AppSec Review: OWASP Code & API Security
- **Security design** generates a `controls.md` file specifying authentication, session, and authorization requirements for a service.
$5
Works with the AI Agents you already use
AppSec Review: OWASP Code & API Security
Example session with this skill installed
Review this API for security problems. I want to know how good it is and what's wrong with it.
- Read your context and instructions
- Compiled the appsec review
A real, unedited Review-mode run of this skill on a seeded test repository: a fictional system built for the skill's eval, not a customer's.
billdesk-api: Application Security Review
Mode: Review,
service tier (R1–R4, all nine domains). This is a static code and config review only. I sent no requests to any running system.
Source: the working tree of billdesk-api 2.3.0, read on 2026-11-03. It is not a git repository, so there is no commit to cite and no history to scan. Rubric v1.0.
Stack: Node.js (the engines field allows >=20; the actual runtime is 🔬), Express 4.19.2, express-session 1.18.0 with the default MemoryStore, raw pg 8.11.3 (no ORM), hand-written password check (src/auth.js), helmet 7.1.0, cors 2.8.5, swagger-ui-express serving api/openapi.yaml. The deployment is an SPA plus a JSON API with
cookie sessions (connect.sid). It is multi-tenant: every user belongs to one tenant (business).
Tools: semgrep, gitleaks and osv-scanner are not installed here, so none ran. I did not run npm audit: the lockfile has no transitive entries or integrity hashes, and the audit would send the dependency list to the registry. Dependency CVEs below come from known advisories for the pinned versions. They are marked ⚠️, so confirm them with npm audit / osv-scanner on a full lockfile.
Coverage: all 11 operations and all 10 query/redirect sinks were read line by line. The repo is small (about 150 lines of code).
Verdict
Score: 2.0 / 10, band "Critical / unsafe" (2.6 without the caps). Gate: FAIL on 7 of 8 conditions.
The API should not be exposed in its current state. The core of it is reasonable: v2 uses parameterised queries almost everywhere, orders are scoped to the tenant correctly, helmet is on, and the error handler is generic. The problems are concentrated in a few places, and several are severe:
Anyone on the internet can read every tenant's invoices. /api/v1 is still mounted with no authentication, and the client chooses the tenant ID with a query parameter.
2.
Any signed-in user can run arbitrary SQL through invoice search. Because pg uses the simple query protocol here, stacked statements work, so this means read and write access to the whole database, including every user's unsalted MD5 password hash.
3. Any signed-in user can rewrite any other user's email and role, across tenants, with PATCH /users/me and an id in the body.
4.
The v2 single-invoice endpoint has no tenant check. Users of one business can read another business's invoices by ID.
5.
Credentials live in the repo: a production-labelled DATABASE_URL with an embedded password in .env, plus a hard-coded session-signing secret in app.js.
Underneath these sit three missing layers. Fixing those layers fixes most of the findings:
- Authentication is opt-in per router. It is not deny-by-default.
- There is no authorisation or data-access layer. Each handler writes its own tenant predicate, or forgets to.
- Nothing validates or allow-lists request input. That covers query parameters, bodies and redirect targets.
R1: Inventory
Secrets found (kind and location only, values redacted)
| Location | Kind | Notes |
|---|---|---|
.env:3 | DATABASE_URL: a Postgres connection string with an embedded username and password | The same file sets NODE_ENV=production (.env:1). The README (README.md:11,15) tells developers to copy this file, and .gitignore does not exclude .env, so it is meant to travel with the repo. Whether the credential is live is 🔬. |
.env:4 | STRIPE_SECRET_KEY: a payment-provider secret key, test-mode prefix | Lower impact than a live key, but still a credential to the provider account. Rotate it. |
src/app.js:21 | express-session signing secret, a literal string | The same value in every environment and every clone. |
Endpoint inventory
All operations, one row per route × method × version.
| # | Method · path | Ver | Who may call | Authn checked | Authz checked | Untrusted inputs | Sinks | State change | Cookie-auth | Spec |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | POST /auth/login | – | anonymous | n/a | n/a | body username, password; query next | SQL (param) auth.js:9; log routes/auth.js:9; redirect routes/auth.js:13 | yes (session) | sets cookie | ❌ shadow |
| 2 | POST /auth/logout | – | anyone | none | none | none | session store | yes | yes | ❌ shadow |
| 3 | GET /api/v2/invoices/search | v2 | user | app.js:30 (requireAuth) | tenant predicate in SQL, but concatenated | query q | SQL (concatenated) invoices.js:10-13 | no* | yes | ✅ |
| 4 | GET /api/v2/invoices/:id | v2 | user | app.js:30 | none | path id | SQL (param) invoices.js:23, SELECT * | no | yes | ✅ |
| 5 | GET /api/v2/orders | v2 | user | app.js:31 | query predicate tenant_id = session orders.js:10-11 🟢 | none | SQL (param) | no | yes | ✅ |
| 6 | GET /api/v2/orders/:id | v2 | user | app.js:31 | query predicate id AND tenant_id orders.js:23-24 🟢 | path id | SQL (param) | no | yes | ✅ |
| 7 | GET /api/v2/users/me | v2 | user | app.js:32 | session user id users.js:12 🟢 | none | SQL (param) | no | yes | ✅ |
| 8 | PATCH /api/v2/users/me | v2 | user | app.js:32 | target id taken from the body after Object.assign users.js:24-27 | whole JSON body | SQL UPDATE (param) on email, display_name, role, id | yes | yes | ✅ (spec documents only email, display_name) |
| 9 | GET /api/v1/invoices?tenant= | v1 | anonymous | none (app.js:33) | client-chosen tenant legacy.js:12 | query tenant | SQL (param) | no | no | ❌ zombie |
| 10 | GET /api/v1/invoices/:id | v1 | anonymous | none | none | path id | SQL (param), SELECT * legacy.js:23 | no | no | ❌ zombie |
| 11 | GET /docs (+ assets) | – | anonymous | none | none | none | Swagger UI renders the spec | no | no | ❌ not listed |
*Endpoint 3 is read-only by design, but the injection lets stacked UPDATE/DELETE statements run (see AS-INP-01).
Totals: 11 operations,
5 reachable anonymously (login, logout, both v1 routes, docs), 3 that change state, all authenticated by cookie.
Reconciliation: code ↔ spec ↔ gateway ↔ DNS
| Surface | Code | Spec (api/openapi.yaml) | Gateway / DNS | Classification |
|---|---|---|---|---|
/api/v2/*, 6 operations | yes | yes, all 6 | 🔬 not supplied | in sync |
/api/v1/invoices, /api/v1/invoices/:id | mounted app.js:33 | absent; servers lists only /api/v2 | 🔬 | Zombie. The README says v1 was "replaced by v2 in 2024". It is still served, and without the authentication v2 has. |
/auth/login, /auth/logout | yes | absent | 🔬 | Shadow, undocumented |
/docs | yes, unconditional | n/a | 🔬 | discovery artefact exposed anonymously |
PATCH /users/me body | accepts any property | documents email and display_name only, with no additionalProperties: false | – | Drift. The spec states a restriction the handler does not enforce. |
Spec operations with no route: none.
Trust boundaries
| Boundary | What is trusted, and the problem |
|---|---|
| Browser ↔ API | The session cookie is the only credential. CORS reflects every origin with credentials, so for the browser any website is treated as a trusted client. The cookie is not HttpOnly, not Secure and has no SameSite. |
Old mobile app ↔ /api/v1 | v1 trusts the caller to say which tenant it is (?tenant=). There is no authentication at all. |
| User ↔ tenant | Tenant isolation is enforced per handler. Three of the eight object-access handlers fail it. |
| API ↔ Postgres | One pool with one connection string (db.js:3). Every query runs with the same database privileges, so the SQL injection has the app's full rights. TLS to the database is 🔬 (depends on sslmode in the URL). |
| API ↔ payment provider | A key is present in .env, but no code calls the provider. That raises the question of why the key ships with the repo at all. |
Credential stores and crypto uses
| Use | Where | With what |
|---|---|---|
| Password storage | auth.js:4-6 | MD5, unsalted, compared with === (auth.js:15) |
| Session ID generation | express-session (uid-safe) | CSPRNG 🟢 |
| Session cookie signing | express-session, secret at app.js:21 | HMAC-SHA256, literal secret |
| Secrets | .env, app.js:21 | in the repo; there is no secret store |
Dependencies
| Package | Pinned | Notes |
|---|---|---|
| express 4.19.2 | exact | ⚠️ CVE-2024-43796 (XSS in the res.redirect body, fixed in 4.20.0). The vulnerable call is reachable at routes/auth.js:13. Bundled path-to-regexp 0.1.7 has CVE-2024-45296 (ReDoS), which needs two parameters in one segment; no route here has that, so it is not reachable. Bundled body-parser below 1.20.3 has CVE-2024-45590, which hits the urlencoded parser only; that parser is not mounted, so it is not reachable. |
| express-session 1.18.0 | exact | ⚠️ Bundles cookie below 0.7.0 (CVE-2024-47764). Cookie attributes here are not request-controlled, so it is not reachable. The default MemoryStore is used in production. |
| lodash 4.17.15 | exact | ⚠️ CVE-2020-8203 (prototype pollution, zipObjectDeep), CVE-2021-23337 (code injection, template), CVE-2020-28500 (ReDoS). Only _.omit is used (users.js:29), so none is reachable today. |
| yamljs 0.3.0 | exact | No release since 2017. It parses only a trusted local file. |
| cors 2.8.5, helmet 7.1.0, pg 8.11.3, swagger-ui-express 5.0.0 | exact | No reachable advisories known to me. |
| Lockfile | present | Lists only the 8 direct packages: no transitive entries and no integrity hashes (package-lock.json:8-15). It does not actually lock the tree. |
| Runtime | >=20 | Node 20 reached end of life on 2026-04-30, and this range still allows it. The deployed version is 🔬. |
| Licences | – | All direct dependencies are MIT or ISC (permissive). There is no inventory or NOTICE file. |
Object counts per domain
These weight the score: input 10 · authentication 3 · access 11 · crypto 6 · configuration 1 · dependencies 9 · logging 6 · browser 4 · api 11.
Total 61.
R3: Findings
The severity grade assumes reachability as stated and that the data is
business invoices and user accounts across tenants, meaning other businesses' financial and personal data. Confidence markers: ✅ decidable from the code, ⚠️ proxy that needs confirmation, 🔬 needs runtime data.
Critical
| ID | Object | Anti-pattern | Conf. | Theory | OWASP 2021 / API 2023 | Evidence (source → sink, missing check) |
|---|---|---|---|---|---|---|
| AS-API-01 | GET /api/v1/invoices, GET /api/v1/invoices/:id | Zombie API with weaker controls than v2; no authentication; client-chosen tenant | ✅ | A40, A9, A10, A11 | A01 / API9 + API1 | app.js:33 mounts legacyRoutes with no requireAuth. In legacy.js:12, req.query.tenant goes straight into the tenant_id = $1 predicate. In legacy.js:23, SELECT * FROM invoices WHERE id = $1 has no owner check. An anonymous caller can walk ?tenant=1..N and dump every tenant's invoices, or walk sequential IDs to get full invoice rows. The README calls v1 replaced, and the spec does not list it. |
| AS-INP-01 | GET /api/v2/invoices/search | SQL injection by string interpolation | ✅ | A2, A1 | A03 / API8 (2019) | The source is req.query.q (invoices.js:9). It is interpolated into a template literal at invoices.js:12 (ILIKE '%${q}%'), and so is tenantId. The sink is db.query(text) with no parameter array, so pg uses the simple query protocol and stacked statements run. One quote breaks out of the tenant predicate: any authenticated user can read all tenants, read users.password_hash, and run UPDATE/DELETE. |
| AS-ACC-01 | PATCH /api/v2/users/me | Mass assignment that grants privilege; target object chosen by the client | ✅ | A41, A12, A10 | A01 / API3 (BOPLA) + API1 | users.js:24 does Object.assign(rows[0], req.body). Then users.js:26-27 runs UPDATE users SET email=$1, display_name=$2, role=$3 WHERE id=$4 with user.role and user.id from the body. A body like {"id":<victim>,"email":"<attacker>","role":"<any>"} overwrites any user's email and role, in any tenant. The spec (openapi.yaml:42-51) says only email and display_name are writable. Bonus impact: the response at users.js:29 echoes the merged row, which includes every column except password_hash. |
| AS-ACC-02 | GET /api/v2/invoices/:id | IDOR: no tenant predicate | ✅ | A10 | A01 / API1 | invoices.js:23 runs SELECT * FROM invoices WHERE id = $1, and req.session.user.tenantId is never used. Compare the correct pattern in orders.js:23. Any user can read any tenant's invoice by sequential ID, and gets the whole row. |
| AS-CRY-01 | .env | Production-labelled database credential committed with the source | ✅ present / 🔬 live | A17 | A02 / – | .env:3 holds DATABASE_URL with an embedded password, next to NODE_ENV=production (.env:1). .gitignore (.gitignore:1-2) does not exclude .env, and README.md:11 tells developers to copy it. .env:4 holds a payment-provider secret key (test mode). I can't tell from here whether the credentials are live or whether earlier commits held other values (🔬: no git history). Treat both as compromised and rotate them. |
High
| ID | Object | Anti-pattern | Conf. | Theory | OWASP / API | Evidence |
|---|---|---|---|---|---|---|
| AS-AUT-01 | Credential store | Fast, unsalted password hash | ✅ | A8, A14 | A07 / API2 | auth.js:5 uses createHash('md5') with no salt. Identical passwords give identical hashes, and GPUs crack them at billions of guesses per second. Combined with AS-INP-01, this turns a SQL injection into account takeover at scale. The comparison is also not constant-time (auth.js:15, Low on its own). |
| AS-ACC-03 | CORS policy | Reflected origin with credentials | ✅ | A30, A12 | A01 / API8 | app.js:18 sets cors({ origin: true, credentials: true }). Every origin is echoed back with Access-Control-Allow-Credentials: true, and preflights for PATCH pass. Any site can read a logged-in user's API responses and send state-changing requests, as far as the browser forwards the cookie. Today, browser third-party-cookie defaults (Chrome Lax-by-default, Firefox and Safari partitioning) blunt the purely cross-site case. That protection comes from the browser, not the app, and it does not apply to same-site origins such as any *.billdesk.example sibling. |
| AS-ACC-04 | POST /auth/login, PATCH /users/me, POST /auth/logout | No CSRF defence on cookie-authenticated state changes | ✅ | A12 | A01 | There is no token or Origin check anywhere, and the cookie has no SameSite (app.js:24). The JSON content-type preflight would normally help, but AS-ACC-03 approves every preflight. That leaves login CSRF, and PATCH /users/me CSRF, which combined with AS-ACC-01 escalates a victim's privileges. |
| AS-AUT-02 | Session cookie | Cookie readable by script and sent over HTTP; no SameSite | ✅ | A7, A31 | A07 | app.js:24 sets cookie: { secure: false, httpOnly: false }. Any XSS on a sibling page can read connect.sid, and the cookie travels over plain HTTP. helmet sends HSTS, but the first HTTP request and non-HSTS clients still leak it. Whether a TLS-terminating proxy sits in front, and how trust proxy should be set, is 🔬. |
| AS-AUT-03 | Login | Session not regenerated at login (session fixation) | ✅ | A7 | A07 | routes/auth.js:12 assigns req.session.user without req.session.regenerate(). A session ID planted before login is upgraded in place. AS-CRY-02 makes planting easier. |
| AS-CRY-02 | Session signing secret | Hard-coded literal secret | ✅ | A17, A7 | A02 / API2 | app.js:21 sets secret: 'billdesk-session-secret'. It is identical in every deployment and clone, and can only be rotated by a code release. Knowing it lets an attacker mint validly signed cookies for any session ID. express-session keeps the session data server-side, so this does not forge a login by itself. It does enable fixation and removes the integrity layer. |
| AS-LOG-01 | Login | Plaintext password written to the log | ✅ | A24 | A09 | routes/auth.js:9 logs `login attempt user=${username} password=${password}`. Every user's password, including failed attempts that are often a near-miss of the real password, lands in stdout and whatever collects it. username is not encoded, so log forging is also possible. |
| AS-INP-02 | POST /auth/login?next= | Open redirect on the login flow | ✅ | A5, A28 | A01 | routes/auth.js:13 calls res.redirect(req.query.next || '/app'), and nothing checks the target. Express 4.19.2 also carries CVE-2024-43796 on exactly this call (⚠️, see AS-DEP-01). |
| AS-API-02 | POST /auth/login; all API operations | Credential endpoint unmetered | ✅ (in code) / 🔬 (gateway) | A42, A8 | A07 / API4 | There is no rate limiter, delay or lockout anywhere (app.js, routes/auth.js). Unlimited online guessing becomes cheap. Search (invoices.js:10) and v1 list (legacy.js:10) have no row limit. |
| AS-API-03 | GET /api/v2/invoices/:id, GET /api/v1/invoices/:id, PATCH /users/me response | Stored objects serialised whole | ⚠️ (table columns unknown) | A41 | A01 / API3 | invoices.js:23-25 and legacy.js:23-24 do SELECT * → res.json(rows[0]). users.js:29 returns the whole user row minus one field (a deny-list, not an allow-list). Any column added later, such as an MFA secret or an internal note, leaks automatically. The real column set is 🔬. |
Medium
| ID | Object | Anti-pattern | Conf. | Theory | OWASP / API | Evidence |
|---|---|---|---|---|---|---|
| AS-ACC-05 | All routers | Authentication opt-in per mount; no central authorisation layer | ✅ | A9 | A01 | app.js:29-33 attaches requireAuth router by router, and v1 shows what happens when one is forgotten. Tenant scoping is written separately in each handler (orders.js:11,24 correct; invoices.js:23, legacy.js, users.js:27 wrong). req.session.user.role is stored but never checked, and goes stale after a role change. |
| AS-API-04 | GET /docs | Discovery artefact exposed anonymously | ✅ | A43 | A05 / API8 | app.js:27 mounts it unconditionally, with no NODE_ENV check or authentication. Its content is limited to v2 today. |
| AS-API-05 | Single-object reads | Existence oracle, inconsistent across versions | ✅ | A16, A10 | A01 / API1 | v2 orders correctly return 404 for "not yours" and "missing" alike. v2 invoices return other tenants' data (AS-ACC-02). v1 returns {} vs a full row (legacy.js:24). |
| AS-INP-03 | All inputs | No server-side schema on any boundary | ✅ | A1 | A03 | id is never checked as an integer (a non-numeric value becomes a pg error and a 500). q, tenant and next are unvalidated, and the PATCH body is unvalidated (email format, length). |
| AS-CFG-01 | Session store | Default MemoryStore in production | ✅ | A18 | A05 | app.js:20-25 configures no store. MemoryStore leaks memory, loses every session on restart, and does not work across instances. That makes it an availability and logout-consistency problem. |
| AS-CFG-02 | Configuration | No per-environment config | ✅ | A18 | A05 | There is one .env with production values, and the README instructs copying it to developer machines. Cookie flags and the session secret are literals rather than environment-driven. |
| AS-BRW-01 | Authenticated JSON responses | No Cache-Control: no-store on personal responses | ✅ | A35 | A05 | No handler or middleware sets it. Invoices and profile data may be cached by browsers or intermediaries. |
| AS-AUT-04 | Sessions | No idle or absolute timeout | ✅ | A7 | A07 | app.js:24 sets no maxAge or rolling expiry, and the MemoryStore keeps sessions until restart. |
| AS-LOG-02 | Security events | Login outcome, 401s, role and email changes not logged | ✅ | A23 | A09 | The only security log line is the bad one (AS-LOG-01). Role changes through PATCH leave no trace. |
| AS-DEP-01 | express 4.19.2, express-session 1.18.0, lodash 4.17.15 | Known-vulnerable versions; one reachable | ⚠️ | A21 | A06 | The express res.redirect XSS advisory is reachable at routes/auth.js:13. The lodash and cookie advisories have no reachable call today, but lodash 4.17.15 is a trap for the next _.template or _.zipObjectDeep. Confirm with npm audit. |
| AS-DEP-02 | Lockfile | Incomplete lockfile without integrity hashes | ✅ | A21 | A08 | package-lock.json:8-15 has 8 entries and no transitive dependencies or integrity fields. The installed tree is whatever resolves on the day. |
| AS-DEP-03 | Runtime | engines: >=20 admits an end-of-life Node | ⚠️ | A21 | A06 | package.json:10. Node 20 has been end of life since April 2026. The deployed version is 🔬. |
Low
| ID | Object | Note |
|---|---|---|
| AS-CRY-03 | auth.js:15 | Hash comparison with === is not constant-time (A16). It becomes moot once a KDF's verify function is used. |
| AS-DEP-04 | yamljs 0.3.0 | Unmaintained since 2017 (A21). It only parses a trusted local file. |
| AS-DEP-05 | Licences | All dependencies are permissive, but there is no inventory, SBOM or NOTICE (A22). |
| AS-AUT-05 | POST /auth/logout | The session is destroyed 🟢, but the cookie is not cleared, and logout is CSRF-able (nuisance only). |
🔬 Needs-data flags (not scored)
- Whether the
DATABASE_URLand payment key in.envare live, and whether earlier versions are in VCS history. This is not a git repo, so history could not be scanned. - Whether a gateway, ingress or DNS name in front still routes
/api/v1, or exposes other hosts or versions. - Whether a TLS-terminating proxy is in front, and the
trust proxysetting that implies. - The real Node runtime version in production.
- The real column set of
invoicesandusers(sensitive fields exposed bySELECT *and the PATCH echo). - Whether the Postgres connection uses verified TLS (
sslmode). - Whether stdout logs are shipped off-host, and whether any alerting exists.
- Which
rolevalues exist and what they unlock in the SPA or other services. This determines the full blast radius of AS-ACC-01.
What is working well 🟢 (keep and extend)
- Parameterised queries in 8 of the 9 query sinks (
$1placeholders with arrays).
The orders handlers are the reference pattern for tenant isolation: WHERE id = $1 AND tenant_id = $2 with the tenant taken from the session (orders.js:23-24), a uniform 404, an explicit column list, and LIMIT 100.
Explicit column lists on search, the orders endpoints and GET /users/me. password_hash is never selected for /me.
- The tenant comes from the server-side session, not the request, in v2.
- helmet with defaults: CSP,
nosniff, frame protection, HSTS, Referrer-Policy. - A generic error handler (
app.js:35-38): no stack traces to clients. saveUninitialized: false,resave: false, andsession.destroy()on logout.- Exact version pins in
package.json.
express.json's default 100 kB body limit, and JSON responses only (no HTML templating, so no reflected XSS surface in the API).
R4: Scores
The arithmetic follows the scoring guide. Each criterion is graded by the fraction p of in-scope objects that pass it: 🟢 (p ≥ 0.95) = 2 points, 🟡 (0.50 ≤ p < 0.95) = 1 point, 🔴 (p < 0.50) = 0 points. base = Σ points / (2 × criteria) × 10. Caps: any open Critical caps the domain at 2.0; any open High caps it at 6.0. Criteria marked N/A have no in-scope object.
input (10 sinks: 9 queries, 1 redirect)
| Criterion | Pass / in scope | p | Pts |
|---|---|---|---|
| 1 Parameterised | 8/9 | 0.89 | 🟡 1 |
| 3 Output encoded (JSON) | 9/9 | 1.0 | 🟢 2 |
| 5 Server-side schema | 0/10 | 0 | 🔴 0 |
| 6 Parsers safe | 2/2 | 1.0 | 🟢 2 |
| 9 Redirect allow-listed | 0/1 | 0 | 🔴 0 |
Criteria 2, 4, 7 and 8 are N/A. Base = 5/10 × 10 = 5.0; the Critical cap (AS-INP-01) gives 2.0.
authentication (3 mechanisms: password login, session, credential store)
| Criterion | Pass / in scope | p | Pts |
|---|---|---|---|
| 1 Framework authentication (session yes, password check hand-rolled) | 1/2 | 0.50 | 🟡 1 |
| 2 Slow salted KDF | 0/1 | 0 | 🔴 0 |
| 4 Rotated at login | ✗ | – | 🔴 0 |
| 5 Cookie flags | ✗ | – | 🔴 0 |
| 6 Timeouts | ✗ | – | 🔴 0 |
| 9 Throttled | ✗ | – | 🔴 0 |
| 10 MFA for privileged roles (⚠️: roles exist, privilege unknown, so capped at 🟡) | – | – | 🟡 1 |
Criteria 3, 7 and 8 are N/A (no registration, tokens or recovery flow in code). Base = 2/14 × 10 =
1.4. The High cap (6.0) doesn't bind, so the score is
1.4.
access (11 endpoints)
| Criterion | Pass / in scope | p | Pts |
|---|---|---|---|
| 1 Central authorisation layer, deny by default | none exists | 0 | 🔴 0 |
| 2 Object access scoped by tenant | 4/8 | 0.50 | 🟡 1 |
| 3 No decisions on client signals | 6/8 | 0.75 | 🟡 1 |
| 4 CSRF defence | 0/3 | 0 | 🔴 0 |
| 5 CORS restricted | 0/1 | 0 | 🔴 0 |
| 6 Request binding allow-listed | 1/2 | 0.50 | 🟡 1 |
Criteria 7 and 8 are N/A. Base = 3/12 × 10 = 2.5; the Critical cap gives 2.0.
crypto (6 objects: MD5 hash, session HMAC, session-ID RNG, 3 secrets)
| Criterion | Pass / in scope | p | Pts |
|---|---|---|---|
| 1 Vetted, current algorithms | 2/3 | 0.67 | 🟡 1 |
| 2 CSPRNG and salts | 1/2 | 0.50 | 🟡 1 |
| 3 Keys separated by purpose and environment | 0/1 | 0 | 🔴 0 |
| 4 Constant-time comparison | 1/2 | 0.50 | 🟡 1 |
| 5 Secrets from a store | 0/3 | 0 | 🔴 0 |
| 7 Key lifecycle | 0/1 | 0 | 🔴 0 |
Criterion 6 (TLS clients) is 🔬. Base = 3/12 × 10 = 2.5; the Critical cap (AS-CRY-01) gives 2.0.
configuration (1 production config)
| Criterion | Result | Pts |
|---|---|---|
| 1 Debug off | pass | 🟢 2 |
| 2 Generic errors | pass | 🟢 2 |
| 4 HTTPS + HSTS (⚠️: HSTS on, cookie not Secure, proxy 🔬) | partial | 🟡 1 |
| 5 Baseline headers | pass | 🟢 2 |
| 6 No default secrets (literal session secret) | fail | 🔴 0 |
| 7 Fail closed (errors yes, authentication opt-in, ⚠️) | partial | 🟡 1 |
| 8 Per-environment config | fail | 🔴 0 |
Criterion 3 is N/A (docs are graded under api). Base = 8/14 × 10 =
5.7. No High or Critical finding is attributed to this domain, so the score is
5.7.
dependencies (8 direct + runtime = 9)
| Criterion | Result | Pts |
|---|---|---|
| 1 Locked and pinned (exact pins, hollow lockfile) | partial | 🟡 1 |
| 2 No known-exploited/critical reachable (⚠️ 6/9 clean) | p 0.67 | 🟡 1 |
| 3 SCA in CI | fail | 🔴 0 |
| 4 Supported runtime (⚠️) | partial | 🟡 1 |
| 5 Maintained (8/9) | p 0.89 | 🟡 1 |
| 6 Integrity verified | fail | 🔴 0 |
| 7 SBOM | fail | 🔴 0 |
| 8 Licences inventoried | fail | 🔴 0 |
Base = 4/16 × 10 = 2.5. There are no Highs here, so the score is 2.5.
logging (6 events: login success, login failure, 401, role change, email change, logout)
| Criterion | Pass / in scope | Pts |
|---|---|---|
| 1 Events logged | 0/6 | 🔴 0 |
| 2 No secrets in logs | fail | 🔴 0 |
| 3 Input encoded against forging | fail | 🔴 0 |
Criteria 4 and 5 are 🔬. Base = 0.0, so the score is 0.0.
browser (4 objects: JSON class, docs HTML, static assets, the CORS policy)
| Criterion | Result | Pts |
|---|---|---|
| 1 Explicit type + nosniff | pass | 🟢 2 |
3 Request data in headers (⚠️, redirect Location) | partial | 🟡 1 |
| 4 URL decisions on parsed parts | fail | 🔴 0 |
| 6 CORS allow-listed | fail | 🔴 0 |
7 __Host- cookie + CSRF token | fail | 🔴 0 |
| 8 Framing denied | pass | 🟢 2 |
| 9 No cross-site includable data | pass | 🟢 2 |
11 no-store | fail | 🔴 0 |
| 12 Request size/time bounded | partial | 🟡 1 |
Criteria 2, 5 and 10 are N/A. Base = 8/18 × 10 =
4.4. There are no Criticals in this domain, so the score is
4.4.
api (11 operations)
| Criterion | Pass / in scope | p | Pts |
|---|---|---|---|
| 1 In the reconciled inventory | 6/11 | 0.55 | 🟡 1 |
| 2 Retired versions answer 410 | 0/1 | 0 | 🔴 0 |
| 3 Per-role response shapes | 5/8 | 0.63 | 🟡 1 |
| 4 Writable properties allow-listed | 1/2 | 0.50 | 🟡 1 |
| 5 Consumption limits | 0 | 0 | 🔴 0 |
| 6 Page size bounded | 1/3 | 0.33 | 🔴 0 |
| 7 Docs gated | fail | 0 | 🔴 0 |
| 8 Uniform refusals | 1/3 | 0.33 | 🔴 0 |
| 10 Token/secret strength | fail | 0 | 🔴 0 |
Criterion 9 is 🔬. Base = 3/18 × 10 = 1.7, which is already below the Critical cap of 2.0, so the score is 1.7.
| input | authentication | access | crypto | configuration | dependencies | logging | browser | api | Service |
|---|---|---|---|---|---|---|---|---|---|
| 2.0 | 1.4 | 2.0 | 2.0 | 5.7 | 2.5 | 0.0 | 4.4 | 1.7 | 2.0 |
Service score. Each domain score is weighted by its object count:
- Capped: (10·2.0 + 3·1.4 + 11·2.0 + 6·2.0 + 1·5.7 + 9·2.5 + 6·0 + 4·4.4 + 11·1.7) / 61 = 122.7 / 61 = 2.01. Re-applying the Critical cap gives
2.0.
- Uncapped: (10·5.0 + 3·1.4 + 11·2.5 + 6·2.5 + 5.7 + 22.5 + 0 + 17.6 + 18.7) / 61 = 161.2 / 61 = 2.6.
Both are in the
Critical / unsafe band. Even with every Critical removed, the uncapped base sits in "Critical / unsafe", because logging, authentication and the API controls are mostly missing rather than slightly wrong.
Severity tally: Critical 5 · High 10 · Medium 12 · Low 4 · 🔬 8.
OWASP tally (2021):
| Category | Findings |
|---|---|
| A01 Broken Access Control | AS-API-01, AS-ACC-01, AS-ACC-02, AS-ACC-03, AS-ACC-04, AS-INP-02, AS-API-03, AS-ACC-05, AS-API-05 |
| A02 Cryptographic Failures | AS-CRY-01, AS-CRY-02 |
| A03 Injection | AS-INP-01, AS-INP-03 |
| A05 Misconfiguration | AS-API-04, AS-CFG-01, AS-CFG-02, AS-BRW-01 |
| A06 Vulnerable Components | AS-DEP-01, AS-DEP-03 |
| A07 Authentication Failures | AS-AUT-01, AS-AUT-02, AS-AUT-03, AS-API-02, AS-AUT-04 |
| A08 Integrity Failures | AS-DEP-02 |
| A09 Logging Failures | AS-LOG-01, AS-LOG-02 |
OWASP API Top 10 (2023):
| Category | Findings |
|---|---|
| API1 Broken Object Level Authorization | AS-API-01, AS-ACC-02, AS-ACC-01, AS-API-05 |
| API2 Broken Authentication | AS-AUT-01, AS-CRY-02 |
| API3 Broken Object Property Level Authorization | AS-ACC-01, AS-API-03 |
| API4 Unrestricted Resource Consumption | AS-API-02 |
| API8 Security Misconfiguration | AS-ACC-03, AS-API-04 |
| API9 Improper Inventory Management | AS-API-01 |
Systemic issues (shared causes)
Authentication is opt-in and there is no authorisation layer (A9, A10). This one missing layer causes AS-API-01, AS-ACC-02, AS-ACC-01 (the target ID) and AS-API-05. The orders handlers prove the team knows the right pattern; nothing forces it on the next handler.
2.
No input contract or binding allow-list (A1, A41). This one missing layer causes AS-INP-01, AS-ACC-01, AS-INP-02, AS-INP-03 and the spec drift. The spec already describes the contract; the code never enforces it.
3.
Secrets and security settings as literals in the repo (A17, A18). This causes AS-CRY-01, AS-CRY-02, AS-AUT-02 and AS-CFG-02. One configuration module, reading from the environment or a secret store and failing closed in production, removes all four.
4.
No inventory discipline (A40, A43). v1 was "replaced in 2024" but never unmounted, and the auth routes and docs are not in the spec. The most severe finding in the review exists only because of this.
5.
Session hardening was never done (A7, A30, A12). The defaults were loosened instead: reflected CORS, httpOnly: false, no regenerate, no SameSite, MemoryStore. Together these make CSRF and session theft easy.
Attack chains worth knowing (traced, not executed)
Anonymous attacker: loop over GET /api/v1/invoices?tenant=<n> to get every tenant's invoices, then call GET /api/v1/invoices/<id> for full rows. Prerequisites: none.
2.
Any customer account: inject through GET /api/v2/invoices/search?q=… to read users.username, password_hash, then crack the unsalted MD5 hashes offline and log in as anyone. Alternatively, a stacked UPDATE users SET role=… skips the cracking.
3.
Any customer account, no SQL needed: send PATCH /api/v2/users/me with {"id": <victim>, "email": "<attacker>", "role": "<highest>"}. This takes over another user's contact address and changes their role, in any tenant.
Gate: FAIL
| Condition | Result | Reason |
|---|---|---|
| Capped score ≥ 9.0 | ❌ | 2.0 |
| No open Critical or High | ❌ | 5 Critical, 10 High |
| Every state change has server-side authorisation and, where cookie-authenticated, a CSRF defence (A9, A10, A12) | ❌ | PATCH /users/me takes its target from the body (AS-ACC-01). No endpoint has a CSRF defence (AS-ACC-04). |
| No unrotated secret in VCS or artefacts (A17) | ❌ | .env:3-4 and app.js:21 (AS-CRY-01, AS-CRY-02). History is unknown. |
| Passwords use a slow salted KDF (A8) | ❌ | Unsalted MD5 (AS-AUT-01) |
| No known-exploited dependency on a reachable path (A21) | ✅ (⚠️) | No known-exploited advisory is reachable. The reachable express redirect CVE is moderate. Confirm with npm audit on a full lockfile. |
| No API version or docs endpoint outside the controlled inventory (A40, A43) | ❌ | /api/v1 zombie, anonymous /docs, undocumented /auth/* |
| 🔬 flags ≤ 10% of objects | ❌ | 8 of 61 (13%) |
Do now (before any wider remediation plan)
Review mode does not prescribe fixes. These items are
containment: they close paths that are open to anyone right now. The full fix sequence belongs in Propose.
Unmount /api/v1 (app.js:33), or put it behind requireAuth plus the session tenant, today. Check the gateway or ingress for the same paths (🔬).
2. Rotate the database password, the payment-provider key and the session secret. Removing them from the files is not enough. Remove .env from the repo, add it to .gitignore, and scan history once the repo is under git.
3.
Stop logging passwords (routes/auth.js:9). Purge existing logs that contain them, and treat any password that appears there as exposed.
4.
Take search offline, or parameterise it (invoices.js:12). Add tenant_id to invoices.js:23 and allow-list the PATCH body (users.js:24-27).
5. Then check the database for signs of the paths above having been used. The 🔬 flags list the evidence needed.
Handoff
I reviewed
billdesk-api2.3.0 from its working tree (no git, so no commit to cite). Stack: Node/Express 4.19.2, express-session, raw pg. Score
2.0 (Critical / unsafe; 2.6 uncapped). The gate
fails on 7 of 8 conditions. There are
5 Critical and 10 High findings, across A01, A02, A03, A07 and A09 (API1, API2, API3, API4, API8, API9). The endpoint inventory and its reconciliation are above.
Next:
Design for access (a central authorisation layer, an authorisation matrix, A-B-A tests), authentication and sessions, and the api inventory and DTOs.
-
Propose to sequence the work: containment first, then the authorisation and input layers as class fixes, then guardrails (a route-vs-spec CI check, a semgrep rule against unparameterised db.query, a secret scanner).
- Fixes go through tdd with a red test per finding.
- The tenant-isolation model goes to threatmodel.
- The proxy, TLS, gateway and DNS 🔬 items go to hardening.
Connects securely to your tools. The creator never sees your data.
About this skill
Software vulnerabilities often boil down to two things: untrusted input being treated as instructions, or actions performed without authorization. This skill audits your codebase against these core failures, providing a rigorous assessment of your application's security posture. It moves beyond simple linting by tracing data from source to sink and verifying the enforcement of security boundaries.
What it does
- Static code review analyzes source, templates, and configurations to identify injection, broken auth, and crypto flaws.
- Endpoint inventory builds a comprehensive map of every route, handler, and consumer, identifying who can call them and what inputs they read.
- Security design generates a
controls.mdfile specifying authentication, session, and authorization requirements for a service. - Remediation sequencing produces a
proposal.mdthat prioritizes fixes by risk and focuses on solving entire classes of bugs at the root. - OWASP alignment grades findings against the OWASP Top 10 and API Top 10 using a standardized 0–10 scoring rubric.
How it works
- Review mode identifies vulnerabilities in a repo or PR diff, producing an evidence-based inventory and score.
- Design mode architects the necessary security controls and authorization matrices for a new or existing service.
- Propose mode creates a phased remediation plan, ensuring each fix starts with a red test and includes a regression guard.
Frameworks & tools
This skill supports .NET, Java, Node.js, Python, PHP, Go, and Ruby. It leverages evidence from tools like Semgrep, CodeQL, Bandit, Gosec, and various SCA scanners while providing manual synthesis.
Why this beats prompting it yourself
Generic prompts often miss "shadow" APIs or fail to trace untrusted input across trust boundaries. This skill uses a formal rubric (A1–A43) to ensure every finding is cited against security theory rather than subjective taste.
Use cases
- PR security audits to catch authorization bypasses or injection risks before they reach the main branch.
- API inventory reconciliation to find zombie endpoints or drift between code and OpenAPI specs.
- Remediation planning for legacy codebases needing a systematic, risk-ordered security overhaul.
- Auth system design for new microservices requiring a formal authorization matrix and session model.
Known limitations
Dynamic testing is restricted to non-production environments explicitly named by the user. Static review coverage depends on the visibility of source code and configuration files.
Dynamic testing requires user-owned non-prod environments. Static review is limited to provided source and config files. Estate-level reviews may require subagent delegation.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 14 days ago
Requires