Skip to content

Enforce Non-Zero Address Invariant for Fee Collector and Treasury Queued Updates #1242

Open

Description

@nursetechie

Fix: Enforce Non-Zero Address Invariant for Fee Collector and Treasury Queued Updates

Description

Architectural Motivation: In queue_set_fee_collector and queue_set_treasury, the address parameter is serialized into params_hash. In execute_set_fee_collector and execute_set_treasury, the contract deserializes the address and updates storage. If an admin accidentally provides a dummy, empty, or zeroed address, protocol fees will be routed to a black hole upon subsequent settlements. Enforcing address validation before queueing and execution prevents configuration bricking.

Integration & Backend Considerations: Affects admin.rs::queue_set_fee_collector and queue_set_treasury. Reverts with ContractError::InvalidAddress if target address matches system zero or current contract address.


Requirements & Context

contracts/escrow/src/admin.rs (lines 1015-1080). Address parameters are not validated prior to hashing.

Tasks:

Part A — Address Invariant Validation

  1. In queue_set_fee_collector, check new_collector != env.current_contract_address().
  2. Verify new_collector != read_admin_address(&env).unwrap() to prevent role confusion.
  3. Apply identical checks in queue_set_treasury.

Part B — Execution-Time Re-Verification

  1. In execute_set_fee_collector, re-validate address before updating GlobalConfig.fee_collector.
  2. Return ContractError::InvalidAddress on violation.

Part C — Test Address Validation

  1. Add test in test_admin.rs attempting to set fee collector to contract's own address.
  2. Assert call reverts with ContractError::InvalidAddress.

Acceptance Criteria

  • queue_set_fee_collector rejects contract address or invalid roles with InvalidAddress.
  • queue_set_treasury rejects contract address with InvalidAddress.
  • Addresses are validated at both queue time and execution time.

Suggested Execution

git checkout -b fix/validate-fee-collector-address

Suggested Commit Message

fix: enforce non-zero and valid role address checks for fee collector and treasury

Testing Notes

  • Run cargo test --lib test_admin.
  • Verify error codes match ContractError::InvalidAddress.

References

contracts/escrow/src/admin.rs#L1015-L1080
contracts/escrow/src/errors.rs#L47-L48


Definition of Done

  • Ready for review.

Activity

  1. added
    bug
    on Nov 19, 2026
  2. added
    Stellar Wave
    on Nov 23, 2026
  3. Kaybee973 commented on Nov 23, 2026

    @Kaybee973

    @Kaybee973 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    I’m interested in working on this issue and have experience fixing similar problems. I’d be happy to contribute.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Kaybee973 to this issue.

  4. keshav2800 commented on Nov 25, 2026

    @keshav2800

    @keshav2800 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    Hi @nursetechie,

    I can ship this within 30 minutes.

    1. In contracts/escrow/src/admin.rs, queue_set_fee_collector (lines 1200-1212) and queue_set_treasury (lines 1166-1173) still push the address into params and call queue_timelock_op with no invariant check, so a zero or contract/admin address can be queued.
    2. execute_set_fee_collector (line 1225) and execute_set_treasury (line 1185) already call validate_fee_collector_change / validate_treasury_change. I'll run those same checks on the queue path (and extend them if they don't already reject env.current_contract_address() and the admin, as the issue asks) so a bad address never enters the timelock.

    This is a small Soroban/Rust address-invariant fix, and I can open the PR within 30 minutes if assigned.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @keshav2800 to this issue.

  5. drips-wave commented on Nov 25, 2026

    @drips-wave

    Congratulations, @Kaybee973! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

    🧑‍💻 @Kaybee973: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  6. drips-wave commented on Nov 28, 2026

    @drips-wave

    This issue has been marked as completed by a Drips Wave moderator for @Kaybee973 as part of the Stellar Wave Program's 11th Wave 🥳

    Moderator's reason: [Auto-assessed] The contributor's PR #1379 correctly implements the requested address-invariant checks for both fee collector and treasury queued updates in contracts/escrow/src/admin.rs and internal validation helpers, and adds comprehensive unit test coverage in test_admin.rs verifying that zero, contract, and admin addresses are correctly rejected with ContractError::InvalidAddress.

    😎 @Kaybee973: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

    ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar Wavebug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions