Skip to content

security: reject cross-site POST/PUT/DELETE on /api (#11) - #38

Merged
alloevil merged 1 commit into
masterfrom
fix/csrf-guard
Sep 7, 2026
Merged

security: reject cross-site POST/PUT/DELETE on /api (#11)#38
alloevil merged 1 commit into
masterfrom
fix/csrf-guard

Conversation

@alloevil

@alloevil alloevil commented Sep 7, 2026

Copy link
Copy Markdown
Owner

No cookies, no auth: a CSRF token would prove nothing. The real attack is a
page on another origin driving the visitor's browser at 127.0.0.1:3800 to
rewrite prompts, install library items or trigger a backup. Browsers always
send Origin / Sec-Fetch-Site on those requests, so lib/csrf.js rejects
unsafe methods whose Origin (or Referer, or Sec-Fetch-Site) is not the Host
the request arrived on. Origin-less clients (curl, scripts) and every GET
are unaffected; HOST=0.0.0.0 LAN setups work from whatever hostname is served.

Closes #11

No cookies, no auth: a CSRF token would prove nothing. The real attack is a
page on another origin driving the visitor's browser at 127.0.0.1:3800 to
rewrite prompts, install library items or trigger a backup. Browsers always
send Origin / Sec-Fetch-Site on those requests, so lib/csrf.js rejects
unsafe methods whose Origin (or Referer, or Sec-Fetch-Site) is not the Host
the request arrived on. Origin-less clients (curl, scripts) and every GET
are unaffected; HOST=0.0.0.0 LAN setups work from whatever hostname is served.

Closes #11
@alloevil
alloevil merged commit bb5b891 into master Sep 7, 2026
3 checks passed
@alloevil
alloevil deleted the fix/csrf-guard branch September 7, 2026 08:27
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