Skip to content

harden: grpc input validation, ttl overflow, cursor truncation - #126

Merged
kacy merged 1 commit into
mainfrom
security/ember-server
Feb 14, 2026
Merged

harden: grpc input validation, ttl overflow, cursor truncation#126
kacy merged 1 commit into
mainfrom
security/ember-server

Conversation

@kacy

@kacy kacy commented Feb 14, 2026

Copy link
Copy Markdown
Owner

summary

adds input validation to grpc handlers and fixes two numeric edge cases.

input validation

  • validate_key() rejects empty keys and keys over 512KB
  • validate_value() rejects values over 512MB
  • applied to: GET, SET, DEL, MGET, MSET
  • vector handlers additionally validate: dimensions ≤ 65,536, vsim count
    ≤ 10,000, hnsw M ≤ 1,024, ef_construction ≤ 1,024

ttl overflow (S5)

  • PTTL handler converted seconds to millis with s * 1000, which wraps
    on large TTLs. changed to s.saturating_mul(1000).

cursor truncation (S6)

  • scan cursor decoded shard index via req.cursor as usize which truncates
    on 32-bit platforms. moved the modulo arithmetic into u64 space so the
    conversion to usize only happens on the (small) shard index result.

what was tested

all 43 ember-server tests pass. also checked clean compile with the
vector feature enabled (--features protobuf,grpc,vector).

design considerations

validation limits are deliberately generous — they protect against
obviously malformed requests (e.g. multi-gigabyte keys from a fuzzer)
without restricting any realistic workload. the constants live at module
scope next to the existing helper functions.

- add validate_key() and validate_value() helpers with size limits
  (512KB keys, 512MB values) applied to GET, SET, DEL, MGET, MSET
- add vector-specific limits: dimensions (65K), vsim count (10K),
  hnsw connectivity and ef_construction (1K each) applied to VADD, VSIM
- fix TTL overflow: s * 1000 -> s.saturating_mul(1000) in PTTL handler
- fix scan cursor truncation on 32-bit: keep modulo arithmetic in u64
  space before converting shard index to usize
@kacy
kacy force-pushed the security/ember-server branch from 1741b71 to 8353590 Compare February 14, 2026 21:51
@kacy
kacy merged commit 94b3cef into main Feb 14, 2026
6 of 7 checks passed
@kacy
kacy deleted the security/ember-server branch February 14, 2026 21:52
kacy added a commit that referenced this pull request Feb 19, 2026
- add validate_key() and validate_value() helpers with size limits
  (512KB keys, 512MB values) applied to GET, SET, DEL, MGET, MSET
- add vector-specific limits: dimensions (65K), vsim count (10K),
  hnsw connectivity and ef_construction (1K each) applied to VADD, VSIM
- fix TTL overflow: s * 1000 -> s.saturating_mul(1000) in PTTL handler
- fix scan cursor truncation on 32-bit: keep modulo arithmetic in u64
  space before converting shard index to usize
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