Summary
The register() function in LLMOracleRegistry only checks the allowance but not the actual token balance of the registrant.
This could lead to failed transfers when users have insufficient tokens despite having set the required allowance.
Vulnerability Details
Current implementation only checks allowance before attempting transfer:
function register(LLMOracleKind kind) public {
uint256 amount = getStakeAmount(kind);
if (isRegistered(msg.sender, kind)) {
revert AlreadyRegistered(msg.sender);
}
if (token.allowance(msg.sender, address(this)) < amount) {
revert InsufficientFunds();
}
token.transferFrom(msg.sender, address(this), amount);
registrations[msg.sender][kind] = amount;
emit Registered(msg.sender, kind);
}
Impact
This vulnerability leads to wasted gas fees for users who attempt to register without sufficient token balance.
Additionally, the lack of a balance check may cause unexpected transaction failures
Tools Used
Manual Review
Recommendations
Add balance check before transfer:
function register(LLMOracleKind kind) public {
uint256 amount = getStakeAmount(kind);
if (isRegistered(msg.sender, kind)) {
revert AlreadyRegistered(msg.sender);
}
if (token.allowance(msg.sender, address(this)) < amount) {
revert InsufficientAllowance(msg.sender, amount);
}
if (token.balanceOf(msg.sender) < amount) {
revert InsufficientBalance(msg.sender, amount);
}
token.transferFrom(msg.sender, address(this), amount);
registrations[msg.sender][kind] = amount;
emit Registered(msg.sender, kind);
}