Repository navigation
Fix/issue 8 initialize auth - #22
Open
ple1155n-cmyk wants to merge 5 commits into
Open
ple1155n-cmyk wants to merge 5 commits into
ple1155n-cmyk wants to merge 5 commits into
Conversation
…t-running Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8
Problem & Threat Model
Previously,
initializeincontracts/yield_vault/src/lib.rsonly validated thatDataKey::Configwas not set, without checking caller authorization. On a freshly deployed vault instance, an attacker/front-runner observing contract creation could front-run initialization and supply their own address asadmin. Because the admin controls critical operations likepauseandunpausewith no recovery/replacement mechanism, this vulnerability allowed complete contract capture.Solution
contracts/yield_vault/src/lib.rs: Enforcedadmin.require_auth()at the start ofinitialize. The designated admin must cryptographically authorize initialization, preventing front-runners from installing an admin address they do not control.contracts/yield_vault/README.md: Documented the initialization security guarantee requiring admin authorization.docs/deployment/testnet.md: Updated deployment documentation to reflect that the front-running caveat is resolved.Test Coverage
Added unit tests covering the front-running and authentication paths:
initialize_panics_without_admin_auth: Asserts panic when called without valid authorization.initialize_requires_admin_auth_before_metadata_validation: Asserts authorization is verified before metadata validation logic.initialize_rejects_unauthorized_front_runner: Confirms an unauthorized attacker's transaction fails when attempting to front-run initialization.Verification
pnpm run contract:test(16/16 passed).pnpm run contract:clippy(passed with-D warnings, 0 warnings).