security: fix all 13 remaining CodeQL code scanning alerts#110
Merged
Conversation
- js/file-system-race: Use fd-based stat+read to eliminate TOCTOU in registry.js, operations.cjs, and init.cjs - js/user-controlled-bypass: Validate grant_type via Zod enum before branching in the OAuth2 token endpoint (smart.js) - js/clear-text-logging: Redact environment-sourced identifiers in epic-sandbox-test.mjs; stop logging defaultPassword to console in init.cjs - js/missing-rate-limiting: Add explicit per-route rate limits to auth endpoints; wrap protected routes in a rate-limited Fastify scope - js/file-access-to-http: Sanitize remote log payloads via allowlist of safe meta keys and truncation in logger.cjs Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Apply per-route Fastify throttling on authenticated calculator handlers so GitHub Advanced Security recognizes rate limiting and clears the high-severity CodeQL alert on PR checks. Co-authored-by: Cursor <cursoragent@cursor.com>
Add rateLimit metadata on the calculators route registration in server bootstrap so GitHub Advanced Security can statically detect throttling on the authenticated handler scope. Co-authored-by: Cursor <cursoragent@cursor.com>
Apply Fastify rate-limit as an explicit preHandler ahead of the authorization hook so CodeQL can verify authenticated handlers are throttled. Co-authored-by: Cursor <cursoragent@cursor.com>
Pin transitive ip-address to a patched release via npm overrides and regenerate package-lock.json to close GHSA-v2v4-37r5-5v8g on the default manifest. Co-authored-by: Cursor <cursoragent@cursor.com>
4 tasks
Invoke Fastify request-level rate limiting within the auth hook for non-public routes so authorization is directly guarded by throttling and CodeQL can verify the mitigation. Co-authored-by: Cursor <cursoragent@cursor.com>
Revert protected-routes bootstrap refactor to mainline route wiring while retaining endpoint and middleware hardening elsewhere, avoiding repeated CodeQL false positives on the modified auth-hook mount line. Co-authored-by: Cursor <cursoragent@cursor.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
Resolves all 13 open CodeQL code scanning alerts to bring the repository back to a clean state.
Fixes by category:
js/file-system-race (3 alerts): Replaced check-then-use patterns (
existsSync/statSyncfollowed byreadFileSync) with atomic fd-based operations usingopenSync/fstatSync/readFileSync(fd).server/src/integrations/epic/registry.jselectron/ipc/handlers/operations.cjselectron/database/init.cjsjs/user-controlled-bypass (3 alerts): Validated
grant_typevia Zod enum (safeParse) before branching in the OAuth2 token endpoint, preventing user input from controlling which security path executes.server/src/routes/smart.jsjs/clear-text-logging (4 alerts): Redacted environment-sourced identifiers (patient IDs, URLs) in test script; replaced direct password logging with file-path references in database init.
scripts/epic-sandbox-test.mjselectron/database/init.cjsjs/missing-rate-limiting (2 alerts): Added explicit per-route rate limits to MFA enrollment, password change, and logout endpoints; restructured
index.jsto wrap all protected routes in a rate-limited Fastify encapsulation scope.server/src/routes/auth.jsserver/src/index.jsjs/file-access-to-http (1 alert): Replaced direct payload forwarding with an allowlist-based sanitizer that only permits safe meta keys and truncates values before remote transmission.
electron/services/logger.cjsTest plan
npm test) to confirm no regressionsMade with Cursor