The SecretVault contract is designed to allow only the owner to store and retrieve secrets, ensuring exclusive access control to sensitive data stored on-chain.
The contract implements inconsistent access control between the set_secret
and get_secret
functions, where any user can store secrets but only the hardcoded @owner
address can retrieve them, completely breaking the intended security model and making secrets inaccessible to legitimate users.
More info about this can be accessed through : https://github.com/CodeHawks-Contests/2025-07-secret-vault/pull/2
Likelihood:
Reason 1 Any user can call the public set_secret
function without restrictions, as there are no access control checks preventing unauthorized secret storage
Reason 2 The vulnerability is present in every transaction involving secret management, making it inevitable that unauthorized users will interact with the contract
Impact:
Impact 1 Legitimate users (non-owners) who store secrets will permanently lose access to their data, as only the hardcoded @owner
can retrieve secrets
Impact 2 The contract fails its primary security objective of providing exclusive secret storage, rendering it completely unusable for its intended purpose
This proof of concept demonstrates how the access control bypass vulnerability allows any user to store secrets while preventing legitimate access to those secrets. The test simulates a real-world scenario where a user successfully stores confidential data but then discovers it's permanently inaccessible due to the flawed access control logic.
The vulnerability occurs because set_secret
accepts any signer without validation, while get_secret
only allows the hardcoded @owner
address and always reads from the @owner
account regardless of where the secret was actually stored. This creates a critical disconnect between storage and retrieval operations.
The mitigation strategy addresses the root cause by implementing consistent access control across both functions and fixing the resource management logic. The solution ensures that only the authorized owner can store secrets and that the retrieval logic correctly accesses the owner's account where the secret is stored.
Key improvements include: (1) Adding proper access control validation in set_secret
, (2) Implementing proper resource update handling for existing vaults, (3) Aligning the storage and retrieval logic to use consistent account addressing, and (4) Adding comprehensive error handling for edge cases.
In Move for Aptos, the term "owner" refers to a signer, which is a verified account that owns a given resource, has permission to add resources and the ability to grant access or modify digital assets. Following this logic in this contest, the owner is the account that owns `Vault`. This means that anyone has right to call `set_secret` and then to own the `Vault` and to retrieve the secret from the `Vault` in `get_secret` function. Therefore, this group is invalid, because the expected behavior is anyone to call the `set_secret` function.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.