fix: add admin auth to set_legal_vault and collect_streaming_fees (siblings of #38) - #43
Open
leanworld7-netizen wants to merge 2 commits into
Open
Conversation
…x_rate set_government_vault called require_auth() on the caller-supplied vault_address, allowing anyone to self-authorize as the government vault. set_tax_rate had no auth at all with a comment saying 'Should be admin-only in production'. Both functions now require an admin: Address parameter that is: 1. Authenticated via require_auth() 2. Verified against the stored CurrentAdmin This prevents unauthenticated takeover of settlement payouts.
set_legal_vault: had vault.require_auth() on caller-supplied vault address (same self-authorizing bug as EquipChain#38). Now requires admin verified against DataKey::CurrentAdmin. collect_streaming_fees: had NO auth at all. Anyone could call it to zero out accrued streaming fees for any stream, preventing the protocol fee vault from collecting. Now requires admin auth.
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.
Security Fix: Sibling vulnerabilities to #38
Vulnerability 1:
set_legal_vaultself-authorizing (CRITICAL)Same pattern as #38 —
vault.require_auth()was called on the caller-supplied vault address, allowing anyone to self-authorize as the legal vault.Impact: The legal vault address is used in
legal_freezeandrelease_legal_freezefor fund transfers. An attacker setting themselves as the legal vault could intercept or block legal freeze releases.Vulnerability 2:
collect_streaming_feesno auth (MEDIUM)collect_streaming_feeshad zero authentication. Anyone could call it to reset theStreamingFeeAccruedcounter to 0 for any stream, preventing the protocol fee vault from ever collecting accrued fees.Impact: Griefing/DoS — streaming fee accruals can be wiped by any caller before the vault collects them.
Fix
Both functions now require an
admin: Addressparameter verified againstDataKey::CurrentAdmin:set_legal_vault(env, vault)→set_legal_vault(env, admin, vault)collect_streaming_fees(env, stream_id)→collect_streaming_fees(env, admin, stream_id)This follows the same pattern used by nearby admin-gated functions (L6597, L6671, L8220).
Relationship to #38
These are sibling bugs to the
set_government_vault/set_tax_ratevulnerabilities reported in #38. The same self-authorizing pattern was used inset_legal_vault, andcollect_streaming_feeshad no auth at all.