Repository navigation
fix: cap manifest fetches, clamp outboard reads, and small hardening - #2872
Conversation
- client: a bundle pull's manifest fetch runs under min(run cap, MAX_MANIFEST_BYTES), so a blob URI with a trailing `/` pays for at most 64 MiB. The constant lives in decdn-client; the CLI and gateway re-use it (#2847). - cache: an origin size claim past max_blob_bytes reads no .obao4 outboard (#2842). - cache: a filesystem origin whose base directory vanished answers Permanent, not a per-hash absence (#2823). - cli: `decdn config init` writes node.toml 0600 and creates its directory 0700 (#2851). - node: the metrics server sets hyper's timer, a 10 s header read timeout and a 60 s connection lifetime (#2851). - client: reserved pull-state names (.decdn-partial, .decdn-manifest.json, .decdn-bundles) compare by path_key (#2851). - sponsord-onramp: every response sends frame-ancestors 'none' and X-Frame-Options: DENY (#2772). - ci: a free-disk-space action that reclaims space only when / has less than 90 GB free, on the coverage, anvil e2e and SDK contract jobs (#2828). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gas snapshotNo gas changes vs base. |
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 9 most impacted files.
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A critical issue remains in crates/node/src/metrics/tests.rs where a tokio test starts with paused time but never advances the clock, preventing timeout futures from firing and potentially causing an indefinite hang in the client read loop.
1 open issue
What changed in this PR
Hardening updates across client bundle pulling, cache/origin handling, node metrics serving, onramp HTTP responses, and CI reliability based on the 2026-11-05 security review.
Changes:
- Cap manifest fetches to
min(run cap, MAX_MANIFEST_BYTES)and expose/re-export the manifest cap constants for shared use. - Clamp outboard reads when origin size claims exceed the blob cap and improve filesystem-origin behavior when the base path disappears.
- Add metrics server timeouts/lifetime bounds, forbid framing on all onramp responses, enforce private config file modes, and add conditional CI disk-space reclamation.
| File | Description |
|---|---|
| crates/sponsord-onramp/tests/http_contract.rs | Adds an HTTP contract test asserting anti-framing headers are present on all responses (including 404s). |
| crates/sponsord-onramp/src/http/mod.rs | Applies response middleware to set Content-Security-Policy: frame-ancestors 'none' and X-Frame-Options: DENY on every response. |
| crates/node/src/metrics/tests.rs | Adds a test covering closure of silent/idle metrics connections under the configured timeouts. |
| crates/node/src/metrics.rs | Hardens the metrics HTTP/1 server by configuring a timer, header read timeout, and per-connection lifetime bounds. |
| crates/client/tests/snapshots/public_api__public_api.snap | Updates the public API snapshot to include newly exported manifest cap constants. |
| crates/client/src/bundle/engine/tests.rs | Adds tests for manifest cap behavior and for reserving pull-state paths using normalized/case-aware keys. |
| crates/client/src/bundle/engine.rs | Implements manifest fetch capping and updates reserved pull-state path checks to use path_key for consistent matching. |
| crates/client/src/bundle.rs | Exposes MAX_MANIFEST_BYTES and MAX_MANIFEST_MB from decdn_client::bundle for downstream reuse. |
| crates/cli/src/commands/fetch.rs | Re-exports the client manifest cap constants so CLI and gateway share the same limits. |
| crates/cli/src/commands/config/tests.rs | Adds unix-only tests asserting config init creates private directories (0700) and writes config files as owner-only (0600), including overwrite behavior. |
| crates/cli/src/commands/config.rs | Writes node.toml via a helper that enforces owner-only permissions (and private created directories on unix). |
| crates/cache/src/origin/fs/tests.rs | Adds a regression test ensuring a vanished filesystem-origin base is surfaced as a permanent error rather than silent absence. |
| crates/cache/src/origin/fs.rs | Adjusts filesystem-origin resolution to distinguish missing content from a missing base path by treating a vanished base as a permanent fault. |
| crates/cache/src/engine/tests.rs | Adds a test ensuring oversized origin size claims do not trigger outboard reads. |
| crates/cache/src/engine.rs | Clamps outboard handling by returning Ok(None) when an origin’s total_bytes exceeds max_blob_bytes before any outboard read is attempted. |
| .github/workflows/sdk-contract.yml | Integrates the conditional free-disk-space action into SDK contract workflow jobs. |
| .github/workflows/ci.yml | Integrates the conditional free-disk-space action into coverage, anvil e2e, and related CI jobs to reduce ENOSPC risk. |
| .github/actions/free-disk-space/action.yml | Adds a composite action that conditionally reclaims disk space only when / free space falls below a threshold. |
Review effort: Balanced
…ch on a capped manifest - free-disk-space: the 145 GB runner reports 86 GB free, so the default threshold is 80 GB and the reclaim is skipped there. - A bundle manifest fetch that ends on the manifest cap says the blob is larger than a manifest can be and to drop the trailing path, as the `-o -` path does. - Doc comments state what the caps and checks do: a manifest fetch pays for at most the cap, the fs origin's base check covers a deleted base and a base below an unmounted mount point, and the metrics connection lifetime bounds slow readers. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Kpvr4Hsh3j4uw3sPiHpYkv
|
After #2885 merged (a6405f5), the #2842 hunk here may be redundant: on main the serve path verifies size_proof(hash, total) before origin_range_serviceable runs (crates/node/src/handlers/client/dispatch.rs:1155), so outboard_with_origin's read cap already derives from a proven size, not the origin's raw claim. Worth re-checking on rebase whether the outboard_with_origin clamp still has a caller it protects — the rest of the PR is unaffected. |

Small hardening fixes from the 2026-11-05 security review, in one PR.
Fixes
PullCtx::fetch_to_memoryruns the manifest fetch undermin(run cap, MAX_MANIFEST_BYTES)(64 MiB; a run with no cap takes 64 MiB). The lanes then refuse a larger size claim, and the driver stops before it pays past the cap (BlobTooLarge).MAX_MANIFEST_BYTES/MAX_MANIFEST_MBmove intodecdn_client::bundle. The CLI'sfetch.rsre-exports them, sodecdn get … -o -and the gateway use the same constant. The public_api snapshot gains the two consts.outboard_with_originreturnsOk(None)when the origin'stotal_bytesexceedsmax_blob_bytes, before it derives the outboard read cap or asks any origin.FilesystemOrigin::resolve_regular'sNotFoundarm, when no dangling link explains it, a stat ofself.basethat saysNotFoundreturnsPermanent("cache.origin.path base … no longer exists").config initfile mode:node.tomlis written 0600, and the overwritten file under--forceis reset to 0600 too. Directories created for it are 0700 (unix)..timer(TokioTimer)and a 10 sheader_read_timeout. Each connection also gets a 60 s lifetime bound, so idle keep-alive peers release their permit. The Host check is not included. The admin listener has no reusable loopback Host check to share, and the metrics server can bind non-loopback on purpose, so this needs its own decision..decdn-partial,.decdn-manifest.jsonand.decdn-bundlesnow compare bypath_key(the first component under the output root), at all three sites.Content-Security-Policy: frame-ancestors 'none'andX-Frame-Options: DENY. This usesaxum::middleware::map_response, so it adds no new dependency and leaves the crate-edge table unchanged.testjob runs out of disk on 72 GB hosted runners #2828). There is a new composite action,.github/actions/free-disk-space, with the step ci: drop the free-disk-space steps #2652 removed. It reclaims space only whendfshows less than 90 GB free on/. It is wired into the coveragetestjob, the three anvil e2e jobs, and both SDK contract jobs.Testing
cargo fmt -- --check: cleancargo clippy --workspace --all-targets --all-features -- -D warnings: cleancargo nextest run --no-fail-fast -p decdn-client -p decdn-cache -p decdn-cli -p decdn-node -p sponsord-onramp: 5040 passed. In the first fail-fast run,node_origin_pull::a_slow_post_topup_delivery_scores_slow_not_instantfailed under load. It passed alone and in the full rerun.CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: cleanINSTA_UPDATE=always cargo nextest run -p decdn-client --features public-api-test --test public_api: the snapshot is updated (+2 consts)pre-commit(commit hooks,workflow-hardening,check-yaml): passNew tests:
bundle::engine::tests::a_manifest_fetch_runs_under_the_manifest_capchecks the cap helper. The refusal at the cap itself is the driver's existingBlobTooLargepath, which existing driver tests cover. There is no end-to-end PullCtx harness for a paid over-cap manifest.cache engine::tests::an_origin_size_past_the_blob_cap_reads_no_outboardorigin::fs::tests::a_vanished_base_is_permanent_not_absentcommands::config::tests::config_file_is_written_owner_onlymetrics::tests::a_silent_metrics_connection_is_closedbundle::engine::tests::writable_dest_reserves_every_case_of_the_pull_state_namessponsord-onramp http_contract::every_response_forbids_framingThe CI action can only be checked on hosted runners.
🤖 Generated with Claude Code