Violation of implicit constraints in batched operations may break protocol assumptions
The Ladle contract allows batched operations but does not enforce implicit constraints on operation order and multiplicity, such as requiring Join Ether to be first and Exit Ether to be last. An attacker or integrator could craft a batch that violates these constraints, potentially causing failed transactions, undefined behaviour, or loss/lock of funds.
Yield Witch v2 contest
Originally disclosed on Code4rena
The Ladle batching of operations is a complex task (as noted by the project lead) with implicit constraints on what operations can be bundled together in a batch. Operations can/have to appear how many times and in what order/sequence etc. Some examples of these constraints are: Join Ether should be the first operation, Exit Ether the last, and only one Join Ether per batch.
All this complexity is managed currently by anticipating all interactions to happen via their authorized front-end, which uses validated (and currently only revealed on-demand) recipes that adhere to these constraints. There is a plan to open the design up to other front-ends and partner integrating protocols that will also test their batch recipes or integrations for these constraints.
Breaking some of these constraints opens up the protocol to failing transactions, undefined behavior, or potentially loss/lock of funds. Defensive programming suggests enforcing such batch operation constraints in the code and documentation and onboarding checks for defense-in-depth. Relying on documentation or external validation may not be sufficient for arguably the most critical aspect of batched operations which is the only authorized way to interact with the protocol.
The rationale for assigning medium-severity is that, while the likelihood of this may be low because of controlled/validated onboarding on new front-ends or integrating protocols, the impact of accidental deviation from implicit constraints is high. This may result in a transaction failing, or tokens getting locked/lost, thus impact the entire protocol’s functioning. So, with low likelihood and high impact, the severity (according to OWASP) is medium.
- A new front-end project comes up claiming to provide a better user interface than the project’s authorized front-end. It does not use the recipe book (correctly) and makes Ladle batches with incorrect operations, thus failing the constraints and leading to protocol failures and token lock/loss.
- An integrating protocol goes through the approved onboarding and validation but has missed bugs in its recipe for batches, thus failing the constraints and leading to protocol failures and token lock/loss.
Recommend enforcing batch operation constraints explicitly in the code (e.g., with tracking counters/booleans for operations) along with documentation and onboarding validation. This may increase the complexity of the batching code but adds fail-safe defense-in-depth for any mistakes in onboarding validation of implicit constraints, which may affect protocol operations significantly.
albertocuestacanada (Yield) disputed:
I don’t think implementing the suggested checks is worth the added complexity and deployment gas.
Given that this is an issue disclosed by the sponsor and widely discussed, I would find it unfair to the other wardens if accepted.
The warden brings up a valid concern. As to the sponsor’s objection, the sponsor has written, “The Ladle is a complex contract, with wide-ranging powers over the protocol. It is the riskiest contract, and at the same time, the one that has more room for a bug to hide. It is of the highest importance to find as many bugs as we can in it.” (emphasis mine). I highly recommend the issue be addressed by the sponsor.
albertocuestacanada (Yield) commented:
I still disagree. I disclosed this issue myself first in the C4 discord, and it is a design choice.
Users are not expected to build batches themselves and won’t be provided with any tools to do so. If a user decides to ignore all advice and go to the extreme length of interacting with the smart contracts himself or via an unauthorized front-end, it’s completely on him if he loses funds.
It is impossible that a user will execute a non-reverting batch without careful research on the batching system. To do that, he would need to exactly match one or more action codes with abi-encoded arrays of parameters of the right types.
My concerns on the batching system are not on users or integrators building a bad batch and losing their funds.
My concerns are that the batching system is complex, and there could be the chance that a batch could be built with a negative effect on the protocol or for other users. Since the Ladle has sweeping powers over the protocol, that would be a real issue. Such a batch has not been found.
So, to reiterate. The issue being brought up was brought up in the discord by myself, and it is a conscious trade-off we made of usability for flexibility. No undisclosed issue has been found.
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 contract does not enforce implicit constraints on batched operations in code, relying instead on documentation and external validation.
Impact
A batch that violates the implicit constraints could cause a transaction to fail or tokens to be locked or lost, affecting the protocol's functioning.
What the attacker needed
Ability to submit a batch directly; knowledge of operation encoding
The fix
The issue should be fixed by enforcing batch operation constraints explicitly in the code, for example with tracking counters or booleans, along with documentation and onboarding validation.
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 Ladle is a smart contract that lets users perform several actions in one batch. The contract assumes batches follow certain rules, like a deposit must come first and a withdrawal last, but it does not check these rules. If someone builds a batch that breaks the rules, the contract might misbehave and funds could get stuck.
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.