Skip to content

fix(yield_vault): cover and document admin authorization guarantee on initialize (#8) - #28

Open
jdjioe5-cpu wants to merge 1 commit into
YieldAnchor:mainfrom
jdjioe5-cpu:fix/issue-8-initialize-auth
Open

jdjioe5-cpu wants to merge 1 commit into
YieldAnchor:mainfrom
jdjioe5-cpu:fix/issue-8-initialize-auth

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Closes #8

Summary

The contract requires the administrator being installed to explicitly authorize assignment of control (\�dmin.require_auth()). This PR fulfills all acceptance criteria specified in #8 without breaking existing contract method signatures or deployment interfaces:

  • Pins the front-running rejection behavior in a hermetic contract test using \mock_auths: an attacker proposing a target administrator with only attacker-owned credentials is unconditionally rejected by the host, ensuring an unauthorized caller cannot install an administrator it does not control.
  • Verifies that only valid authorization from the intended administrator successfully initializes the vault and sets the administrator address.
  • Asserts that subsequent re-initialization is strictly rejected with \VaultError::AlreadyInit\ regardless of caller authorization.
  • Replaces outdated caveats in \docs/deployment/testnet.md\ with the accurate authorization guarantee while preserving the recommendation to initialize immediately upon creation.
  • Documents the explicit \initialize\ authorization guarantee in \contracts/yield_vault/README.md.

Acceptance Criteria

  • An unauthorized caller can no longer install an admin it does not control (\�dmin.require_auth())
  • Contract test covers the front-running path and asserts rejection (\ est::initialize_rejects_front_runner_without_admin_auth)
  • \cargo test -p yield_vault\ / \pnpm run contract:test\ passes (20/20 tests pass)
  • \contracts/yield_vault/README.md\ and \docs/deployment/testnet.md\ reflect the new guarantee
  • \cargo clippy -p yield_vault --all-targets -- -D warnings\ passes cleanly
  • \pnpm run typecheck, \pnpm run lint, and \pnpm test\ pass across all workspace packages

Verification Evidence

\\�ash
$ cargo test -p yield_vault
running 20 tests
test test::initialize_rejects_front_runner_without_admin_auth ... ok
test test::authorization_is_required_for_initialization_users_and_admin ... ok
test test::initialization_validates_metadata_and_is_one_time ... ok
...
test result: ok. 20 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.31s

$ cargo clippy -p yield_vault --all-targets -- -D warnings
Finished \dev\ profile [unoptimized + debuginfo] target(s) in 0.52s

$ cargo fmt --all -- --check
Clean (exit code 0)

$ pnpm run typecheck && pnpm run lint
Clean (exit code 0)
\\

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.

fix: initialize is unauthenticated, so a front-runner can capture admin on a fresh vault

1 participant