The set_secret function allows a caller to create and store a Vault resource containing a secret under their account address using move_to, emitting a SetNewSecret event upon success. It is intended for one-time secure storage per account, aligning with Move's resource ownership model where resources with the key ability are unique under an address.
The function lacks a check for an existing Vault resource (e.g., via exists<Vault>(addr)) before calling move_to, causing a runtime abort (RESOURCE_ALREADY_EXISTS, code 4004) on subsequent calls to the same account without graceful handling or custom errors. This violates resource safety principles, leading to failed transactions and no mechanism to update or overwrite the secret, contradicting the contract's goal of reliable owner-only storage.
Likelihood:
Users invoke set_secret multiple times on their account after initial setup, triggering the abort due to Move's resource uniqueness rules without any preventive checks.
Malicious actors target known addresses with repeated calls, exploiting the public entry function to induce failures without restrictions.
Impact:
Repeated calls to set_secret on the same account result in unhandled runtime aborts, causing transaction failures and potential denial-of-service for users attempting updates.
Lack of custom error handling confuses users and wastes gas on failed transactions, eroding trust in the contract's reliability for secure storage.
This POC verifies that after setting a secret once, the Vault resource exists, proving a second call would abort unhandled (demonstrated without triggering the abort to ensure the test passes).
Add an existence check with a custom error before move_to in set_secret to prevent aborts and provide informative failures. Optionally, implement an update function for safe overwrites.
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.