Skip to content

fix(#38): add admin auth to set_government_vault and set_tax_rate - #42

Open
leanworld7-netizen wants to merge 1 commit into
EquipChain:mainfrom
leanworld7-netizen:fix/settlement-auth-38
Open

fix(#38): add admin auth to set_government_vault and set_tax_rate#42
leanworld7-netizen wants to merge 1 commit into
EquipChain:mainfrom
leanworld7-netizen:fix/settlement-auth-38

Conversation

@leanworld7-netizen

Copy link
Copy Markdown

Fix for #38: Unauthenticated redirection of settlement payouts

Vulnerability

  • 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 authorization check with a comment saying "Should be admin-only in production"
  • Both functions control global settlement state — DataKey::GovernmentVault and DataKey::TaxRateBps are instance-level storage consulted by every settlement

Fix

Both functions now require an admin: Address parameter that is:

  1. Authenticated via admin.require_auth()
  2. Verified against the stored DataKey::CurrentAdmin

This 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)
  • Both now check admin == stored CurrentAdmin before proceeding

Testing

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

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Critical: unauthenticated redirection of all settlement payouts in utility_contracts (PoC included)

1 participant