Dria

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

Protocol allows generators and validators to use a flashloan to register, respond to requests and unregister

Summary

The vulnerability allows users to bypass staking requirements by using a flash loan to register, perform actions, and unregister within a single transaction. Since there’s no penalty or slashing mechanism, users can exploit this to access respond or validate functions without maintaining a genuine stake, undermining the security of the system.

Vulnerability Details

In order to make respond and validate calls, one has to have registered to be a generator or a validator.

Here are the register and unregister functions:

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);
}
// ensure the user has enough allowance to stake
if (token.allowance(msg.sender, address(this)) < amount) {
revert InsufficientFunds();
}
token.transferFrom(msg.sender, address(this), amount);
// register the user
registrations[msg.sender][kind] = amount;
emit Registered(msg.sender, kind);
}
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, token.allowance(address(this), msg.sender) + amount);
}

As we can see, there is no requirement that the user does not unregister in the same tx as he registered.

There is also no slashing mechanism for misbehaviour.

This allows anyone to obtain a flashloan, register, respond/validate and then unregister in a single tx, so anyone can easily use many accounts to register as generator/validator to manipulate outcome of the output assets that will be purchased by the buyerAgent

Impact

This undermines the staking mechanism intended to secure the system. Users can temporarily stake via flash loans, perform respond or validate actions, and withdraw their stake in the same transaction, bypassing any real commitment. This exposes the system to potential abuse by uncommitted or malicious actors, who can repeatedly perform actions without risk or lasting stake. Consequently, it weakens the reliability and trustworthiness of the validation and generation processes, possibly leading to inaccurate or malicious outcomes within the system.

Tools Used

Manual Review

Recommendations

  • Funds sent during register should be locked for a period

  • Impose slashing mechanism for misbehaviour

Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

There is no oracle whitelisting

Support

FAQs

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