Payer cannot withdraw accidental extra funds sent to the contract without canceling
The contract's rescueERC20 function only allows withdrawing non-stream tokens, so if extra stream tokens are accidentally sent, the payer cannot retrieve them without cancelling the stream. An attacker could not directly exploit this, but the payer might be forced to cancel the stream, disrupting the receiver.
Source: https://github.com/sherlock-audit/2022-11-nounsdao-judging/issues/28
Found by
0xZakk, dic0de, cccz, WATCHPUG, neko_nyaa, adriro, dipp, obront
Summary
If a different ERC20 is accidentally sent to the contract, the Payer can withdraw it using the rescueERC20 function. However, if they accidentally send extra of the streaming token's funds to the contract, the only way to withdraw it is to cancel the stream.
Vulnerability Detail
The Nouns team seems to have made the decision that they should protect against accidental funds being sent into the contract. They implemented the rescueERC20 function to accomplish this.
However, the rescueERC20 function only works for non-stream tokens. If they accidentally send too much of the streaming token (which seems like a likely scenario), there is no similar rescue function to retrieve it.
Instead, their only option is to cancel the stream. In a protocol that's intended to be run via a governance system, canceling the stream could cause problems for the receiver (for example, if they are unable to pass a vote to restart the stream).
Impact
If too many stream tokens are sent into the contract, the whole stream will need to be canceled to retrieve them.
Code Snippet
https://github.com/sherlock-audit/2022-11-nounsdao/blob/main/src/Stream.sol#L237-L259
Tool used
Manual Review
Recommendation
Adjust the rescueERC20 function to also allow for withdrawing excess stream tokens, as follows:
function rescueERC20(address tokenAddress, uint256 amount) external onlyPayer {
- if (tokenAddress == address(token())) revert CannotRescueStreamToken();
+ if (tokenAddress == address(token()) && amount < tokenBalance() - remainingBalance) revert AmountExceedsBalance;
IERC20(tokenAddress).safeTransfer(msg.sender, amount);
}
Discussion
eladmallel
Fix PR: https://github.com/nounsDAO/streamer/pull/6
The PR fixes multiple issues because they were touching the same code.
jack-the-pug
Fix confirmed!
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 rescueERC20 function explicitly reverts when the token address matches the stream token, preventing recovery of excess stream tokens.
Impact
If too many stream tokens are sent into the contract, the whole stream will need to be canceled to retrieve them, which could cause problems for the receiver.
What the attacker needed
Payer accidentally sends extra stream tokens
The fix
The rescueERC20 function should be adjusted to allow withdrawing excess stream tokens, as long as the amount does not exceed the excess balance.
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.
This is a smart contract that streams tokens over time. The contract has a function to rescue tokens sent by mistake, but it only works for tokens other than the one being streamed. If someone accidentally sends extra of the streamed token, they cannot get it back without stopping the stream, which could harm the receiver.
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.