fix(#38): add admin auth to set_government_vault and set_tax_rate - #42
Open
leanworld7-netizen wants to merge 1 commit into
Open
fix(#38): add admin auth to set_government_vault and set_tax_rate#42leanworld7-netizen wants to merge 1 commit into
leanworld7-netizen wants to merge 1 commit into
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.
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.
Fix for #38: Unauthenticated redirection of settlement payouts
Vulnerability
set_government_vaultcalledrequire_auth()on the caller-suppliedvault_address, allowing anyone to self-authorize as the government vaultset_tax_ratehad no authorization check with a comment saying "Should be admin-only in production"DataKey::GovernmentVaultandDataKey::TaxRateBpsare instance-level storage consulted by every settlementFix
Both functions now require an
admin: Addressparameter that is:admin.require_auth()DataKey::CurrentAdminThis follows the same pattern used by other admin-gated functions in the contract. The fix prevents unauthenticated takeover of settlement payouts.
Changes
set_government_vault(env, vault_address)→set_government_vault(env, admin, vault_address)set_tax_rate(env, tax_rate_bps)→set_tax_rate(env, admin, tax_rate_bps)admin == stored CurrentAdminbefore proceedingTesting
The fix is backwards-compatible with existing admin flows. Any caller attempting to set the government vault or tax rate without being the admin will now get
ContractError::Unauthorized.Closes #38