Repository navigation
Require an explicit opt-in before serving without a secret - #35
Merged
Merged
Conversation
An empty secret no longer starts a listener, including on loopback. Whitespace-only secrets are rejected by startup and by both bearer interceptors. allow_unauthenticated is the loopback-only development flag, and unknown auth-like keys are no longer ignored. Co-authored-by: RustFS <hello@rustfs.com>
There was a problem hiding this comment.
🟡 Changes recommended
The restart regression fixture is rejected before reaching its intended persisted-address check, causing its assertion to fail, and the documented loopback launch command now exits at startup.
2 open issues
What changed in this PR
This PR closes the implicit unauthenticated-loopback path left by #13. Server startup now requires a usable shared secret or an explicit loopback-only opt-in; listeners remain plaintext.
Changes:
- Add
security.allow_unauthenticated, reject conflicting settings, and expand rejection of unsupported authentication keys. - Reject whitespace-only credentials consistently across authentication paths.
- Update regression tests, local test fixtures, and English documentation for the new startup requirements.
| File | Description |
|---|---|
| docs/guides/en/deployment.md | Explain explicit loopback opt-in. |
| docs/en/testing.md | Describe updated authentication cases. |
| docs/en/operations.md | Update listener and metrics requirements. |
| docs/en/configuration.md | Document security settings and validation. |
| docs/en/build-and-run.md | Explain new startup requirements. |
| docs/en/architecture.md | Update startup authentication flow. |
| crates/metadb-server/tests/snapshot_status_tests.rs | Opt snapshot fixtures into unauthenticated loopback. |
| crates/metadb-server/tests/security_adversarial_regressions.rs | Expect whitespace-secret startup refusal. |
| crates/metadb-server/tests/scale_in_restart_tests.rs | Opt restart fixtures into unauthenticated loopback. |
| crates/metadb-server/tests/round2_restart_routes_tests.rs | Update restart-route fixtures. |
| crates/metadb-server/tests/round2_quota_order_tests.rs | Update quota-order fixture. |
| crates/metadb-server/tests/round2_namespace_tests.rs | Update namespace startup helper. |
| crates/metadb-server/tests/round2_name_flush_tests.rs | Update name-flush fixture. |
| crates/metadb-server/tests/round2_mixed_shard_tests.rs | Update mixed-shard fixture. |
| crates/metadb-server/tests/round2_cli_tests.rs | Update CLI and metrics fixtures. |
| crates/metadb-server/tests/round2_api_tests.rs | Update API startup helper. |
| crates/metadb-server/tests/rename_concurrency_regressions.rs | Update rename-concurrency fixture. |
| crates/metadb-server/tests/prefix_load.rs | Opt local load fixture into unauthenticated loopback. |
| crates/metadb-server/tests/join_existing_group.rs | Separate authenticated and unauthenticated join fixtures. |
| crates/metadb-server/tests/integration_tests.rs | Update integration configuration. |
| crates/metadb-server/tests/grpc_regressions.rs | Preserve explicit authentication modes in fixtures. |
| crates/metadb-server/tests/e2e_cluster_evolution_tests.rs | Update cluster-evolution configuration. |
| crates/metadb-server/tests/control_plane_claim_tests.rs | Update control-plane fixture. |
| crates/metadb-server/tests/backup_restore.rs | Update backup/restore configuration. |
| crates/metadb-server/tests/auth_fail_closed.rs | Cover startup refusal and explicit opt-in. |
| crates/metadb-server/src/stress.rs | Opt stress fixtures into unauthenticated loopback. |
| crates/metadb-server/src/metrics_http.rs | Reject whitespace-only metrics secrets. |
| crates/metadb-server/src/lib.rs | Classify secrets consistently in bearer interceptors. |
| crates/metadb-server/src/config.rs | Enforce explicit authentication configuration. |
| crates/metadb-raft/src/network.rs | Filter whitespace-only Raft credentials. |
Review effort: Balanced
| fn reject_unauthenticated_bind(addr: &str, secret: &str) -> Result<()> { | ||
| if !secret.trim().is_empty() || is_loopback_bind(addr) { | ||
| fn reject_unauthenticated_bind(addr: &str, security: &SecuritySection) -> Result<()> { | ||
| security.validate_for_startup()?; |
| Logs use `tracing-subscriber`'s `EnvFilter`. The default filter is `info`. Override it with the standard `RUST_LOG` variable, for example `RUST_LOG=debug`. | ||
|
|
||
| On startup with an empty `security.shared_secret`, the process logs a warning that loopback gRPC has no authentication. The default bind is `127.0.0.1`. A wildcard or other non-loopback address with an empty, missing, or misspelled secret refuses to listen. A non-empty `[security].shared_secret` requires the same bearer on metadata, transaction, control-plane, Raft transport, and `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the config fails startup instead of serving plaintext. Keep the listener on a trusted network, or put every service behind a proxy that authenticates clients and block direct access to this process. | ||
| An empty `security.shared_secret` does not start the process. The default bind is `127.0.0.1`, and loopback is not an implicit exception. Local development without credentials sets `allow_unauthenticated = true` and keeps every listener on loopback. A wildcard or other non-loopback address still refuses to listen. A whitespace-only secret is rejected. A non-empty `[security].shared_secret` requires the same bearer on metadata, transaction, control-plane, Raft transport, and `GET /metrics`. The process does not terminate TLS. A TLS, certificate, anonymous, or insecure key in the config fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates clients and block direct access to this process. |
An empty secret is allowed only with the loopback opt-in. A whitespace-only secret is rejected even then. The loopback launch examples now include that explicit setting instead of a credential-free default. Co-authored-by: RustFS <hello@rustfs.com>
8 of 12 tasks
Unauthenticated mode accepts only literal loopback IPs and rechecks the bound address, so localhost is not trusted. The saved-address regression opts in before asserting that refusal, and a separate test keeps the default empty-secret error. Security-sensitive key aliases fail closed. Co-authored-by: RustFS <hello@rustfs.com>
3 tasks
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
Follow-up to merged #13. This does not change that pull request's branch. Base is current
mainat36d8e950. Open pull requests #27–#33 are documentation or status wording and do not cover this authentication change.This process still does not terminate TLS, and this pull request does not add mutual TLS or RBAC. Product security review is still pending.
What the code on
mainactually did, and what changes:shared_secretstarted every loopback listener with no credentials. That is no longer the default. Startup refuses unless the operator sets a secret that contains a non-whitespace character, or sets[security].allow_unauthenticated = true.allow_unauthenticatedaccepts only literal loopback IPs (127.0.0.0/8or::1). The hostnamelocalhostis not accepted and is not resolved, so a hosts-file mapping cannot widen it. The process binds that same literal address and checks the bound IP again. A wildcard or other address still refuses to listen. Setting the flag together with a usable secret is rejected. Compatibility: an opted-in config that used the namelocalhostno longer starts. A usable secret may still bind a hostname.secret,password,passwd,token,credential,auth,anonymous,anon,insecure,api_key,apikey,bearer,jwt,private_key,privatekey,encryption,encrypt,tls,ssl,cert,x509,mtls,cipher,keystore,https,ca_file, orcafile, or starts withsecur, including inside nested tables and arrays. The only exceptions are the direct keys[security].shared_secretand[security].allow_unauthenticated. Other unknown keys, includingbloom_bits_per_keyand a misspelled listen or storage key, are still ignored.Compatibility: a deployment that already sets a non-empty
shared_secretand does not setallow_unauthenticatedkeeps the same bearer requirement. A deployment that relied on an empty secret plus loopback, includingmetadbdwith no security section, no longer starts until one of those two settings is chosen.English operator docs describe these rules. Non-English locale reconciliation is left to the docs author of #36.
classify_secretandSecuritySection::validate_for_startupstay in place for #38 to integrate against. This pull request does not change that author's operability work.Tests
cargo check -p metadb-server --teststypechecked the latest commit. The tests below were not executed. No workspace test suite was run, and CI was not waited on.empty_secret_on_loopback_does_not_listenwhitespace_secret_on_loopback_does_not_listenexplicit_unauthenticated_loopback_serves_without_credentialssecurity_sensitive_aliases_fail_closed_and_storage_keys_do_not(includesapi_key,bearer,jwt,private_key,ca_file,encryption,anon, andbloom_bits_per_key)loopback_whitespace_secret_does_not_startpersisted_non_loopback_advertise_without_secret_fails_closednow setsallow_unauthenticatedso the saved0.0.0.0address is the refusal under testdefault_empty_secret_is_rejected_before_any_listenerkeeps the separatenot an implicit exceptionassertionExisting in-process tests that start a loopback node without a secret set
allow_unauthenticated = trueand bind127.0.0.1. Tests that set a real secret leave that flag false.Limitations
127.0.0.0/8and::1are accepted. IPv4-mapped IPv6 addresses are not treated as loopback.DistributedTxRouter::with_forward_secretstill stores the string it is given. Startup does not pass a whitespace-only secret into it. That helper was not otherwise changed.a48d038.