Keep3r Relay Implementations are Not Compatible with Keep3r in Optimism and Executions Will Always Revert
The Keep3r relay contracts call a deprecated worked() function that reverts on sidechains like Optimism, so all exec() calls by keepers will always revert. This makes the relay contracts unusable on those chains.
Source: https://github.com/sherlock-audit/2024-04-xkeeper-judging/issues/132
Found by
Kose
Summary
Keep3rRelay and Keep3rBondedRelay uses deprecated function for sidechains and exec calls will always revert.
Vulnerability Detail
Keep3r takes different arguments for function worked() in sidechains in order to estimate gas usage and rewards for keepers properly:
/// @dev Sidechain implementation deprecates worked(address) as it should come with a usdPerGasUnit parameter
function worked(address) external pure override {
revert Deprecated();
}
/// @notice Implemented by jobs to show that a keeper performed work
/// @dev Uses a USD per gas unit payment mechanism
/// @param _keeper Address of the keeper that performed the work
/// @param _usdPerGasUnit Units of USD (in wei) per gas unit that should be rewarded to the keeper
function worked(address _keeper, uint256 _usdPerGasUnit) external override {
The snippet above taken from Keep3rSidechain.sol that is live in optimism currently. We can also see that this contract is exact contract that will be interacted as it is the address of KEEPER_V2 in deployed Keep3r Relays by xKeeper in Optimism. Deployed addresses can checked from here
But relay contracts implemented by xKeeper uses the worked() function that is deprecated:
// Inject the final call which will issue the payment to the keeper
_execDataKeep3r[_execDataLength + 1] = IAutomationVault.ExecData({
job: address(KEEP3R_V2),
jobData: abi.encodeWithSelector(IKeep3rV2.worked.selector, msg.sender)
});
Hence in chains other than mainnet, Keep3r calls will always revert.
Impact
Current Keep3r Relay contracts are not compatible with Keep3r in Optimism (Keeper is only deployed to Mainnet and Optimism currently). Although vault creation will succeed, exec() called by keepers will always revert.
Code Snippet
Keep3rRelay.sol Keep3rBondedRelay.sol
Tool used
Manual Review
Recommendation
Either implement a compatible version for Keep3rSideChain, or don't use Keep3r in sidechains.
Discussion
sherlock-admin3
1 comment(s) were left on this issue during the judging contest.
Kose commented:
medium
Hash01011122
Borderline Low/Med issue
kosedogus
Escalate
The core contract functionality is broken for Keep3rRelay.sol and Keep3rBondedRelay.sol in all L2's. All exec() calls via these contracts will always revert, rendering contracts useless. This should be valid medium.
sherlock-admin2
Escalate
The core contract functionality is broken for
Keep3rRelay.solandKeep3rBondedRelay.solin all L2's. Allexec()calls via these contracts will always revert, rendering contracts useless. This should be valid medium.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
ashitakah
The issue is right, in the L2 version of keep3r worked was deprecated, we have to generate versions of the keep3r relays in L2 with the updated worked.
Hash01011122
As I mentioned, above this issue is borderline low/medium issue. In earlier contest of sherlock, issues like this was considered as low severity issue, because of which I considered it as low. I will let head of judge decide the severity.
cvetanovv
For me this issue is Medium and fits the rule:
Breaks core contract functionality, rendering the contract useless.
I am planning to accept the escalation and make this issue Medium.
Evert0x
Result: Medium Unique
sherlock-admin2
Escalations have been resolved successfully!
Escalation status:
- kosedogus: accepted
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/xkeeper-framework/xkeeper-core/commit/df7b21882a1073b334625a1be394e38a2bba1cb9
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The relay contracts use the deprecated worked(address) function instead of the sidechain-specific worked(address,uint256) function.
Impact
On sidechains like Optimism, all exec() calls by keepers will always revert, rendering the relay contracts useless.
What the attacker needed
Deployment on a sidechain like Optimism; Use of Keep3rRelay or Keep3rBondedRelay
The fix
The protocol team fixed this issue by implementing a compatible version for Keep3rSidechain.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract on a sidechain (a secondary blockchain) changed how it pays keepers, but the relay contracts still use the old way. When a keeper tries to execute work, the old function immediately fails, so the whole transaction is undone. This means the relay cannot be used on that sidechain.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.