Description
In the docmentation, the Protocol says that they accept tokens that are compatible with ERC20 token standard.
However, token like `ERC-777` are backward compatible with ERC-20 tokens, If the Protocol accepts `ERC777` tokens that allows malicious callbacks ,the attacker can Re-Enter the function and can cause multiple `request()` call with the same amount.
Vulnerability Details
```javascript
function request(
bytes32 protocol,
bytes memory input,
bytes memory models,
LLMOracleTaskParameters calldata parameters
)
=> feeToken.transferFrom(msg.sender, address(this), totalfee);
//events emitted after extenal calls
emit Request(taskId, msg.sender, protocol);
emit StatusUpdate(taskId, protocol, TaskStatus.None, TaskStatus.PendingGeneration);
```
Impact
these events are important for LLM generation, therefore these events should be emitted before the external call.
Even though variables like `nextTaskId` are managed safely here, reentrant calls could still generate multiple request calls that add tasks unnecessarily or duplicate logs and events.
Tools Used
manual review
Recommendations
1. consider using Rereentrancy guard from openzeppelin for mitigation.
2. emit the logs before the external call.
```diff
function request(
bytes32 protocol,
bytes memory input,
bytes memory models,
LLMOracleTaskParameters calldata parameters
)
+ emit Request(taskId, msg.sender, protocol);
+ emit StatusUpdate(taskId, protocol, TaskStatus.None, TaskStatus.PendingGeneration);
feeToken.transferFrom(msg.sender, address(this), totalfee);
- emit Request(taskId, msg.sender, protocol);
- emit StatusUpdate(taskId, protocol, TaskStatus.None, TaskStatus.PendingGeneration);
```