[Detail Bug] HTTP: Unbounded max_attempts override enables CPU DoS via C0-Config header
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with the ma parsing in src/service/routes.rs and how RequestConfig validates other C0-Config values; then check how src/object_store/config.rs applies max_attempts. Reject out-of-range values with the existing 400 response pattern and verify that zero and very large values are rejected while valid values still configure retries.
Written by the indexing model from the issue text.
Description
Detail Bug Report
Introduced in #3 by @shikhar on Sep 7, 2025
Summary
- Context: Cachey is a read-through HTTP cache for S3. The untrusted
C0-Configrequest header lets a client override the AWS S3 SDK's retry/timeout configuration for each cache miss; those values are merged into per-request SDK config overrides for every backendGetObjectcall. - Bug:
max_attempts(ma) is parsed fromC0-Configand passed toRetryConfig::with_max_attemptswith no upper (or lower) bound. A huge value drives an O(max_attempts) synchronous CPU loop inside the AWS SDK's identity-cache load-timeout computation on every S3 operation, before any network I/O — CPU work that none of the server's download deadlines can bound, because it runs inside a single non-preemptible future poll. - Actual vs. expected: A request like
C0-Config: ma=4294967295pins a server CPU core for ~3.7 minutes (release build) per backend operation. Expected: out-of-range values are rejected at parse time (every other malformedC0-Configvalue yields a 400) and the resulting SDK behavior stays within the server'sbucket_timeout/download_timeoutbounds as the README documents ("SDK overrides are bounded by the server's download deadlines"). - Impact: Trivial denial of service — a ~100-byte header value burns a full core for minutes per request while holding a download admission slot and a client connection; a number of concurrent requests equal to the tokio worker count stalls the entire service for all clients.
Code with Bug
src/service/routes.rs accepts any syntactically-valid u32 for ma:
"ma" => {
config.max_attempts = Some(value.parse().map_err(|_| {
(
StatusCode::BAD_REQUEST,
"Invalid value for ma in C0-Config header",
)
})?);
}
src/object_store/config.rs applies it without clamping:
if let Some(max_attempts) = self.max_attempts {
config = config.with_max_attempts(max_attempts); // <-- BUG 🔴 no clamp/range check; any u32 accepted
}
Explanation
- Because
mais unbounded, a client can set it to a huge value (e.g.u32::MAX). - The AWS SDK’s default identity cache (
aws-smithy-runtime) computes a pessimistic identity load timeout by summing an exponential backoff term in a loop from0..attempts-1. This loop is O(max_attempts) and runs synchronously during futurepoll, before any backend HTTP request. - Cachey’s own download/bucket deadlines use
select!/timeouts that only trigger between polls; a single poll that runs for minutes cannot be preempted. So the documented expectation that SDK overrides remain withinbucket_timeout/download_timeoutbounds does not hold for this input. - Measured cost of the loop in release:
ma=u32::MAXtakes ~219.6s (~3.7 min) per call.
Exploit Scenario
An attacker sends requests to any cachey endpoint with:
GET /fetch/some-kind/some-object HTTP/1.1
Range: bytes=0-15
C0-Config: ma=4294967295
Each request pins a tokio worker at 100% CPU for ~3.7 minutes before the first backend request. With roughly one concurrent request per core (tokio worker count), the async runtime is saturated and all endpoints (including health/metrics) stall.
Recommended Fix
Add semantic range validation for ma in the RequestConfig extractor and return 400 for out-of-range values (e.g., reject 0 and cap to a small maximum such as 16).
History
Introduced in commit 0a53101 ("feat: configurable timeouts & retries (#3)") when C0-Config/C0-Upstream was added: the parser accepted any u32 for ma and the retry config passed it directly to RetryConfig::with_max_attempts(...) without validation.
- Dominant language
- Rust
- Stars
- 622
- Forks
- 18
- Avg merge
- 5h 2m
- Merged PRs (30d)
- 33
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from s2-streamstore/cachey
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
s2-streamstore/cachey#224 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
s2-streamstore/cachey#223 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 71/100
s2-streamstore/cachey#222 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
s2-streamstore/cachey#217 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 15/100
s2-streamstore/cachey#6 · 2 comments ·
Maintainers usually reply within 1 day
All issues in s2-streamstore/cachey
Similar issues
-
<input type="number"> misses text-entry leaf sizing in layoutPossibly taken @GoCoder7 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
DioxusLabs/blitz#1675 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
metasequoiaime/msime#11666 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
bug drawings help wanted ui
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
userFRM/egui-charts#3479 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spellshift/realm#2509 ·
Maintainers usually reply within 1 day