The LLMOracleRegistry contract’s register function calls transferFrom to transfer the staking amount from the user to the contract but does not verify whether the transfer succeeded. If transferFrom fails (due to insufficient balance, lack of approval, or other issues), the function will not revert, leaving the contract in an inconsistent state and potentially registering the user without a successful stake transfer.
In the LLMOracleRegistry contract, the register function stakes a specified amount by calling token.transferFrom(msg.sender, address(this), amount). However, the result of this call is not checked. This could lead to unintended registration of users who have not successfully transferred their stake, as the function proceeds even if transferFrom fails.
The vulnerable code is shown below:
To demonstrate this vulnerability, simulate a scenario where transferFrom fails (e.g., insufficient balance or lack of allowance) and observe that register still proceeds without reverting.
The test demonstrates that attempting to register without sufficient balance or allowance should revert, as transferFrom does not succeed. In this case, the original code would have incorrectly registered the oracle even though the stake transfer did not complete, but with the fix (shown below), it will correctly revert.
If the transferFrom call fails, users will be incorrectly registered without their stake being successfully transferred to the contract. This could lead to several issues:
Users may incorrectly believe they have staked and are registered as oracles.
The contract's state could be inconsistent with the actual funds held.
Unregistered users could gain access to oracle functions, potentially undermining the protocol’s integrity.
Manual review.
To resolve this issue, modify the register function to check the return value of transferFrom and revert if the transfer fails.
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.