Skip to content
Business logic Audit finding Intermediate

Staking preSign could use some basic validations

The preSign function accepts any orderUid without validating its contents, so the owner could sign an order with an arbitrary receiver and other parameters. This could act as a rug vector, allowing the owner to redirect funds or set unfavourable terms.

Alex the Entreprenerd Follow

Originally disclosed on Code4rena

Submitted by Alex the Entreprenerd

The function preSign accepts any orderUid. function preSign(bytes calldata orderUid) external onlyOwner

Because of how Cowswap works, accepting any orderUid can be used as a rug-vector.

This is because the orderData contains a receiver which in lack of validation could be any address.

You’d also be signing other parameters such as minOut and how long the order could be filled for, which you may or may not want to validate to give stronger security guarantees to end users.

Recomended Mitigation Steps

I’d recommend adding basic validation for tokenOut, minOut and receiver.

Feel free to check the work we’ve done at Badger to validate order parameters, giving way stronger guarantees to end users. https://github.com/GalloDaSballo/fair-selling/blob/44c0c0629289a0c4ccb3ca971cc5cd665ce5cb82/contracts/CowSwapSeller.sol#L194

Also notice how through the code above we are able to re-construct the orderUid, feel free to re-use that code which has been validated by the original Cowswap / GPv2 Developers.

toshiSat (Yieldy) confirmed, resolved and commented:

Thanks for the functions, I like what you guys did. Our cowswap function is only called using the onlyOwner modifier, so I think it’s pretty safe, but I agree some validation would be better than none.


The original report as published on Code4rena, by Alex the Entreprenerd. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 preSign function lacks validation of the order parameters such as receiver, tokenOut and minOut, allowing the owner to sign arbitrary orders.

Impact

The owner could sign an order with an arbitrary receiver, potentially redirecting funds, though the function is restricted to the owner.

What the attacker needed

Owner privileges

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 lets its owner approve orders for a trading system. The approval function does not check what is inside the order, so the owner could approve an order that sends the money to themselves or sets bad terms. This is risky because users have to trust the owner not to do that.

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.

More by Alex the Entreprenerd

View all

7 more disclosed reports, best first.

More from Yieldy contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.