Normally, the set_secret
function allows the owner to store a secret in a Vault
resource. Each account can hold a single instance of the Vault
resource under the owner’s address. This applies for modules as well => Aptos Docs
The specific issue arises because move_to
will abort if a resource of the same type already exists under the caller’s account. This means the owner cannot overwrite an existing secret, causing a transaction revert when attempting to set another secret.
Likelihood:
Any attempt to call set_secret
more than once per account will trigger this behavior.
Users or scripts expecting the secret to be updatable will encounter a revert.
Impact:
Prevents updating or rotating secrets in the Vault, limiting usability.
May lead to confusion or failed transactions for integrators expecting multiple updates.
The PoC uses localnet and terminal commands to simulate how move_to
aborts the tx if the onwer already has a secret.
Start local Aptos node & faucet
Now we need to create a new terminal and:
After each step, if successful, the terminal will output a json with field "success": true
Initialize local account for deployment. It will ask you to enter a key, just press enter and it will generate account address and fund it
If you have already created a profile, Aptos would be initialized for it, so no need to overwrite the existing configuration
Publish/Deploy
Skip this step, If you already have a published module.
Set some random secret
To check if you already have a stored secret run:
Output:
If not, create one:
Now, try to create/update the current secret my_secret
Output:
move_to
fails because Vault
already exists under that address, so a second set_secret
call from the same account will revert before even reaching the event emission.
I would recommend using the borrow_global_mut
command if a secret already exists for the caller. This way, if a secret already exists and the caller wants to update it, we get a mutable reference to the resource and update the secret.
NOTE: whenever a function reads or mutates a global resource (like Vault
), you must declare it in the function signature with an acquires
annotation.
Now, we can recompile the module, publish it again, set very first secret and update the secret to a new value:
To get the new value just run curl http://127.0.0.1:8080/v1/accounts/<owner_address>/resource/<owner_address>::vault::Vault
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.