runtime: charge quota before guard check on submit#435
Open
mfw78 wants to merge 2 commits into
Open
Conversation
The submission charge moves ahead of the guard verdict at the venue registry, so a denied egress spends one unit exactly as an accepted submit does: a module spamming denied egress exhausts its own budget instead of looping free once the guard turns enforcing. A regression test pins the rate limit on a repeated-deny loop.
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 free
to 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.
What
Move the quota charge in
VenueRegistry::submitfrom after the guard check to before it.Why
The guard is advisory-only today, so a deny always falls through and gets charged regardless of order. But once a guard enforces a deny, charging after the check means a denied caller pays nothing and can retry forever: a free busy-loop DoS against the guard and router. Charging before the check closes that gap ahead of time.
Testing
repeated_guard_denies_exhaust_the_caller_quota: with a 2-unit quota and a denying guard, the first two submits are charged and admitted, the third isRateLimited, proving a deny loop cannot outrun the quota.cargo test --doc(rustdoc reflects the new charge order).AI Assistance
Implemented and tested with Claude Code assistance.
Closes #364