Repository navigation
Wave 19: bundled semgrep rules for handler fetch timeouts, auth cookie flags and credentialed CORS - #2173
Merged
Conversation
…e flags and credentialed CORS The bundled semgrep rules in templates/semgrep-taint/js.yml gain three pattern rules for defect classes the taint rules leave unflagged. Each keeps the test-path exclusions of hardcoded-credential-compare. perun.js.fetch-no-timeout (INFO) reports a fetch with no signal inside a Next.js route handler, a pages API handler or an Express-style route callback. Any signal value, an options spread and a fetch outside a handler stay clean; a const-arrow export or a handler passed by name is not seen. perun.js.auth-cookie-flags (WARNING) reports a session or auth cookie, matched as a whole word in the literal name with csrf and xsrf names skipped, set with httpOnly or secure missing or the literal false through <x>.cookie, <x>.setCookie, the Next.js cookies() store (called directly, awaited, or bound to a variable in an enclosing block) or <x>.cookies.set. Receivers whose libraries document both flags as on by default (ctx.cookies from the pillarjs/cookies library behind Koa, SvelteKit's event.cookies, this.cookies and a bare cookies.set) are reported only for a literal false; two standards-index rows record those fetched defaults. Clears and request-side cookie sets are skipped, and options must be an object literal. perun.js.cors-credentials-any-origin (WARNING) reports credentialed CORS that allows any origin (origin true, /.*/ or a callback that always allows) and a handler that copies the request Origin header into Access-Control-Allow-Origin while it sends Allow-Credentials true, unless an allowlist check precedes or encloses the set call. A literal "*" is not reported, because browsers refuse it on credentialed requests, and the req.headers.origin handler shape is left to the default pack's rule that already flags it. New scripts/test_semgrep_js_gaps.py, registered in ci-tests.d, runs annotated fictional fixtures through semgrep with the bundled rules only, plus copies under test paths that must stay clean; offline checks of severity, exclusions and the key regexes run where semgrep is absent. The test_semgrep_taint.py fixtures now pass a signal to fetch, so the new rule does not change the exact findings they assert. Tests: run-ci-tests.sh --affected on this head, with the derived files rebuilt first as CI does (regen-unlanded.sh): 18 selected suites pass, rc 0, including its privacy gate (clean). semgrep is installed here, so the live fixture checks ran in semgrep-js-gaps, semgrep-taint and the four other semgrep suites. Changelog fragments 23/23, size ratchet ok. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
3 bundled semgrep rules for JavaScript defect classes the taint rules miss, each pinned by annotated fictional fixtures.
perun.js.fetch-no-timeout(INFO): afetchwith nosignalinside a route handler.perun.js.auth-cookie-flags(WARNING): a session or auth cookie set withouthttpOnlyorsecure. Receivers whose libraries document both flags as on by default are reported only for a literalfalse; the two fetched sources are logged indocs/standards-index.md.perun.js.cors-credentials-any-origin(WARNING): credentialed CORS that allows any origin, or reflects the request Origin header without an allowlist check.Each rule names its ceiling in the rule file and the changelog.
Verification
Run on this head:
run-ci-tests.sh --affectedwith the derived files rebuilt first, as CI does: 18/18 selected suites pass, with semgrep installed so the live fixture checks ran.🤖 Generated with Claude Code