The contract is intended to only allow the designated @owner
to store a secret in a Vault
resource at their own address.
However, the set_secret
function is a public entry
function with no access control. It allows any user to call it and create a Vault
resource at their own address. This directly contradicts the fundamental security requirement of the contract. This single flaw is the root cause for the majority of the contract's problems.
Likelihood: High
Any user can and will be able to call this public function. This isn't a complex edge case; it's a direct failure of the primary function.
Impact: High
This flaw has two major impacts:
Loss of Data: Any non-owner who calls set_secret
successfully stores a secret at their own address. However, because get_secret
is hardcoded to read from the @owner
address, the secret stored by the non-owner becomes permanently irretrievable. The data is effectively lost.
Violation of Core Logic: The contract's main purpose is to be a private vault for the owner. By allowing anyone to create a vault, this purpose is completely defeated.
The vulnerability is confirmed by a logical walkthrough of the code's execution path:
An attacker
(any address that is not @owner
) calls set_secret
.
The function executes without any access control checks.
The line move_to(caller, secret_vault)
stores a new Vault
resource at the attacker
's address.
Later, no function can retrieve this secret. If the attacker
calls get_secret
, the assert!(caller == @owner, NOT_OWNER)
check correctly causes an abort. If the owner calls get_secret
, it will look for a vault at the @owner
address, not the attacker
's address, and will also fail (or retrieve a different vault if the owner had set one). The attacker's vault is orphaned.
The fix is to enforce ownership within set_secret
and handle resource updates correctly. This single change fixes the access control, data loss, and update issues simultaneously.
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.