Skip to content

fix(api): enforce one access boundary for HTTP and WebSocket - #974

Open
saksim wants to merge 1 commit into
NanmiCoder:mainfrom
saksim:codex/upstream-api-access
Open

saksim wants to merge 1 commit into
NanmiCoder:mainfrom
saksim:codex/upstream-api-access

Conversation

@saksim

@saksim saksim commented Sep 9, 2026

Copy link
Copy Markdown

The WebUI API accepts anonymous remote requests to data, logs, environment information, and crawler controls; WebSocket handshakes have no origin/authentication boundary. Add shared ASGI access middleware and bind the default entry point to loopback with proxy-header parsing disabled.

Without a token, require a loopback peer/Host and a trusted browser Origin. With MEDIACRAWLER_API_TOKEN configured, require Bearer authorization for every HTTP request and WebSocket handshake, including local clients. Preserve local WebUI and Vite development origins. Remote deployments and the current WebUI token-input limitation are documented in docs/api-access.md.

Validation: all 12 new access-control tests fail before the fix. The isolated upstream branch passes all 108 tests (Python 3.11, Windows with PYTHONUTF8=1). Tests verify sensitive HTTP routes, blocked start/stop side effects, malformed/rebound Host, same/cross-origin requests, valid local WebSocket connections, and correct/incorrect tokens. Existing API parameter tests use a fixture-only token and continue to run.

Cookie process transport and JSONL support are separate PRs. Fork tracking and CI: PR #23. Related report: saksim#1.

@saksim
saksim requested a review from NanmiCoder as a code owner September 9, 2026 03:24
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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