Skip to content

Security review of the local dashboard: CSRF on state-changing routes, DNS rebinding, and an XSS regression suite #118

Closed

Description

@vsn411

Problem: secfoo serve binds 127.0.0.1:8787 by default, which stops other hosts, but not the user's own browser. The FastAPI app has six POST routes (src/secfoo/web/routes/assessments.py and activities.py): create assessment, bulk status, launch runs on an assessment (/assessments/{id}/runs, which starts a paid agent run), upload attachments, delete an assessment, and review a SAST finding. There is no CSRF token, no Origin/Referer check, no TrustedHostMiddleware (DNS rebinding reaches the app with a foreign Host), and no cookie or header a browser would refuse to send cross-site. A page the user visits while the dashboard is running can fetch("http://127.0.0.1:8787/assessments/1/runs", {method: "POST", body: …, mode: "no-cors"}) and trigger scans, delete case files or flip finding reviews. --allow-insecure-runtime and the runtime ingest API-key path need the same review. Markdown rendering already disables raw HTML and tests/test_web/test_no_inline_scripts.py exists, but there is no systematic XSS corpus for report content, which is agent output over untrusted repositories.

Build:

  1. Cross-site protection for every state-changing route: reject requests whose Origin (or Sec-Fetch-Site) is not same-origin, and add TrustedHostMiddleware allowing localhost, 127.0.0.1, [::1] and the --host value. A double-submit CSRF token on the HTML forms is fine as a second layer, but the Origin check is what protects against fetch from other sites. Tests: a cross-origin POST gets 403, a same-origin one works.
  2. Ingest and runtime routes: confirm the API-key check applies to every mutating runtime endpoint, keys compare in constant time, and --allow-insecure-runtime is documented with exactly what it disables.
  3. Response headers: Content-Security-Policy (the app already avoids inline scripts), X-Content-Type-Options, Referrer-Policy, X-Frame-Options: DENY; tests assert them on every route.
  4. XSS regression corpus: reports containing <img onerror>, javascript: links, Markdown link titles with quotes, HTML entities in headings, SVG, data URIs, and Mermaid blocks with script content; assert the rendered page contains none of them executable. Cover the finding detail pages and the attachments download (Content-Disposition, served as octet-stream).
  5. Upload handling: size limits and type checks on /assessments/{id}/attachments (docext.py parses PDF/DOCX/PPTX; fuzz the parsers for 60 s following the fuzz/ harness pattern).
  6. Write the findings and fixes up in SECURITY.md under "Local dashboard threat model".

Where to look: src/secfoo/web/app.py, src/secfoo/web/routes/*.py, src/secfoo/web/templates/**/*.html (the method="post" forms), src/secfoo/report/markdown.py, src/secfoo/docext.py, tests/test_web/, fuzz/.

Done when: every POST route has a cross-origin rejection test; headers tested; the XSS corpus runs in pytest tests; upload limits enforced; SECURITY.md updated with what was found and fixed.

Activity

  1. added
    enhancement
    help wanted
    hackathon
    difficulty: hard
    on Nov 15, 2026
  2. aaas72 commented on Nov 20, 2026

    @aaas72
    Contributor

    Hi! I'd like to take this one too, after #112. Plan: an Origin / Sec-Fetch-Site check on every state-changing route (cross-origin POST gets 403, same-origin works) plus TrustedHostMiddleware for localhost, 127.0.0.1, [::1] and the --host value; an audit of the runtime ingest routes (API key on every mutating endpoint, constant-time compare, documented --allow-insecure-runtime); CSP, X-Content-Type-Options, Referrer-Policy and X-Frame-Options asserted on every route; and an XSS regression corpus for report content (img onerror, javascript: links, quoted link titles, entities in headings, SVG, data URIs, Mermaid with script).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: hardenhancementhackathonhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions