Skip to content

fix(escrow,trampoline): address V12 audit findings (COW-1272) - #40

Merged
jean-neiverth merged 9 commits into
mainfrom
jean/cow-1272-address-v12-audit-findings-for-escrow-and-trampoline
Aug 21, 2026
Merged

jean-neiverth merged 9 commits into
mainfrom
jean/cow-1272-address-v12-audit-findings-for-escrow-and-trampoline

Conversation

@jean-neiverth

@jean-neiverth jean-neiverth commented Aug 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Addresses the actionable findings from the V12 AI audit, after filtering out noise (see COW-1272 for triage rationale).

  • Bind sellToken and buyToken into the EIP-712 signature — both trade tokens are now signed proposal fields (nine-field ProposalData struct), preventing a signature from being reused with an unrelated token pair (F-234212). The separate _sellToken/_buyToken calldata parameters are removed from execute().
  • Cap cooldownPeriod to 30 days — prevents overflow in withdrawalRequestedAt + cooldownPeriod arithmetic (F-234217)
  • Block OPERATOR_ROLE / DEFAULT_ADMIN_ROLE renunciation while paused — prevents permanently stuck pause that would lock user funds (F-234221)
  • Validate _adminTransferDelay — rejects values > type(uint48).max / 2 to prevent OZ timestamp overflow that disables admin rotation (F-234109)

One finding deferred for separate work:

  • Requiring minBuyAmount > 0 (F-234211)

Test plan

  • All existing tests pass
  • forge fmt --check clean
  • Boundary tests for cooldownPeriod (constructor + setter, at limit and limit+1)
  • Paused renounceRole tested for both protected roles and one allowed case
  • Token-field signature binding tested (mutating sellToken/buyToken each reverts with Trampoline_InvalidSignature)
  • Verify deployment script values remain within new bounds

The _sellToken parameter was already unnamed in the implementation and
served no purpose. Removing it simplifies the interface and reduces
calldata size.

Addresses V12 audit finding F-234211/F-234212 cleanup.
Reject cooldown values exceeding 30 days in both the constructor and
setCooldownPeriod to prevent overflow in the withdrawal timestamp
arithmetic (withdrawalRequestedAt + cooldownPeriod).

Addresses V12 audit finding F-234217.
Override renounceRole to revert for OPERATOR_ROLE and DEFAULT_ADMIN_ROLE
when the contract is paused, preventing a permanently stuck pause that
would lock user funds.

Addresses V12 audit finding F-234221.
Reject admin transfer delays exceeding type(uint48).max / 2 to prevent
the OZ AccessControlDefaultAdminRules timestamp arithmetic from
overflowing, which would permanently disable admin rotation.

Addresses V12 audit finding F-234109.
@linear-code

linear-code Bot commented Aug 19, 2026

Copy link
Copy Markdown

COW-1272

…COW-1272)

Add both trade token addresses to PROPOSAL_TYPEHASH and the Proposal
struct so signatures cannot be reused with an unrelated measurement
token. The separate _buyToken execute() parameter is removed —
_proposal.buyToken is used for the balance-delta check instead.

@yvesfracari yvesfracari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Please address the inline findings in this PR.

Comment thread src/contracts/Escrow.sol
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) AccessControlDefaultAdminRules(_adminTransferDelay, _admin) {
if (_adminTransferDelay > type(uint48).max / 2) revert Escrow_InvalidAdminTransferDelay();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would - Could changeDefaultAdminDelay bypass this constructor-only check? A near-max delay may overflow OZ's scheduling arithmetic.

Comment thread src/contracts/Trampoline.sol
Comment thread src/contracts/Escrow.sol
Comment thread src/contracts/Escrow.sol
Comment thread src/interfaces/ITrampoline.sol
- Add sellToken/buyToken signature-binding tests (comment 2)
- Add cooldown period boundary tests for constructor and setter (comment 3)
- Add paused renounceRole tests for protected and allowed roles (comment 4)
- Fix "seven fields" → "nine fields" in PROPOSAL_TYPEHASH doc comment (comment 5)
@jean-neiverth
jean-neiverth merged commit b132db9 into main Aug 21, 2026
3 checks passed
@jean-neiverth
jean-neiverth deleted the jean/cow-1272-address-v12-audit-findings-for-escrow-and-trampoline branch August 21, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants