HIGH phishing api keysfeathersjsbasic auth

Phishing Api Keys in Feathersjs with Basic Auth

Phishing Api Keys in Feathersjs with Basic Auth — how this specific combination creates or exposes the vulnerability

FeathersJS is a framework for building REST and real-time APIs with minimal configuration. When Basic Authentication is used without additional protections, API keys or credentials can be exposed through phishing vectors or client-side mishandling. Basic Auth in FeathersJS typically relies on an authentication hook that checks an Authorization header, and if the application does not enforce strict transport security and proper secret management, attackers may phish for these credentials.

Consider a FeathersJS service configured with Basic Auth:

const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const auth = require('@feathersjs/authentication');
const jwt = require('@feathersjs/authentication-jwt');
const basic = require('feathers-authentication-basic');

const app = express(feathers());

app.configure(auth({
  secret: 'your-super-secret-key'
}));

app.configure(basic({
  usernameField: 'email',
  passwordField: 'password'
}));

app.use('/users', require('./users.service'));

If the client sends credentials in an insecure context (e.g., over HTTP or via a malicious site that mimics the API endpoint), a phishing attack can capture the Base64-encoded credentials. Because Base64 is easily reversible, intercepted credentials grant immediate access. Additionally, if the API keys are embedded in client-side code or logs, they become targets for extraction. The 12 security checks in middleBrick include Authentication and BOLA/IDOR, which would flag weak transport configurations and excessive data exposure in this setup.

An attacker may use social engineering to trick a developer or user into revealing credentials used by the FeathersJS Basic Auth flow. Because the authentication header is static for a given credential set, captured tokens can be reused. middleBoot's LLM/AI Security checks would detect system prompt leakage patterns that might expose API keys in error messages, and its Active Prompt Injection tests simulate attempts to override instructions or exfiltrate data via crafted inputs targeting authentication handlers.

Data exposure findings from middleBrick would highlight that Basic Auth without HTTPS places credentials at risk, and the scanner would map this to OWASP API Top 10 and SOC2 controls. The tool does not block or fix the issue but provides remediation guidance, such as enforcing TLS and rotating secrets.

Basic Auth-Specific Remediation in Feathersjs — concrete code fixes

To secure FeathersJS with Basic Auth, enforce HTTPS, avoid embedding secrets in client-side code, and use middleware to validate credentials securely. Below is a hardened configuration example:

const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const auth = require('@feathersjs/authentication');
const jwt = require('@feathersjs/authentication-jwt');
const basic = require('feathers-authentication-basic');

const app = express(feathers());

// Enforce HTTPS in production by checking the environment
app.set('force HTTPS', process.env.NODE_ENV === 'production');

app.configure(auth({
  secret: process.env.AUTH_SECRET || 'fallback-secret-for-dev-only',
  providers: ['jwt', 'basic'],
  path: '/authentication'
}));

app.configure(basic({
  usernameField: 'email',
  passwordField: 'password',
  passReqToCallback: true
}));

// Custom hook to validate Basic Auth credentials against a secure store
app.service('authentication').hooks({
  before: {
    create: [async context => {
      const { email, password } = context.data;
      // Implement secure credential verification, e.g., compare hashed passwords
      if (!email || !password) {
        throw new Error('Missing credentials');
      }
      // Example: verify against a database with hashed passwords
      const user = await getUserByEmail(email);
      if (!user || user.passwordHash !== hashPassword(password)) {
        throw new Error('Invalid credentials');
      }
      context.params.auth = { strategy: 'basic' };
      return context;
    }]
  }
});

app.use('/users', require('./users.service'));

Key remediation steps include:

  • Always use HTTPS to prevent interception of Base64-encoded credentials.
  • Store password hashes instead of plaintext secrets; use libraries like bcrypt.
  • Set environment-specific secrets via process.env and avoid hardcoding.
  • Add rate limiting to mitigate credential stuffing attacks; middleBrick's Rate Limiting check would flag endpoints lacking this.
  • Rotate API keys and secrets regularly, and audit logs for suspicious access patterns.

For CI/CD integration, the middleBrick GitHub Action can be added to fail builds if the security score drops below a chosen threshold, ensuring that insecure configurations are caught before deployment.

Frequently Asked Questions

How does middleBrick detect phishing risks related to Basic Auth in FeathersJS?
middleBrick runs unauthenticated black-box scans that test Authentication and BOLA/IDOR checks. It examines how credentials are transmitted and stored, flagging missing HTTPS, credential leakage in logs or error messages, and weak secret management. Findings include severity levels and remediation guidance without modifying the API.
Can the middleBrick CLI be used to scan a FeathersJS Basic Auth endpoint and get a detailed report?
Yes. Use the CLI tool by running middlebrick scan <url> from the terminal. The output provides a security risk score (A–F), per-category breakdowns, and prioritized findings with remediation steps. JSON output can be integrated into scripts or the GitHub Action for automated checks.