The get_secret
function in the Secret Vault contract contains a critical access control vulnerability that completely undermines the security model of the application.
Only the owner should be able to set and retrieve their own secret from their personal vault storage.
The get_secret
function contains a logic error where it checks if the caller is the owner (@owner
) but then always retrieves the vault from the hardcoded @owner
address instead of the caller's address. This creates a fundamental mismatch between access control validation and data retrieval.
Vulnerable Code:
Reason 1: The vulnerability is deterministic and always present - any call to get_secret
with @owner
as the caller parameter will trigger this behavior
Reason 2: The function is a public view function accessible to all users without additional restrictions
Impact 1: Complete bypass of the intended access control mechanism, violating the core security requirement
Impact 2: Unauthorized access to sensitive data - any user can retrieve the owner's secret by calling the function with the owner's address
Any external user can exploit this vulnerability with a simple function call:
Attack Flow:
Attacker calls get_secret(@owner)
Function validates that @owner == @owner
(passes ✅)
Function retrieves vault from @owner
's storage (unintended behavior ❌)
Returns the owner's secret to the attacker
Code demonstrating the vulnerability:
Fix the function to read from the caller's storage instead of the hardcoded owner address:
Alternative Solution: If the intention is to only allow the owner to access their own secret, consider redesigning the function to not take a caller parameter:
This vulnerability completely breaks the fundamental security promise of the Secret Vault application. The contract is designed to ensure that "only the owner should be able to store a secret and then retrieve it later," but this flaw allows anyone to access the owner's secret, making the entire security model ineffective.
Severity Classification: Critical/High - Complete access control bypass with unauthorized data disclosure.
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.