A user should be able to query the contract to see if a secret exists without causing an error. However, the get_secret
function directly attempts to borrow_global
without first checking if a Vault
resource actually exists. If no vault has been created, this operation will fail and cause the entire transaction or view call to abort.
Likelihood: Medium
It is a common and expected behavior for a user or front-end application to check for a value before one has been set. This will always fail.
Impact: Low
This flaw does not lead to data loss or theft, but it represents poor design and creates a brittle contract. It forces front-ends to build complex, off-chain logic to avoid calling a function that should be safe to call.
The issue is a direct result of the borrow_global
function's defined behavior in Move.
The contract is deployed. No one has called set_secret
yet, so no Vault
resource exists at the @owner
address.
A front-end or user calls the get_secret
view function to check the current secret.
The function executes borrow_global<Vault>(@owner)
.
The Move VM requires that the resource must exist for borrow_global
to succeed. Since it doesn't, the VM aborts the execution with an ERESOURCE_NOT_FOUND
error.
The function should first check for the resource's existence and return an Option
type, which is the standard way to handle optional values in Move. This makes the function robust and easier to integrate with.
There is no security impact on the protocol, therefore this is an Informational finding. Also, it is a user mistake, if the user calls `get_secret` without first calling `set_secret`.
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.