Skip to content

harden ember-server: grpc limits, scan cap, gossip port overflow - #133

Merged
kacy merged 2 commits into
mainfrom
security/server-hardening
Feb 14, 2026
Merged

harden ember-server: grpc limits, scan cap, gossip port overflow#133
kacy merged 2 commits into
mainfrom
security/server-hardening

Conversation

@kacy

@kacy kacy commented Feb 14, 2026

Copy link
Copy Markdown
Owner

summary

security hardening for ember-server, addressing findings #4, #7, #9, #12 from the security audit.

  • clippy result_large_err: added #[allow(clippy::result_large_err)] on validate_key and validate_value with justification — tonic's Status is the idiomatic error type
  • grpc message size limits: set explicit 4 MB max decoding/encoding message size on the grpc service (tonic defaults to 4 MB but we now state it explicitly)
  • SCAN count cap: req.count is now capped at 10,000 to prevent a client from requesting unbounded iteration
  • gossip port overflow: replaced saturating_add with checked_add at both gossip port calculation sites — prevents silent port collision when offset overflows u16
  • cargo fmt: fixed formatting drift from recently merged refactoring PRs

what was tested

  • cargo build --workspace --features protobuf,grpc,vector — clean
  • cargo test -p ember-server --features protobuf,grpc,vector — 43/43 pass
  • cargo clippy --workspace --features protobuf,grpc,vector -- -D warnings — clean
  • cargo fmt --all --check — clean

design considerations

  • result_large_err is suppressed rather than fixed because boxing tonic::Status would add allocation overhead on every validation call for no practical benefit. the lint exists for types that are unexpectedly large; 176 bytes for an error type in a non-hot-path is fine.
  • SCAN count is silently capped (not rejected) to match redis behavior — redis also clamps count internally.
  • gossip port uses expect() in the constructor (startup) since an invalid port config is a fatal error, and checked_add + early return in spawn_gossip() since that runs after initialization.

@kacy
kacy force-pushed the security/server-hardening branch from dca1046 to c87dad8 Compare February 14, 2026 22:51
kacy added 2 commits February 14, 2026 17:52
- suppress clippy result_large_err on validate_key/validate_value
  (tonic Status is the idiomatic error type, 176 bytes is acceptable)
- cap SCAN count at 10,000 to prevent huge allocations
- set explicit 4 MB max message size on grpc service
- replace saturating_add with checked_add for gossip port calculation
  (prevents silent port collision on overflow)
@kacy
kacy force-pushed the security/server-hardening branch from c87dad8 to 6e3bb67 Compare February 14, 2026 22:53
@kacy
kacy merged commit c4d9377 into main Feb 14, 2026
7 checks passed
@kacy
kacy deleted the security/server-hardening branch February 14, 2026 22:55
kacy added a commit that referenced this pull request Feb 19, 2026
* cargo fmt: fix formatting drift from merged refactoring PRs

* harden grpc and cluster inputs

- suppress clippy result_large_err on validate_key/validate_value
  (tonic Status is the idiomatic error type, 176 bytes is acceptable)
- cap SCAN count at 10,000 to prevent huge allocations
- set explicit 4 MB max message size on grpc service
- replace saturating_add with checked_add for gossip port calculation
  (prevents silent port collision on overflow)
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