Skip to content

fix: prevent self-transfer from stripping Admin in transfer_authority - #509

Open
Joeljosef7 wants to merge 1 commit into
conduit-protocol:mainfrom
Joeljosef7:fix/issue-359-bug-dripgovernor-transfer-authority-with-new
Open

fix: prevent self-transfer from stripping Admin in transfer_authority#509
Joeljosef7 wants to merge 1 commit into
conduit-protocol:mainfrom
Joeljosef7:fix/issue-359-bug-dripgovernor-transfer-authority-with-new

Conversation

@Joeljosef7

Copy link
Copy Markdown

Overview

This PR fixes a privilege-loss bug in DripGovernor::transfer_authority (contracts/governor/src/lib.rs:302-313). When a caller transfers authority to themselves, the existing grant short-circuits as a no-op and the subsequent revoke removes the caller's own Admin role, decrementing AdminCount. The fix rejects new_authority == caller and is_zero_stellar_account(new_authority) with Error::InvalidParam before any role mutation, preserving AdminCount and the caller's Admin role on invalid input.

Related Issue

Changes

🛡️ Authority Transfer Guards

  • [MODIFY] contracts/governor/src/lib.rs
    • Add early guard in transfer_authority rejecting new_authority == caller with Error::InvalidParam before grant/revoke are called.
    • Add zero-address rejection via is_zero_stellar_account(new_authority) with Error::InvalidParam, consistent with the propose_authority guard from propose_authority accepts the zero address and silently overwrites a pending proposal #338.
    • Keep the deprecated one-step path functionally intact for legitimate transfers; no role state is mutated on invalid input.

Verification Results

cargo test --package drip-governor
✅ 24/24 passed

Live acceptance check:
✅ Self-transfer (new_authority == caller) rejected with Error::InvalidParam
✅ Zero-address transfer rejected with Error::InvalidParam
✅ Legitimate transfer still grants new Admin and revokes caller
✅ AdminCount unchanged on rejected paths
Acceptance Criteria Status
transfer_authority rejects new_authority == caller with Error::InvalidParam before mutating roles ✅ Guard added before any role mutation
transfer_authority rejects zero-address new_authority with Error::InvalidParam is_zero_stellar_account check added
Caller's Admin role and AdminCount are never modified on invalid input grant/revoke only execute after validation passes
Existing valid authority transfers continue to work ✅ Legacy one-step path preserved unchanged for valid inputs

Closes #359

@Joeljosef7
Joeljosef7 requested a review from Jaydbrown as a code owner August 31, 2026 14:44
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Joeljosef7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Bug: DripGovernor::transfer_authority with new_authority == caller silently strips the caller's own Admin

1 participant