Skip to content

fix: cap manifest fetches, clamp outboard reads, and small hardening - #2872

Merged
alpergundogdu merged 3 commits into
mainfrom
fix/small-hardening-batch
Nov 16, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
fix/small-hardening-batch

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Small hardening fixes from the 2026-11-05 security review, in one PR.

Fixes

Testing

  • cargo fmt -- --check: clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings: clean
  • cargo 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_instant failed under load. It passed alone and in the full rerun.
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: clean
  • INSTA_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): pass

New tests:

  • bundle::engine::tests::a_manifest_fetch_runs_under_the_manifest_cap checks the cap helper. The refusal at the cap itself is the driver's existing BlobTooLarge path, 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_outboard
  • origin::fs::tests::a_vanished_base_is_permanent_not_absent
  • commands::config::tests::config_file_is_written_owner_only
  • metrics::tests::a_silent_metrics_connection_is_closed
  • bundle::engine::tests::writable_dest_reserves_every_case_of_the_pull_state_names
  • sponsord-onramp http_contract::every_response_forbids_framing

The CI action can only be checked on hosted runners.

🤖 Generated with Claude Code

- 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]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:09
@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-code-quality

github-code-quality Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main a6405f5 fix/small-hardening-... 610dbc9 +/-
77% 77% 0%
View coverage of the 9 most impacted files.
File main a6405f5 fix/small-hardening-... 610dbc9 +/-
crates/client/src/lib.rs 90% 89% -1%
crates/client/s...undle/engine.rs 66% 65% -1%
crates/client/src/scheduler.rs 94% 94% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/cli/src/...mands/config.rs 84% 84% 0%
crates/node/src/metrics.rs 92% 92% 0%
crates/sponsord...src/http/mod.rs 100% 100% 0%
crates/node/src/dht/publish.rs 77% 78% +1%
crates/cache/src/origin/fs.rs 73% 74% +1%

Solidity / code-coverage/forge

main a6405f5 fix/small-hardening-... 610dbc9 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 13, 2026 19:43 UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread crates/node/src/metrics/tests.rs Resolved
alpergundogdu and others added 2 commits November 11, 2026 19:47
…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]>
@yigitdot

Copy link
Copy Markdown
Contributor

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.

@alpergundogdu
alpergundogdu merged commit fcbe2e0 into main Nov 16, 2026
38 checks passed
@alpergundogdu
alpergundogdu deleted the fix/small-hardening-batch branch November 16, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants