fix: require application/json on dashboard POST endpoints - #6
Closed
SashaMIT wants to merge 1 commit into
Closed
Conversation
Collaborator
|
Thank you for the contribution! Could you please simplify this PR before we merge it?
Please keep the change focused and preserve the existing routing behavior. Thanks again! |
The dashboard's approval-resolve and instruction-inject routes drive a running agent, and previously parsed request bodies regardless of Content-Type. Browsers may send cross-origin 'simple' POSTs (text/plain or form-encoded) without a CORS preflight, so any page the operator visited while the dashboard was up could resolve pending approvals or inject instructions on their behalf. Requiring an exact application/json content type on those two routes turns every cross-origin attempt into a preflighted request, which this server never answers. The bundled UI already sends application/json. The check lives after routing so unknown paths keep their 404, and the comparison is exact so lookalike types are not accepted.
SashaMIT
force-pushed
the
fix/dashboard-csrf-content-type
branch
from
August 7, 2026 03:17
e9b4809 to
a63847c
Compare
Contributor
Author
|
Thanks for the review, all four points addressed and pushed:
Verified live: |
6 tasks
Contributor
Author
|
Superseded by #11, which adds the loopback Host gate, covers select-run, and allows charset on application/json. Closing this incomplete CSRF-only PR in favor of that one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/approvals/<id>/resolve,/api/inject,/api/select-run) drives a running agent: it resolves pending approvals and injects operator instructions._read_json_bodyparses the payload regardless of Content-Type, and browsers may send cross-origin "simple" POSTs (text/plain/form-encoded) without a CORS preflight. Any page the operator visits while the dashboard is up could therefore inject instructions or resolve approvals on their behalf.application/jsonContent-Type on all POSTs. Cross-origin attempts then become preflighted requests, which this server never answers. The bundled UI already sendsapplication/jsonon every POST, so nothing changes for legitimate use.Test plan
tests/test_dashboard_server.py: POST withtext/plain/ no Content-Type → 415; POST withapplication/json(with/without charset) → accepted.Made with Cursor
Made with Cursor