Uh oh!
There was an error while loading. Please reload this page.
fix(dig-node): budget the proxy-fetch leg separately from cheap miss-lookups (#2189) - #190
Merged
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
…lookups (#2189) The per-requestor miss budget (16 burst / 4-per-sec) is sized for a cheap DHT lookup, but a proxy:true miss triggers a full multi-source capsule fetch (large egress + crypto). Add a separate, tighter per-requestor TokenBucket for the proxy leg (4 burst / 1-per-sec) so proxy egress cannot be drained under the lookup budget. Fail-closed: an exhausted proxy allowance degrades to the redirect, never an unbounded fetch. The trusted operator (Local) is exempt. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…(#2189) Co-Authored-By: Claude <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Closes DIG-Network/dig_ecosystem#2189. DoS defense-in-depth (loop-security non-gating finding on PR #182).
The problem
The per-requestor miss budget (16 burst / 4-per-sec) is sized for a cheap DHT lookup, but a
proxy:truemiss triggers a full multi-source capsule fetch (large egress + crypto). A requestor could draw expensive proxy fetches from the budget calibrated for cheap lookups, converting cheap-lookup allowance into egress.Fix
The proxy fetch-through leg gets its own, tighter, independent per-requestor allowance — a separate
MissRateLimiter(proxy_rate_limiter,download.rs), not the shared lookup budget:DEFAULT_PROXY_FETCH_BURST = 4.0andDEFAULT_PROXY_FETCH_REFILL_PER_SEC = 1.0(rate_limit.rs) — a quarter of the cheap-lookup burst/refill, calibrated against the per-fetch egress + CPU of a full multi-source capsule pull. A legitimate NAT-blocked reader proxying a handful of resources is absorbed; sustained proxy spam is throttled independently.proxy:truemisses degrade to the normal redirect outcome — never an unbounded fetch. The cheap-lookup budget is untouched by proxy spend.const{}-style calibration test pinsDEFAULT_PROXY_FETCH_BURST < DEFAULT_MISS_LOOKUP_BURST, so a future loosening that erased the separation reds the build.Test (the acceptance)
proxy_fetch_is_bounded_by_its_own_allowance_independent_of_lookups(lib.rs): a generous cheap-lookup budget (100) + a tiny proxy allowance (1, no refill), interleaved with lookup-only calls. It asserts the secondproxy:truemiss is redirected (proxy allowance exhausted) while the lookup budget is provably untouched — a regression that drew the proxy fetch from the shared lookup budget would serve the second proxy call (100 lookup tokens available) and red the assertion. Non-vacuous by construction.Blast radius
crates/dig-node-core/src/rate_limit.rs(new proxy-default constants +with_proxy_defaults()),crates/dig-node-core/src/download.rs(the separateproxy_rate_limiterwired intomiss_outcome, fail-closed degrade),crates/dig-node-core/src/lib.rs(the regression test + a test-onlyset_proxy_rate_limit). The cheap-lookup miss path (#2007) is unchanged.Version
root
[workspace.package].version0.99.5 → 0.99.6 (patch,fix:— a rate-limit tightening, no wire/API change).Cargo.lockregenerated. Refs #2007.Generated by Claude Code