Skip to content
Source
Sign inSign up
pingdotgg/t3code

security: add HTTP security headers, CSP, and core dump gitignore #1782

Closedbscheffbuch(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1782/headopened View on GitHub

Security Hardening

This PR addresses several findings from a security audit of the codebase.

Changes

  1. HTTP Security Headers (apps/server/src/server.ts)

    • Added X-Content-Type-Options: nosniff and X-Frame-Options: DENY to all HTTP responses via an Effect HttpRouter.middleware
    • Prevents MIME-type sniffing attacks and clickjacking
  2. Content Security Policy (apps/web/index.html)

    • Added CSP meta tag restricting script sources, connection targets, and frame ancestors
    • Uses wasm-unsafe-eval for Shiki syntax highlighting compatibility (WebAssembly)
    • Allows font loading from Google Fonts and WebSocket connections to localhost
  3. Gitignore Core Dumps (.gitignore)

    • Added core.* pattern to prevent accidental commits of core dump files
    • Core dumps can contain sensitive data (env vars, tokens, memory contents)

Type-checked

All changes pass tsc --noEmit with zero new errors.


Note

Low Risk Low risk hardening changes; main risk is inadvertently breaking browser resource loading or WebSocket/dev connections due to the new CSP.

Overview Adds basic security hardening across server and web.

The server now applies a global HttpRouter middleware that sets X-Content-Type-Options: nosniff and X-Frame-Options: DENY on all HTTP responses. The web app adds a Content-Security-Policy meta tag restricting scripts/styles/fonts/images and allowed connection targets (including localhost/ws), and .gitignore now excludes core.* files.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c0dd0c548f609e1f423e5eae57e46751d7353593. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add HTTP security headers and Content Security Policy to server and web app

  • Adds a middleware in server.ts that sets x-content-type-options: nosniff and x-frame-options: DENY on all HTTP responses.
  • Adds a CSP meta tag to index.html restricting resource origins, disallowing framing via frame-ancestors 'none', and permitting WebAssembly via wasm-unsafe-eval.
  • Adds core.* to .gitignore to exclude core dump files from the repository.
Macroscope summarized c0dd0c5.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 18c4b677-123e-4e5a-a90e-a5a828b4701c

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c0dd0c548f609e1f423e5eae57e46751d7353593. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -3,3 +3,6 @@
      33 <head>
      44 <meta charset="UTF-8" />
      55 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      6+ <meta
      7+ http-equiv="Content-Security-Policy"
      8+ content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: blob:; connect-src 'self' ws: wss: http://localhost:* http://127.0.0.1:* https://fonts.googleapis.com https://fonts.gstatic.com; frame-ancestors 'none'; base-uri 'self';"
      cursor[bot](GitHub profile, opens in a new tab)commented

      CSP allows WebSocket connections to any host

      Medium Severity

      The connect-src directive uses bare ws: and wss: scheme sources, which permit WebSocket connections to any host on the internet. The PR description states it "Allows WebSocket connections to localhost," but the actual policy is far broader. If an XSS vector is ever found, data could be exfiltrated over a WebSocket to an attacker-controlled server, undermining the purpose of the CSP. Restricting to specific origins (e.g., ws://localhost:* ws://127.0.0.1:*) would match the stated intent more accurately.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c0dd0c548f609e1f423e5eae57e46751d7353593. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -3,3 +3,6 @@
      33 <head>
      44 <meta charset="UTF-8" />
      55 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      6+ <meta
      7+ http-equiv="Content-Security-Policy"
      8+ content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: blob:; connect-src 'self' ws: wss: http://localhost:* http://127.0.0.1:* https://fonts.googleapis.com https://fonts.gstatic.com; frame-ancestors 'none'; base-uri 'self';"

      CSP frame-ancestors silently ignored in meta tags

      Low Severity

      The frame-ancestors 'none' directive in the CSP <meta> tag is silently ignored by all browsers per the W3C CSP Level 3 specification. Browsers are required to strip frame-ancestors (along with report-uri and sandbox) when processing CSP via a meta element. This creates a false sense of clickjacking protection. The X-Frame-Options: DENY header added in server.ts does provide actual protection, but the ineffective directive in the meta tag is misleading and could cause issues if someone later removes the HTTP header assuming the CSP covers it.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c0dd0c548f609e1f423e5eae57e46751d7353593. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. Approvability

      Verdict: Needs human review

      This PR modifies security-related configurations (HTTP headers, CSP policy), which require human review per policy. Additionally, there are unresolved review comments identifying security issues: the CSP's WebSocket policy is overly permissive, and the frame-ancestors directive is ineffective in meta tags.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.