Skip to content

Wave 19: bundled semgrep rules for handler fetch timeouts, auth cookie flags and credentialed CORS - #2173

Merged
remigiusz-antczak merged 1 commit into
mainfrom
land/wave-19
Oct 31, 2026
Merged

remigiusz-antczak merged 1 commit into
mainfrom
land/wave-19

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

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): a fetch with no signal inside a route handler.
  • perun.js.auth-cookie-flags (WARNING): a session or auth cookie set without httpOnly or secure. Receivers whose libraries document both flags as on by default are reported only for a literal false; the two fetched sources are logged in docs/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:

  • Tests: run-ci-tests.sh --affected with the derived files rebuilt first, as CI does: 18/18 selected suites pass, with semgrep installed so the live fixture checks ran.
  • Changelog fragments 23/23, size ratchet ok, privacy gate clean (rc 0).
  • CI's per-PR legs install no semgrep, so there the new test runs only its offline checks.

🤖 Generated with Claude Code

…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>
@remigiusz-antczak
remigiusz-antczak merged commit 5a83897 into main Oct 31, 2026
11 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the land/wave-19 branch October 31, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant