Skip to content

[Bug] initialize is front-runnable in tholos v1 #158

Closed

Description

@collinsezedike

Summary

initialize (contracts/tholos/src/lib.rs:247-299) takes admin as a caller-supplied parameter and guards only against a second call (if env.storage().instance().has(&DataKey::Admin) { return Err(Error::AlreadyInitialized); }). Nothing ties the call to the address that deployed the contract.

On Soroban, deployment and initialization are separate transactions. Anyone observing the deploy transaction can submit their own initialize call, with their own admin address, ahead of the legitimate deployer's intended call. Whoever's initialize transaction lands first becomes the permanent admin of that contract instance, since AlreadyInitialized then blocks every subsequent attempt, including the legitimate deployer's own.

Impact: a contract instance can be permanently taken over by an unrelated party before its intended operator ever gets to configure it, with no recovery path (see the separate admin-rotation issues, #128/#129, for that gap too).

Scope

  • Add protection against a front-run initialize: options include restricting the caller to the contract's actual deployer, or an atomic constructor pattern that ties initialization to the deploy transaction itself.
  • Add a test confirming initialize can no longer succeed for a caller distinct from the legitimate deployer.

Proposed approach

Whatever mechanism is chosen here should also be applied to contracts/tholos-v2's equivalent (#154) for consistency between the two contracts.

Activity

  1. added
    bugSomething isn't working
    Maybe RewardedIssue may be eligible for a GrantFox reward
    GrantFox OSSIssue tracked in GrantFox OSS
    hardSecurity-sensitive or high-complexity change
    on Sep 2, 2026
  2. odiliflash-ops commented on Sep 3, 2026

    @odiliflash-ops

    I would love to work on this issue

  3. aojomo commented on Sep 3, 2026

    @aojomo

    Hi Maintainer, Please I would like to work on this issue

  4. grantfox-oss commented on Sep 4, 2026

    @grantfox-oss

    🦊 GrantFox — @odiliflash-ops has been assigned to this issue!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #158)
    2. Your PR will be reviewed by the drydocs maintainers

    Good luck! Track your progress on GrantFox.

  5. collinsezedike commented on Sep 7, 2026

    @collinsezedike
    CollaboratorAuthor

    @odiliflash-ops Checking in, any progress on this? Let us know if you're still working it or need to hand it off.

  6. collinsezedike commented on Sep 10, 2026

    @collinsezedike
    CollaboratorAuthor

    @odiliflash-ops Second check-in, still no word since the first. If we don't hear back or see a PR within 24 hours, we'll unassign this and open it up to someone else.

  7. collinsezedike commented on Sep 11, 2026

    @collinsezedike
    CollaboratorAuthor

    @odiliflash-ops Unassigning after no response past the 24-hour window from the last check-in. Fixed directly in #214.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghardSecurity-sensitive or high-complexity change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions