Security: fix medium-severity vulnerabilities (v0.11.7) - #39
Merged
Conversation
Address the nine Medium findings from the security audit. - Protected mode: new --protected-mode (default on) refuses non-loopback clients when no requirepass/ACL password is configured. - ACL keys: check every key argument of a command (MGET/MSET/DEL/RENAME/ ...) via a per-command key spec, instead of only args[1]; non-key commands (PUBLISH/SELECT/...) are no longer mis-treated as keyed. - AUTH backoff: track failures per peer IP in shared state so the exponential backoff survives reconnects; decays after an idle window. - SUBSCRIBE/PSUBSCRIBE: reject a zero-channel call instead of panicking on a usize underflow. - Persistence files: atomic write via O_EXCL temp files with randomized names (defeats symlink TOCTOU) and 0600 permissions on Unix. - RDB: refuse to load on CRC64 mismatch instead of warning and trusting the data. - Scripts: block non-deterministic commands (RANDOMKEY/TIME/SRANDMEMBER/ scan family/...) to keep script effects deterministic. - XADD: saturating sequence increment (no overflow panic); GETRANGE: explicit empty-value guard. Adds regression tests for command key extraction.
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.
Fixes the nine Medium findings from the security audit. Version bumped to 0.11.7.
cargo checkis clean (no warnings); 85 unit tests + all integration tests pass except the two pubsub integration tests in the untracked WIPtests/dir that fail identically onmain(pre-existing, unrelated).Findings addressed
15. Insecure defaults / no protected mode. New
--protected-modeflag (default on). When enabled and norequirepass/ACL password is configured, non-loopback clients are refused (RESP-DENIEDon the plain listener, drop on TLS). Operators binding publicly without auth must set a password or--protected-mode no.16. Key-pattern ACL only checked
args[1]. Added a per-command key spec (command_keys) so all key arguments are checked: multi-key commands (MGET/MSET/DEL/EXISTS/RENAME/SMOVE/…) are fully covered, and non-key commands (PUBLISH/SELECT/SCAN/…) are no longer mis-treated as keyed. Applied on both the RESP and HTTP command paths.17. AUTH backoff was per-connection (reset by reconnecting). Failures are now tracked per peer IP in shared state, so the exponential backoff survives reconnects and can't be parallelized away; the counter decays after a 60 s idle window and clears on success.
18.
SUBSCRIBE/PSUBSCRIBEzero-channelusizeunderflow panic. These are intercepted before the registry arity check; added an explicit empty-argument guard.19. Predictable temp filenames / symlink TOCTOU. RDB/AOF (and BGREWRITEAOF) now write through a shared helper that creates temp files with
O_EXCL(create_new) and a randomized suffix, so a pre-created symlink can't be followed, then atomically renames.20. Dump/AOF world-readable. Persistence files are created with
0600on Unix.21. RDB CRC64 mismatch ignored. A checksum mismatch now fails the load (returns an error) instead of logging a warning and trusting the data; a stored CRC of 0 still means "checksum disabled".
22. Non-deterministic commands in scripts. Blocked
RANDOMKEY/TIME/SRANDMEMBER/ZRANDMEMBER/HRANDFIELDand theSCANfamily inside scripts to keep script effects deterministic (matches Redis's historical requirement).23.
XADDsequence overflow +GETRANGEunderflow.XADDusessaturating_addfor the auto-sequence (exhausted IDs are then rejected by validation rather than panicking);GETRANGEhas an explicit empty-value guard.Notes / residuals
EVALis not logged to the AOF as a write command and script effects aren't replicated verbatim, so the divergence risk is currently latent; the block is defensive/forward-looking. The proper long-term fix is effects-based replication of script writes.ACL LOGremains a stub (returns[]); making it functional is a feature, not included here.args[1]as the key (conservative). Channel-level ACLs for pub/sub are still not enforced (separate Low finding).--bind; operators intentionally exposing an unauthenticated instance must opt out.Adds a
command_keysunit test. Low findings remain out of scope.