Skip to content

Security: fix medium-severity vulnerabilities (v0.11.7) - #39

Merged
mack42 merged 1 commit into
mainfrom
security/medium-fixes-0.11.7
Jul 16, 2026
Merged

Security: fix medium-severity vulnerabilities (v0.11.7)#39
mack42 merged 1 commit into
mainfrom
security/medium-fixes-0.11.7

Conversation

@mack42

@mack42 mack42 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Fixes the nine Medium findings from the security audit. Version bumped to 0.11.7. cargo check is clean (no warnings); 85 unit tests + all integration tests pass except the two pubsub integration tests in the untracked WIP tests/ dir that fail identically on main (pre-existing, unrelated).

Findings addressed

15. Insecure defaults / no protected mode. New --protected-mode flag (default on). When enabled and no requirepass/ACL password is configured, non-loopback clients are refused (RESP -DENIED on 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/PSUBSCRIBE zero-channel usize underflow 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 0600 on 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/HRANDFIELD and the SCAN family inside scripts to keep script effects deterministic (matches Redis's historical requirement).

23. XADD sequence overflow + GETRANGE underflow. XADD uses saturating_add for the auto-sequence (exhausted IDs are then rejected by validation rather than panicking); GETRANGE has an explicit empty-value guard.

Notes / residuals

  • B8: Built-in rate limiting primitives #22: in this codebase EVAL is 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.
  • B3: Time series data type #17: ACL LOG remains a stub (returns []); making it functional is a feature, not included here.
  • B2: Probabilistic data structures #16: the key spec covers common commands; unmapped commands default to treating args[1] as the key (conservative). Channel-level ACLs for pub/sub are still not enforced (separate Low finding).
  • Protected mode triggers on any non-loopback peer when no auth is set, regardless of an explicit --bind; operators intentionally exposing an unauthenticated instance must opt out.

Adds a command_keys unit test. Low findings remain out of scope.

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.
@mack42 mack42 self-assigned this Jul 16, 2026
@mack42
mack42 merged commit a4e9ac7 into main Jul 16, 2026
1 check failed
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