Log Origin and Sec-Fetch-Site when a session write is refused as cross-origin
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, observability, security
Research direction
Start in server/orcaster_server/deps.py at the require_session Origin check; read the existing tests for that dependency and the admin error handler in server/orcaster_server/main.py:636-651. Add the requested caplog coverage for an htmx cross-origin POST, then update the Unreleased section of the changelog. Done means the test verifies the warning fields and absence of credentials, while the response remains 403 with the same detail and no HX-Redirect.
Written by the indexing model from the issue text.
Description
Problem
require_session refuses a cookie-authenticated write (POST, PUT, PATCH, DELETE) when the Origin check fails. It raises 403 with the detail cross-origin request refused (server/orcaster_server/deps.py:72).
The admin error handler already passes this 403 through instead of redirecting to the login page (server/orcaster_server/main.py:636-651). The user now sees an error, not a login loop.
The application logger still writes nothing when it refuses the request. Only the uvicorn access log shows the 403, without the header values. The usual causes are a WEBAUTHN_ORIGIN that does not match the public URL, or a reverse proxy that rewrites or strips Origin. An operator who sees the 403 cannot tell from the server log which header value was received or what was expected.
Steps to reproduce
- Start the server with
WEBAUTHN_ORIGINset to a value that differs from the URL used in the browser. - Sign in to the dashboard and do any action that sends a POST.
- The browser shows the 403. The application log has no line about it.
Proposed change
- In
require_session, when the Origin check fails, log one WARNING with the receivedOriginheader, the receivedSec-Fetch-Siteheader, the request method and the path. - Do not log cookies, tokens or other headers. Cap the logged header length.
- Add a test that sends a cross-origin POST with
HX-Request: true. Assert the response is 403 withoutHX-Redirect, and that the WARNING is logged (caplog).
Acceptance criteria
- A refused cross-origin write logs one WARNING with the received
OriginandSec-Fetch-Site. - The log line contains no cookie, token or other credential.
- The response is unchanged: status 403 and the same detail. Existing clients and the
/api/v1error model keep working. - A test covers the htmx case (
HX-Request: true) and checks the log record. - CHANGELOG entry under Unreleased.
Open questions
- Should
AuthOriginCheckMiddleware(server/orcaster_server/auth/origin.py:108) log the same way for/auth/*routes? - Should the log line also include the expected origin (the configured
WEBAUTHN_ORIGIN)?
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AInvirion/orcaster
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
enhancement good first issue P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug P2 server
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug client P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
All issues in AInvirion/orcaster
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day