Summary
The first token.approve
call in the LLMOracleRegistry::unregister
function is redundant and can be removed, as it serves no purpose and may introduce security vulnerabilities.
Vulnerability Details
Redundant call `token.approve(msg.sender, amount)`;
function unregister(LLMOracleKind kind) public returns (uint256 amount) {
amount = registrations[msg.sender][kind];
if (amount == 0) {
revert NotRegistered(msg.sender);
}
delete registrations[msg.sender][kind];
emit Unregistered(msg.sender, kind);
@> token.approve(msg.sender, amount);
token.approve(msg.sender, token.allowance(address(this), msg.sender) + amount);
}
Impact
token.approve
call in the LLMOracleRegistry::unregister
function is redundant and can be removed, as it serves no purpose and may introduce security vulnerabilities.
Tools Used
Manual Review
Recommendations
function unregister(LLMOracleKind kind) public returns (uint256 amount) {
amount = registrations[msg.sender][kind];
// ensure the user is registered
if (amount == 0) {
revert NotRegistered(msg.sender);
}
// unregister the user
delete registrations[msg.sender][kind];
emit Unregistered(msg.sender, kind);
// approve its stake back
- token.approve(msg.sender, amount);
token.approve(msg.sender, token.allowance(address(this), msg.sender) + amount);
}