
- Business logic implements application functionality: login/logout, purchases, transfers, approvals, workflows, and the rules that guard them.
- Small applications can still expose serious business-logic flaws (for example: user enumeration via timing differences or missing brute-force protections in a login flow).
- When auditing, focus on where server-side enforcement is missing, where state transitions are inconsistent, or where client-supplied values are treated as authoritative.
- If you want to review the prompts used to drive these audits, they are published here:
- Race conditions: concurrent request handling, double-spending prevention, inventory updates.
- Price and value manipulation: client-side totals, coupon/discount abuse, currency tampering.
- Workflow bypass: skipping validation steps, status manipulation, approval-flow circumvention.
- Time-based vulnerabilities: TOCTOU (Time of Check, Time of Use), expiration bypasses, timezone issues.
- Integer overflow/underflow: calculation errors and negative-value handling.
| Issue class | What to verify | Example |
|---|---|---|
| Race conditions | Atomicity of state updates, DB transactions, optimistic/pessimistic locks | Two simultaneous checkouts decrement same inventory item |
| Price manipulation | Server-side price calculation and validation | Client submits modified total or discount code directly |
| Workflow bypass | Endpoint sequencing, required status checks | Calling approval endpoint directly to mark request as approved |
| Time-based issues | Normalize time comparisons, use server time for expiry checks | Using client time to validate a token expiry |
| Integer overflow | Use proper numeric types and bounds checks | Balance underflow when subtracting large values |
- Double-spend / race conditions: Concurrent requests modify shared state (e.g., inventory) without suitable locking or transactional safeguards.
- Client-side price validation: Never trust totals or prices from the client; compute and validate authoritative values server-side.
- Workflow bypass: Ensure each step in a workflow enforces required checks and transitions; attackers can call endpoints out-of-order to override intended flow.
- Time-based attacks: Differences between time of check and time of use may allow expiry bypasses or TOCTOU issues.
- Integer issues: Watch for underflow/overflow in financial calculations, counters, and balances.
Always validate critical values on the server — client-side checks are for better UX only and can be bypassed by an attacker.
- Risk Score: 6.5/10 — five vulnerabilities identified; rate limiting and timing attacks are top priority.
- Top findings:
- Timing attack / user enumeration via measurable response-time differences.
- Missing rate limiting (no brute-force protection on login endpoint).
- Weak JWT secret present in development configuration.
- Error information disclosure (detailed DB errors returned).
- Missing account lockout / failed-attempt tracking.
- The audit flagged a measurable timing discrepancy in the authentication path. When a login attempt references a non-existent user, the code returns immediately. When a user exists, the code calls bcrypt.compare(), which adds a measurable delay (~100 ms). Attackers can distinguish valid accounts by measuring response times across many requests.
routes/auth.js:29-46):
- Early return for non-existent users vs. bcrypt.compare() for existing users produces measurable timing differences.
- Attackers can enumerate valid accounts by measuring average response times.
- The login endpoint lacked rate limiting. Add express-rate-limit or a similar middleware to slow or block brute-force attempts.
- Implement server-side counters and temporary lockouts after repeated failures. Use business-appropriate backoff and unlock mechanisms (email or admin unlock) to avoid permanent denial for legitimate users.
- Do not use default or development secrets in production. Generate secure secrets and fail-fast if missing.
- Avoid returning detailed database or stack traces to clients. Log internal details server-side and return a concise, generic error to the caller.
| Check | Result |
|---|---|
| Race conditions | Pass |
| Price manipulation | Not applicable |
| Workflow bypass | Pass |
| Time-based vulnerabilities | Fail (timing attack / user enumeration) |
| Integer overflow/underflow | Not applicable |
| Rate limiting | Fail |
| Account lockout | Fail |
| Error information disclosure | Fail |
- Add rate limiting on authentication endpoints.
- Normalize authentication timing to mitigate user enumeration.
- Validate and require a strong JWT secret; fail startup if missing.
- Implement account lockout / failed-attempt tracking with safe unlock paths.
- Sanitize error responses to avoid leaking internal details.
Do not use development default secrets in production. Rotate weak secrets and enforce secure values in deployment pipelines.
- Business-logic vulnerabilities can meaningfully increase application risk even in small demos.
- In this Express login demo the primary issues were timing-based user enumeration and missing brute-force protections; both can be fixed with the code snippets above.
- After applying fixes, re-run the audit to confirm mitigations and detect regressions.
- Audit prompts repository: https://github.com/JeremyMorgan/Claude-Code-Reviewing-Prompts
- express-rate-limit: https://www.npmjs.com/package/express-rate-limit
- bcrypt documentation: https://www.npmjs.com/package/bcrypt
- JWT best practices: https://auth0.com/learn/json-web-tokens/
- OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html