Improper Authentication
Improper Authentication
CWE-287 · High severity · Updated November 6, 2026
What it is
CWE-287 covers a family of weaknesses where an application fails to correctly verify the identity of an entity (user, service, device) that interacts with it. Variants include missing authentication for critical functions, broken authentication logic, weak credentials, predictable session identifiers, and authentication bypass via parameter manipulation.
Why it matters
Improper authentication maps directly to account takeover, lateral movement, and total compromise. It is the foundational weakness behind most disclosed breaches. The OWASP Top 10:2025 lists Authentication Failures at A07. HIPAA, PCI-DSS, and CMMC all impose explicit authentication-control requirements that map to this CWE.
Common patterns
- Authentication checks that only happen client-side (the API doesn't re-verify).
- Password comparison via == (timing-attackable) instead of constant-time comparison.
- Session IDs generated from predictable sources (timestamps, counters, weak PRNG).
- Token validation that decodes JWTs but does not verify the signature.
- Routes that check 'logged in' without checking 'authorized for this resource'.
- Backdoor or debug routes left enabled in production.
Languages affected
Python, JavaScript, TypeScript, Java, Go, Ruby, PHP, C#
What Deva detects
Deva includes a suite of authentication-specific rules: detection of password comparison without constant-time helpers (use crypto.timingSafeEqual, secrets.compare_digest), Python JWT decoding with signature verification off, literal JWT signing keys, some unauthenticated routes depending on the framework, weak randomness such as Math.random, and hardcoded credentials in code or configs (CWE-798 overlap).
Example
Vulnerable
import jwt from 'jsonwebtoken'
app.post('/transfer', async (req, res) => {
// jwt.decode reads the token but never checks its signature.
const user = jwt.decode(req.headers.authorization?.split(' ')[1])
if (!user) return res.status(401).json({ error: 'Unauthorized' })
const fromAccount = await db.getAccountForUser(user.sub)
await db.transfer(fromAccount.id, req.body.toAccount, req.body.amount)
res.json({ ok: true })
})Fixed
import jwt from 'jsonwebtoken'
app.post('/transfer', async (req, res) => {
let user
try {
const token = req.headers.authorization?.split(' ')[1]
user = jwt.verify(token, process.env.JWT_PUBLIC_KEY, { algorithms: ['RS256'] })
} catch {
return res.status(401).json({ error: 'Unauthorized' })
}
const amount = Number(req.body.amount)
if (!Number.isFinite(amount) || amount <= 0) {
return res.status(400).json({ error: 'Bad amount' })
}
const fromAccount = await db.getAccountForUser(user.sub)
if (!fromAccount) return res.status(403).json({ error: 'No account' })
await db.transfer(fromAccount.id, req.body.toAccount, amount)
res.json({ ok: true })
})The vulnerable version has an authentication check, but it is broken: jwt.decode reads the token without verifying its signature, so anyone can forge a token naming any user and move that user's money. The fix uses jwt.verify with a pinned algorithm, rejects a token that fails verification, and validates the amount before executing the transfer.
Where this fits in OWASP Top 10
- A07 Authentication FailuresWeak, missing, or improperly implemented authentication.
Compliance framework references
These references explain how the weakness relates to control topics. They do not mean Deva offers evaluation for every framework listed. CMMC evaluation and SPRS scoring are currently unavailable. See the FAQ for offered frameworks and preview status. Deva provides code-level evidence for your assessment, without certifying compliance.
| Framework | Controls |
|---|---|
| OWASP Top 10:2025 | A07:2025 Authentication Failures |
| NIST 800-53 Rev 5 | IA-2 Identification and Authentication, AC-3 Access Enforcement |
| PCI-DSS v4.0.1 | 8.3 Strong authentication |
| HIPAA Security Rule | 164.312(d) Person or Entity Authentication |
| CMMC L2 | IA.L2-3.5.1 Identify users |