Skip to content

security: fix all 20 CodeQL code scanning alerts#104

Merged
NeuroKoder3 merged 6 commits intomainfrom
fix/codeql-security-alerts
May 11, 2026
Merged

security: fix all 20 CodeQL code scanning alerts#104
NeuroKoder3 merged 6 commits intomainfrom
fix/codeql-security-alerts

Conversation

@NeuroKoder3
Copy link
Copy Markdown
Owner

Summary

Resolves all 20 open CodeQL code scanning alerts:

Critical Fixes:

  • Disabling certificate validation - Set
    ejectUnauthorized: true\ in SIEM TLS connections (\siemForwarder.cjs)
  • Polynomial ReDoS (2 alerts) - Replaced backtracking regex /^Bearer\s+(.+)$/i\ and /^Basic\s+(.+)$/i\ with non-backtracking string operations in auth middleware and SMART routes
  • Server-side URL redirect - Added \sanitizeRedirectPath()\ to prevent open redirect via SAML RelayState

Rate Limiting (7 alerts):

  • Added per-route
    ateLimit\ config to all public endpoints: login, MFA verify, refresh, SAML, OIDC, OAuth2 authorize/token/introspect/revoke, health/ready, SMART discovery, CDS services

Clear-text Logging (7 alerts):

  • Redacted patient PII (name, DOB) in \epic-sandbox-test.mjs\
  • Removed detailed clinical data logging (labs, conditions, meds, allergies)
  • Masked org ID in \database/init.cjs\ dev logging
  • Sanitized error objects in \smoke-test.mjs\ catch blocks

Other:

  • Biased cryptographic random - Switched to rejection sampling in MFA backup code generation (\mfa.cjs)
  • Incomplete string escaping (2 alerts) - Escape backslashes before quotes in RFC 5424 syslog formatter (\siemForwarder.cjs)

Additional hardening (prior commit):

  • CORS origin allowlist, error message suppression, PG SSL enforcement, SSRF protection, JWKS HTTPS-only, ReDoS guards, CSP tightening, cookie SameSite, API base URL validation, CodeQL workflow improvements

Test plan

  • Verify auth login/refresh/MFA flows still work
  • Verify SAML and OIDC SSO redirects function correctly
  • Verify SMART on FHIR token endpoint accepts Basic auth
  • Verify SIEM TLS forwarding with valid certificates
  • Verify MFA backup code generation produces valid codes
  • Run
    pm run test:security\ and
    pm run test:business\
  • Confirm CodeQL re-scan shows 0 open alerts

Made with Cursor

NeuroKoder3 and others added 2 commits May 10, 2026 21:17
- CORS: replace permissive origin:true with configurable allowlist

- Error handling: suppress internal error messages from 500 responses

- TLS: enforce rejectUnauthorized for PG SSL require mode

- Auth: prevent open redirect via RelayState; move tokens to httpOnly cookies

- SMART: remove user_id auth bypass; strip sensitive fields from introspect

- SSRF: add DNS-based private IP blocking for subscription delivery and JWKS

- SSRF: validate endpoint URLs in pushToEHR with private range blocking

- Headers: sanitize outbound subscription headers; block injection vectors

- ReDoS: guard dynamic RegExp in vendor profiles and FHIR validation rules

- Info disclosure: genericize HL7 ACK errors, auth middleware, integrations

- Timing: use constant-time comparison for webhook secret verification

- Randomness: replace Math.random with crypto.randomUUID/getRandomValues

- XSS: sanitize document_urls href with protocol allowlist (http/https)

- CSP: tighten script-src, add frame-ancestors/base-uri/form-action

- Cookies: add SameSite=Lax and Secure to sidebar cookie

- API client: validate base URL scheme; reject non-https in production

- Logging: prevent raw request body injection in CDS feedback logs

- CodeQL CI: remove continue-on-error, add security-extended queries

Co-authored-by: Cursor <cursoragent@cursor.com>
- Disabling certificate validation: set rejectUnauthorized=true in SIEM TLS (siemForwarder.cjs)

- Polynomial ReDoS: replace backtracking regex in Bearer/Basic header parsing with string ops (auth.js, smart.js)

- Missing rate limiting: add per-route rateLimit config to all public endpoints (auth, smart, health, cds)

- Biased cryptographic random: use rejection sampling in MFA backup code generation (mfa.cjs)

- Clear-text logging: redact patient PII in epic-sandbox-test, mask org ID in init.cjs, sanitize error objects in smoke-test

- Incomplete string escaping: escape backslashes before quotes in RFC5424 syslog formatter (siemForwarder.cjs)

- Server-side URL redirect: already fixed in prior commit via sanitizeRedirectPath (auth.js)

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread scripts/epic-sandbox-test.mjs Fixed
Comment thread scripts/smoke-test.mjs Fixed
Comment thread server/src/routes/auth.js Fixed
NeuroKoder3 and others added 4 commits May 10, 2026 21:35
…f sensitive information'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…f sensitive information'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…rect'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@NeuroKoder3 NeuroKoder3 merged commit f383f1e into main May 11, 2026
15 checks passed
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.

2 participants