The get_secret
function assumes that a Vault
resource already exists for the given account. It directly calls borrow_global<Vault>(…)
, which aborts whenever the resource is not present in storage. This means that on any new account, or in cases where no secret has been set yet, attempts to read the secret will fail with an abort. Such behavior makes the contract less user-friendly and may confuse developers or integrators who expect a clear signal that no secret exists. A more robust design would handle the absence gracefully, either through a custom error code or by returning an optional value.
Missing existence check (exists<Vault>(addr)
) before borrow_global
.
Likelihood:
On any new account that hasn’t called set_secret
, the first read will always abort.
Clients commonly probe for data before writing; those probes will routinely hit this path.
Impact:
Poor UX: first-time reads revert instead of returning a clear “not set” signal.
Harder client integration / testing due to unexpected aborts.
The following test method test_get_secret_aborts_if_not_exists
demonstartes how getting an empty secret result on the call aborting.
Either adding an explicit error (keep entry, authenticated):
Or graceful view: return an Option<String>
(no plaintext recommended in views)
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.