bug: ECDSA cosignature malleability allows unauthorized fillers to bypass exclusive fill rights in V2DutchOrderReactor#365
Open
chef-carb wants to merge 1 commit into
Conversation
…pass exclusive fill rights Raw `ecrecover` in `V2DutchOrderReactor._validateOrder` accepts both the canonical low-s signature and its malleable high-s counterpart. An attacker who observes a whitelisted filler's pending transaction in the mempool can derive the malleable cosignature without the cosigner's private key and front-run the fill during the exclusivity window, permanently consuming the Permit2 nonce and locking out the legitimate filler. Both POC tests pass against the unmodified contract, confirming the vulnerability. Note: unable to submit through Cantina due to a bugged KYC process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
V2DutchOrderReactor._validateOrderuses rawecrecoverto verify cosignatures. The secp256k1 curve allows two valid signatures for any message — a canonical low-s form and a malleable high-s form. Becauseecrecoveraccepts both, any party that observes a valid cosignature in the mempool can derive a second mathematically equivalent signature without access to the cosigner's private key.This breaks the exclusive filler access control mechanism.
Attack
fillerAas the exclusive fillerfillerAbroadcasts a fill transaction — the cosignature is visible in the mempool(r, secp256k1_order - s, v ^ 1)— O(1) arithmetic, no secret key neededfillerA's transaction reverts — permanently locked out of the fillWhen
exclusivityOverrideBps > 0, the attack succeeds outright. The swapper still receives correct output (at the override premium), but the designated filler's exclusive window is stolen.Vulnerable code
Recommended fix
Replace raw
ecrecoverwith OpenZeppelin'sECDSA.recover, which enforces the EIP-2 low-s constraint and reverts withECDSAInvalidSignatureSon high-s input:Additional benefits:
signer == address(0)check —ECDSA.recoverhandles it internallyPOC
Two Foundry tests are included in
test/reactors/V2DutchOrderReactorMalleability.t.sol:testPOC_MalleableCosignaturePassesValidation— shows that(r, s', v')derived from any observed valid cosignature passes_validateOrderwithout the cosigner's private keytestPOC_NonWhitelistedFillerFillsDuringExclusiveWindow— full end-to-end attack: a non-whitelisted filler front-runs the designated filler using a malleable cosignature, steals the fill, and permanently locks out the legitimate fillerBoth tests pass against the unmodified contract. After applying the fix, both revert with
ECDSAInvalidSignatureS.References
0x00000011F84B9aa48e5f8aA8B9897600006289Be