Skip to content

Clear all 4 CodeQL alerts (insecure randomness + unanchored regexes)#30

Merged
Isonimus merged 2 commits into
mainfrom
fix/codeql-randomness-and-regex
Jun 10, 2026
Merged

Clear all 4 CodeQL alerts (insecure randomness + unanchored regexes)#30
Isonimus merged 2 commits into
mainfrom
fix/codeql-randomness-and-regex

Conversation

@Isonimus

Copy link
Copy Markdown
Contributor

Resolves the 4 open high-severity CodeQL alerts on main.

#1 js/insecure-randomnesspackages/core/src/session.ts

The v4-UUID fallback used Math.random() when crypto.randomUUID was unavailable. Replaced with a crypto.getRandomValues-based UUID (cryptographically secure, and getRandomValues has much wider runtime support than randomUUID). Math.random is gone; a non-random monotonic id (bs-<ts>-<n>) remains only as a last resort for runtimes with no Web Crypto at all. (The session id is a UX-telemetry marker, not a security token — but there's no reason to leave weak randomness in.)

#2-4 js/regex/missing-regexp-anchore2e/tests/{next,react,vue}.spec.ts

page.waitForResponse(/jsonplaceholder\.typicode\.com/) was unanchored, so it could match the host appearing anywhere in a URL. Anchored to /^https:\/\/jsonplaceholder\.typicode\.com\//. Test-only, but it clears the alerts cleanly.

tsc --noEmit clean; all 62 core unit tests pass.

Isonimus added 2 commits June 10, 2026 16:27
- session id: drop the Math.random() v4-UUID fallback (js/insecure-randomness).
  Prefer crypto.randomUUID, then crypto.getRandomValues (secure, near-universal
  support); only a non-random monotonic id remains for the rare runtime with no
  Web Crypto at all. The session id is UX telemetry, not a security token.
- e2e: anchor the jsonplaceholder waitForResponse regexes
  (^https://jsonplaceholder.typicode.com/) so they cannot match the host as a
  substring elsewhere in a URL (js/regex/missing-regexp-anchor x3).
@Isonimus Isonimus merged commit 79f8108 into main Jun 10, 2026
3 checks passed
@Isonimus Isonimus deleted the fix/codeql-randomness-and-regex branch June 10, 2026 14:39
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