Skip to content

Contract Deployment Initialiser Guard #477

Description

@Kingsman-99

Description

The init function can currently be called multiple times, allowing an attacker who front-runs the deployer to hijack the contract by setting their own admin. A one-shot initialiser guard must ensure init can only execute once across the contract's lifetime.

Technical Context

Add an Initialised boolean to storage::instance in contracts/split/src/lib.rs. At the top of init, call env.storage().instance().get::<_, bool>(&DataKey::Initialised) and panic with AlreadyInitialised (new variant in types.rs) if it is set. Set the flag atomically at the end of init.

Acceptance Criteria

  • A second call to init returns AlreadyInitialised error
  • The flag is written inside the same transaction as the rest of init setup
  • Deployment integration test verifies the guard works in a fresh environment
  • The flag persists across ledgers via storage::instance
  • No admin-settable bypass exists for the guard
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptssecuritySecurity hardening and access control

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions