The LLMOracleRegistry contract’s unregister function lacks proper withdrawal functionality for user stakes when unregistering as an oracle. The function currently approves the staked amount back to the user but does not actually transfer the funds. This could mislead users into thinking they are refunded when, in reality, they are not. Without a direct withdrawal mechanism, users would need to explicitly call transferFrom using the allowance, which many may not realize. This vulnerability affects user trust and usability, potentially locking funds in the contract.
In the provided LLMOracleRegistry contract, the unregister function is intended to refund the user’s stake upon unregistering as an oracle. However, rather than transferring the staked amount back to the user, it only approves the allowance for the user, requiring them to initiate a subsequent transferFrom to withdraw their tokens.
Below is the code snippet that highlights the vulnerability in unregister:
To demonstrate the vulnerability, a user must call register with sufficient staking allowance and then call unregister. After unregistering, they would still need to execute a transferFrom to retrieve the approved tokens. Users unaware of this requirement may believe their funds were automatically returned.
Let`s check it with a test:
The test demonstrates that after calling unregister, the tokens remain in the contract. The oracle must make an additional transferFrom call to retrieve their funds, which users may overlook, thinking the funds were automatically returned.
Users who call unregister will not immediately receive their staked funds, which could lead to confusion or funds being "stuck" if they are unaware of the additional transferFrom requirement. This flaw impacts user experience and trust in the contract's functionality, as it deviates from standard staking/unstaking processes where funds are automatically refunded.
Manual review.
To resolve this, modify the unregister function to use transfer instead of approve to ensure that funds are returned directly to the user upon registering.
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.