Insecure Authentication Detection — ShipSafe

ShipSafe ships 98 authentication rules that go beyond checking for missing middleware. It detects weak password hashing algorithms (MD5, SHA1, unsalted SHA256), JWT misconfigurations (algorithm confusion, missing expiration, 'none' algorithm acceptance), insecure cookie flags, CSRF gaps on state-changing routes, and password storage in localStorage or sessionStorage.

98 detection rulesLocal-only scanning

What is Insecure Authentication?

Insecure authentication encompasses vulnerabilities in how applications verify user identity and manage sessions. Weak authentication allows attackers to compromise passwords, keys, or session tokens, or exploit implementation flaws to assume other users' identities.

Why It Matters

Authentication is the front door of your application. When it fails, every other security control fails too — access control, audit logging, data isolation, all of it depends on knowing who the user is. Weak password hashing means a database breach becomes a mass password compromise. JWT misconfiguration can let attackers forge tokens and impersonate any user, including administrators. Missing auth on API routes is the most common vulnerability in AI-generated code, because AI assistants focus on the business logic and forget the security layer.

What ShipSafe Detects

Example: Vulnerable Code

Missing authentication and weak password hashing

// Vulnerable: no auth middleware on admin route
app.delete("/api/users/:id", async (req, res) => {
  await db.query("DELETE FROM users WHERE id = $1", [req.params.id]);
  res.json({ deleted: true });
});
// Anyone on the internet can delete any user!

// Vulnerable: weak password hashing
const crypto = require("crypto");
const hash = crypto.createHash("md5").update(password).digest("hex");
// MD5 produces identical hashes for identical passwords (no salt)
// and can be brute-forced at billions of attempts per second on a GPU.

ShipSafe Catches It

$ shipsafe scan

  HIGH  auth/missing-auth-middleware
  src/routes/admin.ts:1
  DELETE endpoint /api/users/:id has no authentication middleware.
  Fix: Add authentication middleware — app.delete("/api/users/:id", requireAuth, async (req, res) => { ... })

  HIGH  auth/weak-password-hash
  src/auth.ts:3
  MD5 used for password hashing. MD5 is cryptographically broken.
  Fix: Use bcrypt or argon2 — await bcrypt.hash(password, 12)

What to Do Instead

Safe alternatives: auth middleware, bcrypt hashing, and secure cookie settings

// SAFE: auth middleware + authorization check
import { requireAuth, requireRole } from "./middleware/auth";

app.delete("/api/users/:id", requireAuth, requireRole("admin"),
  async (req, res) => {
    await db.query("DELETE FROM users WHERE id = $1", [req.params.id]);
    res.json({ deleted: true });
  }
);

// SAFE: bcrypt password hashing with work factor
import bcrypt from "bcrypt";

// Hash with cost factor 12 (~250ms per hash — fast enough for login,
// slow enough to make brute force infeasible)
const hash = await bcrypt.hash(password, 12);

// Verify
const isValid = await bcrypt.compare(inputPassword, storedHash);

// SAFE: secure cookie settings
app.use(session({
  cookie: {
    httpOnly: true,   // JS cannot read the cookie (blocks XSS theft)
    secure: true,     // only sent over HTTPS
    sameSite: "lax",  // blocks cross-site request forgery
    maxAge: 24 * 60 * 60 * 1000, // 24 hours
  },
}));

Frequently Asked Questions

Why is MD5 bad for password hashing?

MD5 is cryptographically broken and can be computed at over 10 billion hashes per second on a modern GPU. It also produces no salt by default, meaning identical passwords produce identical hashes. Use bcrypt (cost factor 12+) or argon2id instead — these are designed to be intentionally slow and include built-in salting.

What is JWT algorithm confusion?

JWT algorithm confusion occurs when a server that expects RS256 (asymmetric) tokens is tricked into accepting HS256 (symmetric) tokens signed with the RS256 public key. Since the public key is public, the attacker can forge any token. ShipSafe detects JWT verify calls that do not explicitly restrict the accepted algorithms.

Does ShipSafe detect missing auth on Next.js API routes?

Yes. ShipSafe detects Next.js API routes (both Pages Router and App Router) that perform database operations or sensitive actions without checking authentication. It understands Next.js middleware patterns and server-side session validation.

What is IDOR and does ShipSafe detect it?

IDOR (Insecure Direct Object Reference) is when a user can access another user's data by changing an ID in the URL or request body. ShipSafe detects patterns where a user-supplied ID from req.params or req.body is used directly in a database query without verifying that the authenticated user owns that resource.

Detect Insecure Authentication in Your Code

Install ShipSafe and scan your project in under 60 seconds.

npm install -g @shipsafe/cli

Related Security Categories