fix(channels): clamp negative or non-finite Retry-After before Duration conversion#6516
Merged
Conversation
…on conversion f64::min only guards against NaN, not negative values, so a malicious or misbehaving upstream 429 response with a negative or non-finite Retry-After header/body value reached Duration::from_secs_f64 unclamped and panicked the shared dispatch path used by Discord, Slack, and Telegram alike. Closes #6496
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.
Summary
send_with_retryincrates/zeph-channels/src/common/http_retry.rscomputed the 429 backoff delay viaheader_secs.or(body_secs).unwrap_or(1.0).min(MAX_RETRY_SECS).f64::minonly guards againstNaN, not negative values, so a negative or non-finiteRetry-Afterheader/body value from a compromised or misbehaving upstream host reachedDuration::from_secs_f64, which panics on such input — crashing the shared dispatch path used by Discord, Slack, and Telegram alike.valid_retry_secs, which discards negative/non-finite values from either source, treating them the same as an unparseable value (falls through header -> body -> 1s default).Test plan
cargo +nightly fmt --check -p zeph-channelscargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins -E 'package(zeph-channels)'(301 passed)gitleaks protect --staged --no-banner --redactCloses #6496