Skip to content

fix(security): drop hardcoded CORS '*' + sanitize error responses - #19

Merged
totobusnello merged 1 commit into
mainfrom
fix/lane2-security
Jun 16, 2026
Merged

totobusnello merged 1 commit into
mainfrom
fix/lane2-security

Conversation

@totobusnello

Copy link
Copy Markdown
Owner

Verified pre-launch security fixes (review swarm lane 2).

  • P1 json() and the /api/brief path hardcoded Access-Control-Allow-Origin: *, overriding the strict allowlist in cors.ts → any website could read the local 127.0.0.1:18802/api/* (health/KG/reflect data). Removed the hardcoded CORS; applyCorsHeaders() (called before routing) is now the single source of truth, still covering the extension caller.
  • P1 the catch-all 500 and hooks.ts returned raw error strings (leaking the DB file path). Now routed through the existing safeErrorMessage() (sanitized message + correlationId; raw error logged server-side).

Build clean.

…ugh safeErrorMessage

[P1] json() helper and /api/brief text path both hardcoded
Access-Control-Allow-Origin: * (plus Allow-Methods/Allow-Headers),
overriding the strict extension allowlist in cors.ts. Removed those
headers from json() and the brief writeHead so applyCorsHeaders() is
the single CORS source of truth (already called at handleRequest entry).

[P1] catch-all 500 in handleRequest and readRecent catch in hooks.ts
returned String(err)/(e as Error).message directly, leaking DB paths
and SQLite fragments. Routed both through safeErrorMessage() from
src/lib/api/safe-error-message.ts; raw error logged server-side via
console.error with correlationId for debuggability.

Build: tsc clean. Files touched: src/api-server.ts, src/api/hooks.ts.
@totobusnello
totobusnello merged commit e7730d8 into main Jun 16, 2026
1 check passed
@totobusnello
totobusnello deleted the fix/lane2-security branch June 16, 2026 19:43
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