Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: medium
Invalid

Missing Token Balance Check in Oracle Registration

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);
// ensure the user is not already registered
if (isRegistered(msg.sender, kind)) {
revert AlreadyRegistered(msg.sender);
}
// Only checks allowance, not balance
if (token.allowance(msg.sender, address(this)) < amount) {
revert InsufficientFunds();
}
// Transfer will fail if balance is insufficient
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);
}
// Check both allowance and balance
if (token.allowance(msg.sender, address(this)) < amount) {
revert InsufficientAllowance(msg.sender, amount);
}
if (token.balanceOf(msg.sender) < amount) {
revert InsufficientBalance(msg.sender, amount);
}
// Transfer is more likely to succeed now
token.transferFrom(msg.sender, address(this), amount);
registrations[msg.sender][kind] = amount;
emit Registered(msg.sender, kind);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.