Skip to content

fix(channels): clamp negative or non-finite Retry-After before Duration conversion#6516

Merged
bug-ops merged 1 commit into
mainfrom
fix/6496-retry-after-panic
Jul 19, 2026
Merged

fix(channels): clamp negative or non-finite Retry-After before Duration conversion#6516
bug-ops merged 1 commit into
mainfrom
fix/6496-retry-after-panic

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • send_with_retry in crates/zeph-channels/src/common/http_retry.rs computed the 429 backoff delay via header_secs.or(body_secs).unwrap_or(1.0).min(MAX_RETRY_SECS). f64::min only guards against NaN, not negative values, so a negative or non-finite Retry-After header/body value from a compromised or misbehaving upstream host reached Duration::from_secs_f64, which panics on such input — crashing the shared dispatch path used by Discord, Slack, and Telegram alike.
  • Added 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).
  • Added two wiremock regression tests reproducing the exact pre-fix panic scenario (negative header, negative body) plus a fast unit test covering NaN/+inf/-inf/negative/valid inputs for the filter itself.

Test plan

  • cargo +nightly fmt --check -p zeph-channels
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo 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 --redact

Closes #6496

…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
@github-actions github-actions Bot added documentation Improvements or additions to documentation channels zeph-channels crate (Telegram) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Jul 19, 2026
@bug-ops
bug-ops merged commit 37d2c6c into main Jul 19, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/6496-retry-after-panic branch July 19, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working channels zeph-channels crate (Telegram) documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Medium: negative or non-finite Retry-After value panics the shared HTTP retry helper for Discord/Slack/Telegram

1 participant