Repository navigation
Description
Query File Path
js/session-fixation, js/user-controlled-bypass, js/missing-rate-limiting, js/missing-rate-limiting
Update Type
Enhanced detection coverage
Issue Description
AI Scan reported 6 medium-severity CWE-307, CWE-384 (auth rate limit session fixation) finding(s) in JavaScript public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: query-logic, scope-condition, query-absent. Existing queries considered: js/session-fixation, js/user-controlled-bypass, js/missing-rate-limiting, js/missing-rate-limiting.
Why CodeQL appears to have missed these (unverified until reproduced with a test database):
- Shipped js/session-fixation looks for a route path containing 'login', a req.session write, and no regenerate call. This handler has exactly those semantics, so the miss is in route/handler recognition or local flow logic.
- The nearby shipped missing-rate-limiting alerts concern different routes. This route has a limiter, but its key is attacker-controlled X-Forwarded-For under trust-proxy; detecting the bypass needs query logic linking limiter configuration to an untrusted key.
- Login handler without rate limiting; existing query targets expensive handlers only.
- Login sets session state without regenerating session id; no JS session-fixation query.
Linked findings (gap-key: javascript/query-update/auth-rate-limit-session-fixation)
| Repo | CWE | Severity | AI scan alert | Summary |
|---|---|---|---|---|
| NodeGoat | CWE-384 | medium | https://github.com/codeql-forks-felickz/NodeGoat/security/code-scanning/27 | The login handler assigns the authenticated user ID to the existing session instead of regenerating it. An attacker who obtains or fixes a victim's pre-login session ID can reuse that same ID after the victim authenticates and hijack the account. |
| juice-shop | CWE-307 | medium | https://github.com/codeql-forks-felickz/juice-shop/security/code-scanning/118 | The application trusts proxy headers globally and the reset-password limiter uses the raw attacker-controlled X-Forwarded-For header as its key. A client can rotate that header on each request to evade the per-IP limit and brute-force password-reset security answers. |
| Goatlin | CWE-307 | medium | https://github.com/codeql-forks-felickz/Goatlin/security/code-scanning/16 | Every protected API request performs an unrestricted email/password lookup, with no per-account or per-source attempt limit, delay, or lockout anywhere in the application. Attackers can repeatedly submit guessed Basic credentials—assisted by the registration endpoint's email enumeration signal—until a password is found. Add rate limiting and progressive account-level protections while avoiding denial-of-service-prone permanent lockouts. |
| NodeGoat | CWE-307 | medium | https://github.com/codeql-forks-felickz/NodeGoat/security/code-scanning/39 | The login handler performs authentication on every request with no per-account or per-source throttling, delay, or temporary lockout. Attackers can therefore automate password spraying and brute-force attacks, made more effective by the weak password policy and username enumeration. Add layered rate limiting and monitored, carefully bounded account backoff. |
| nodejs-goof | CWE-384 | medium | https://github.com/codeql-forks-felickz/nodejs-goof/security/code-scanning/54 | On successful login the handler only sets session.loggedIn = 1 on the existing session instead of calling req.session.regenerate(). An attacker who can set or learn a victim's connect.sid value before login (e.g. via a fixation vector) retains a session that becomes authenticated. The session is further weakened by a static, publicly known signing secret and a cookie configuration that does not set secure or sameSite. |
| nodejs-goof | CWE-307 | medium | https://github.com/codeql-forks-felickz/nodejs-goof/security/code-scanning/48 | The administrator login handler has no per-account or per-client throttling, delay, or lockout. A remote attacker can make unrestricted password attempts against a known username, enabling automated online brute-force and credential-stuffing attacks. |
Findings come from AI Scan on public synthetic apps. Hypotheses above are unverified until reproduced with a test database. Verify first whether CodeQL already covers a case (for example via a different query or threat model) before adding code.
Handling decision
- Type: Query Update
- Decision: Update existing CodeQL queries. The queries named above already target this weakness class; the findings show missing flow steps, sinks, sources, barriers or scope handling. Extend the smallest existing query or model instead of adding a new query.
- Recommended actions across the findings: extend-existing-query (5), write-new-query (1)
Patterns in this gap
missing-rate-limiting-login(3 findings), for example Goatlin packages/services/api/src/middleware/auth.jsquery-logic(2 findings), for example NodeGoat app/routes/session.jssession-fixation(1 finding), for example nodejs-goof routes/index.js
Finding details
Each finding below has its own context so the agent can work from this issue alone.
1. NodeGoat app/routes/session.js:116 (CWE-384, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/NodeGoat/security/code-scanning/27
- AI Scan message: The login handler assigns the authenticated user ID to the existing session instead of regenerating it. An attacker who obtains or fixes a victim's pre-login session ID can reuse that same ID after the victim authenticates and hijack the account.
- Why CodeQL appears to miss it: query-logic: Shipped js/session-fixation looks for a route path containing 'login', a req.session write, and no regenerate call. This handler has exactly those semantics, so the miss is in route/handler recognition or local flow logic.
- Existing CodeQL queries considered: js/session-fixation
- Recommended action from the comparison: extend-existing-query (classification confidence: high)
2. juice-shop server.ts:365 (CWE-307, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/juice-shop/security/code-scanning/118
- AI Scan message: The application trusts proxy headers globally and the reset-password limiter uses the raw attacker-controlled
X-Forwarded-Forheader as its key. A client can rotate that header on each request to evade the per-IP limit and brute-force password-reset security answers. - Why CodeQL appears to miss it: query-logic: The nearby shipped missing-rate-limiting alerts concern different routes. This route has a limiter, but its key is attacker-controlled X-Forwarded-For under trust-proxy; detecting the bypass needs query logic linking limiter configuration to an untrusted key.
- Existing CodeQL queries considered: js/user-controlled-bypass, js/missing-rate-limiting
- Recommended action from the comparison: extend-existing-query (classification confidence: medium)
3. Goatlin packages/services/api/src/middleware/auth.js:16 (CWE-307, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/Goatlin/security/code-scanning/16
- AI Scan message: Every protected API request performs an unrestricted email/password lookup, with no per-account or per-source attempt limit, delay, or lockout anywhere in the application. Attackers can repeatedly submit guessed Basic credentials—assisted by the registration endpoint's email enumeration signal—until a password is found. Add rate limiting and progressive account-level protections while avoiding denial-of-service-prone permanent lockouts.
- Context for the agent: In Goatlin at packages/services/api/src/middleware/auth.js:16: Every protected API request performs an unrestricted email/password lookup, with no per-account or per-source attempt limit, delay, or lockout anywhere in the application. Attackers can repeatedly submit guessed Basic credentials—assisted by the registration e CodeQL would need an extension of the existing query (source/sink/sanitizer modelling) to flag this pattern.
- Why CodeQL appears to miss it: scope-condition: Login handler without rate limiting; existing query targets expensive handlers only.
- Existing CodeQL queries considered: js/missing-rate-limiting
- Recommended action from the comparison: extend-existing-query (classification confidence: low)
4. NodeGoat app/routes/session.js:58 (CWE-307, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/NodeGoat/security/code-scanning/39
- AI Scan message: The login handler performs authentication on every request with no per-account or per-source throttling, delay, or temporary lockout. Attackers can therefore automate password spraying and brute-force attacks, made more effective by the weak password policy and username enumeration. Add layered rate limiting and monitored, carefully bounded account backoff.
- Context for the agent: In NodeGoat at app/routes/session.js:58: The login handler performs authentication on every request with no per-account or per-source throttling, delay, or temporary lockout. Attackers can therefore automate password spraying and brute-force attacks, made more effective by the weak password policy an CodeQL would need an extension of the existing query (source/sink/sanitizer modelling) to flag this pattern.
- Why CodeQL appears to miss it: scope-condition: Login handler without rate limiting; existing query targets expensive handlers only.
- Existing CodeQL queries considered: js/missing-rate-limiting
- Recommended action from the comparison: extend-existing-query (classification confidence: low)
5. nodejs-goof routes/index.js:68 (CWE-384, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/nodejs-goof/security/code-scanning/54
- AI Scan message: On successful login the handler only sets
session.loggedIn = 1on the existing session instead of callingreq.session.regenerate(). An attacker who can set or learn a victim'sconnect.sidvalue before login (e.g. via a fixation vector) retains a session that becomes authenticated. The session is further weakened by a static, publicly known signing secret and a cookie configuration that does not setsecureorsameSite. - Context for the agent: In nodejs-goof at routes/index.js:68: On successful login the handler only sets
session.loggedIn = 1on the existing session instead of callingreq.session.regenerate(). An attacker who can set or learn a victim'sconnect.sidvalue before login (e.g. via a fixation vector) retains a session CodeQL would need a new query or sink coverage for this pattern. - Why CodeQL appears to miss it: query-absent: Login sets session state without regenerating session id; no JS session-fixation query.
- Recommended action from the comparison: write-new-query (classification confidence: medium)
6. nodejs-goof routes/index.js:50 (CWE-307, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/nodejs-goof/security/code-scanning/48
- AI Scan message: The administrator login handler has no per-account or per-client throttling, delay, or lockout. A remote attacker can make unrestricted password attempts against a known username, enabling automated online brute-force and credential-stuffing attacks.
- Context for the agent: In nodejs-goof at routes/index.js:50: The administrator login handler has no per-account or per-client throttling, delay, or lockout. A remote attacker can make unrestricted password attempts against a known username, enabling automated online brute-force and credential-stuffing attacks. CodeQL would need an extension of the existing query (source/sink/sanitizer modelling) to flag this pattern.
- Why CodeQL appears to miss it: scope-condition: Login handler without rate limiting; existing query targets expensive handlers only.
- Existing CodeQL queries considered: js/missing-rate-limiting
- Recommended action from the comparison: extend-existing-query (classification confidence: low)
Proposed Solution
- Reproduce each linked finding with a minimal synthetic test case and confirm the baseline result.
- Identify the missing source, sink, summary or scope condition and extend the smallest model or query that fixes it.
- Add positive and negative tests and a change note.
- Check the false-positive rate on the other linked findings before widening.
Code Examples
See the linked alerts above for the vulnerable pattern; reduce each to a minimal test case with a safe counterpart that should not alert.
Breaking Change?
No - backward compatible
References (Optional)
https://cwe.mitre.org/data/definitions/307.html
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
felickz commentedon Nov 3, 2026
Upstream triage
precision:mediumRelies on heuristics or accepted over-approximation. Community Packs, always tags:experimental.
tags:experimental
Goes to Community Packs: performance, false-positive or synthetic-only concerns.
Community Packs, experimental. Recommended for the Community Packs repository, not
github/codeql. The issue is labeledtags:experimentalfor this.Separable piece. session handling patch to js/session-fixation, with real-project evidence. This part could be proposed to
github/codeqlon its own, see the split note below.Linked pull request: #367
Why. Mixed PR. The session change adds req.session type tracking to a stock query (scratch run: stock reports 1 of 2 test routes, the copy both) but keeps its login-path heuristic and the stock id. The rate-limit query is new, relies on a fixed header list and the deployment's trust proxy setting, and falls back to any app in the database for unlinked limiters. Medium precision: Community Packs, experimental; the session patch could go upstream alone.
mediumin the pull request). Session patch only adds type tracking but keeps the stock '%login%' route-path heuristic. Rate-limit query uses a fixed client-IP header list, a fallback to any app trusting all proxies when a limiter is unlinked, and ignores proxy deployment, so noticeable false positives are plausible.Concerns, overlap and next steps
False-positive concerns
Performance concerns
Heuristics used
What an upstream change would look like. Community Packs: javascript/src/security/CWE-307/RateLimitSpoofableKey.ql with tests. The session patch could instead be a small PR to stock Security/CWE-384/SessionFixation.ql with tests and a change note; a Community Packs copy needs a distinct
@id.Before opening an upstream pull request
@idif kept as a copy, or propose it against the stock querySplit note. Two parts. The session change patches a stock query (type-tracks req.session into helpers) and is the better candidate for github/codeql on its own, with real-project evidence. The rate-limit query is new and medium precision, so Community Packs.
Change from the initial guess. When this issue was opened the coarse destination guess was
github/codeql. Reading the actual pull request changed it to Community Packs.This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.