Splitter: Anyone can call incrementWindow to steal the tokens in the contract
The Splitter contract's incrementWindow function can be called by anyone using a fake RoyaltyVault contract, allowing the caller to inflate the recorded balance for a window. A verified user can then claim more tokens than they are entitled to, stealing funds from the contract.
Submitted by cccz, also found by hickuphh3, kirk-baird, leastwood, pedroais, rayn, Ruhum, saian, WatchPug, and wuwe1
In general, the Splitter contract’s incrementWindow function is only called when tokens are transfer to the contract, ensuring that the number of tokens stored in balanceForWindow is equal to the contract balance. However, anyone can use a fake RoyaltyVault contract to call the incrementWindow function of the Splitter contract, so that the amount of tokens stored in balanceForWindow is greater than the contract balance, after which the verified user can call the claim or claimForAllWindows functions to steal the tokens in the contract.
function incrementWindow(uint256 royaltyAmount) public returns (bool) {
uint256 wethBalance;
require(
IRoyaltyVault(msg.sender).supportsInterface(IID_IROYALTY),
"Royalty Vault not supported"
);
require(
IRoyaltyVault(msg.sender).getSplitter() == address(this),
"Unauthorised to increment window"
);
wethBalance = IERC20(splitAsset).balanceOf(address(this));
require(wethBalance >= royaltyAmount, "Insufficient funds");
require(royaltyAmount > 0, "No additional funds for window");
balanceForWindow.push(royaltyAmount);
currentWindow += 1;
emit WindowIncremented(currentWindow, royaltyAmount);
return true;
}
Proof of Concept
https://github.com/code-423n4/2022-03-joyn/blob/main/splits/contracts/Splitter.sol#L149-L169
Recommended Mitigation Steps
Add the onlyRoyaltyVault modifier to the incrementWindow function of the Splitter contract to ensure that only RoyaltyVault contracts with a specific address can call this function.
sofianeOuafir (Joyn) confirmed and commented:
This is a high-risk issue and we intend to solve it. The mitigation provided looks good too and will be considered when fixing this issue 👍
deluca-mike (judge) commented:
See a detailed exploit and recommended solution at #21
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
Likely the incrementWindow function lacks proper access control, allowing any contract that implements the required interface to call it and artificially increase the recorded balance.
Impact
A verified user could steal tokens from the contract by inflating the recorded balance and then claiming more than their legitimate share.
What the attacker needed
Attacker must be a verified user; attacker deploys a fake RoyaltyVault contract; contract holds tokens
How it was found
- Deploy a fake RoyaltyVault contract that implements supportsInterface and getSplitter to return the required values.
- Call incrementWindow on the Splitter contract from the fake contract, passing a royaltyAmount that is less than or equal to the contract's token balance.
- The Splitter contract records the royaltyAmount in balanceForWindow and increments currentWindow.
- As a verified user, call claim or claimForAllWindows to withdraw tokens exceeding the legitimate share.
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.
The Splitter contract keeps track of how many tokens each window should pay out. It assumes that only a trusted RoyaltyVault contract will call incrementWindow to add a new window. But anyone can create a fake contract that pretends to be a RoyaltyVault and call incrementWindow, making the contract think there are more tokens to pay out than it actually has. Then a legitimate user can claim those extra tokens, taking money from the contract.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.