Skip to content

fix(server): eliminate startup panics and add pub/sub pattern length cap - #179

Merged
kacy merged 2 commits into
mainfrom
audit/server-security
Feb 18, 2026
Merged

fix(server): eliminate startup panics and add pub/sub pattern length cap#179
kacy merged 2 commits into
mainfrom
audit/server-security

Conversation

@kacy

@kacy kacy commented Feb 18, 2026

Copy link
Copy Markdown
Owner

summary

three security fixes in ember-server found during the pre-merge audit:

  1. port overflow panicClusterCoordinator::new and from_config both called .expect() on a checked_add for the gossip port, which would panic at startup if the port offset caused a u16 overflow. both now return Result so callers can handle the error with exit_err.

  2. pub/sub pattern length cappsubscribe now returns Option<Receiver> and rejects patterns longer than 512 bytes. the connection handler already had a 256-byte check; this adds defense-in-depth at the API level so direct callers are also protected.

  3. PTTL millisecond overflows as i64 * 1000 in the concurrent handler would overflow for TTL values > ~9.2×10^15 seconds. fixed by multiplying within u64 and capping at i64::MAX before the cast.

also includes the workspace-wide cargo fmt + cargo clippy pass as the first commit.

what was tested

  • cargo clippy --workspace --all-features -- -D warnings clean
  • cargo test -p ember-server — 56 tests pass including:
    • cluster::tests::new_rejects_port_overflow (new)
    • pubsub::tests::psubscribe_rejects_oversized_pattern (new)
  • cargo test --workspace --lib — 337 unit tests pass

kacy added 2 commits February 18, 2026 08:41
…Result

ClusterCoordinator::new and from_config now return Err instead of
panicking when port + offset overflows u16. callers in main.rs use
exit_err as with all other startup errors.

also adds psubscribe pattern length cap (512 bytes) as defense in
depth behind the existing 256-byte check in the connection handler.
psubscribe now returns Option<Receiver> so invalid patterns are
rejected at the API level.

fixes ttl overflow in concurrent_handler pttl: multiply within u64
domain before casting to i64.
@kacy
kacy merged commit 2bef782 into main Feb 18, 2026
4 of 7 checks passed
@kacy
kacy deleted the audit/server-security branch February 18, 2026 14:37
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