-
Notifications
You must be signed in to change notification settings - Fork 761
Add localhost-only connection middleware to but-server #12001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
2ceef18 to
8fe4fd6
Compare
8fe4fd6 to
d7e42bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a localhost-only connection guard to but-server and tightens its CORS configuration, along with documentation describing the security model.
Changes:
- Introduced an Axum middleware (
localhost_only_middleware) that rejects any non-loopback client IP with HTTP 403, and wired it viainto_make_service_with_connect_info::<SocketAddr>(). - Updated the CORS configuration to allow only
http://localhostorigins (with optional port) instead ofAny. - Added
crates/but-server/SECURITY.mddescribing the localhost-only behavior, configuration, and logging of rejected connections.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/but-server/src/lib.rs |
Adds localhost-only middleware, adjusts CORS to a localhost-only origin predicate, and updates server startup to use into_make_service_with_connect_info so the middleware can inspect peer addresses. |
crates/but-server/SECURITY.md |
Documents the localhost-only connection policy, CORS behavior, configuration, and logging of rejected connections for but-server. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
but-servernow rejects non-localhost connections with HTTP 403 Forbidden.Implementation
ConnectInfo<SocketAddr>to validate connection origin viais_loopback()(supports IPv4 and IPv6)tracing::warnfor security monitoringaxum::serve()to useinto_make_service_with_connect_info::<SocketAddr>()Defense-in-depth
Provides protection even if bind address is inadvertently changed from
127.0.0.1to0.0.0.0.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https libgit2/deps/xdiff -I libgit2/deps/pcre -sys�� -sys-21e0336783b-I nu/bin/gcc-ld/ldlibgit2/src/util stup/toolchains/-I son ug/build/libssh2-O0 k/gitbutler/gitb-ffunction-sections ug/build/openssl-fdata-sections ug/b�� -sys-21e0336783b-gdwarf-4 include stup/toolchains/-m64 son -sys-3f7fe3bc8ec/usr/lib/php wildcard_imports-mindepth -sys-1d8c88fdf851(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.