Skip to content

fix(web): default to 127.0.0.1 instead of 0.0.0.0 (unauthenticated API) - #483

Open
Firefly0619sec wants to merge 1 commit into
winfunc:mainfrom
Firefly0619sec:fix/web-bind-localhost
Open

Firefly0619sec wants to merge 1 commit into
winfunc:mainfrom
Firefly0619sec:fix/web-bind-localhost

Conversation

@Firefly0619sec

Copy link
Copy Markdown

Problem

opcode-web binds to 0.0.0.0 by default and its HTTP/WebSocket API has no authentication:

  • web_main.rs: #[arg(short = 'H', long, default_value = "0.0.0.0")], but host was never passed to the server — web_server.rs hard-coded SocketAddr::from(([0, 0, 0, 0], port));
  • CORS is allow_origin(Any) with all methods/headers;
  • endpoints include /api/sessions/execute, /api/sessions/continue, /ws/claude, which drive Claude Code — i.e. anyone on the LAN (or anyone reaching a forwarded port) can execute commands.

This is documented as a feature ("access from phone"), but the secure default should be loopback, with an explicit opt-in for LAN exposure.

Change

  • opcode-web now defaults to 127.0.0.1;
  • the --host argument is actually passed through to create_web_server (it was ignored before);
  • printing a warning when --host 0.0.0.0 is used, because the API is still unauthenticated.

Notes

  • --host 0.0.0.0 still works exactly as before for users who need phone access;
  • I did not add authentication here (that is a larger change) — this PR only makes the dangerous mode opt-in;
  • Happy to follow up with a token/basic-auth layer if you want one.

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