Assessment reports>d3-doma>Threat Model>Function: pay(PaymentVoucher calldata voucher, bytes calldata signature)

Function: pay(PaymentVoucher calldata voucher, bytes calldata signature)

This function processes payment for off-chain orders using signed vouchers. It supports both ETH and ERC-20 token payments with signature verification and payment-ID replay protection.

Inputs

  • voucher.buyer

    • Control: Full.

    • Constraints: Must match msg.sender (checked via _verifyBuyerMatchesSender()).

    • Impact: Ensures only the designated buyer can execute the payment, preventing unauthorized payment execution.

  • voucher.token

    • Control: Full.

    • Constraints: N/A.

    • Impact: Specifies payment token (address(0) for ETH, ERC-20 address for tokens).

  • voucher.amount

    • Control: Full.

    • Constraints: Must match msg.value for ETH payments or be transferred from buyer for ERC-20.

    • Impact: Ensures the payment amount matches the voucher specification, preventing underpayment attacks.

  • voucher.voucherExpiration

    • Control: Full.

    • Constraints: Must be greater than the current block timestamp (checked via _verifyNotExpiredVoucher()).

    • Impact: Prevents execution of expired vouchers, ensuring time-sensitive payment conditions.

  • voucher.paymentId

    • Control: Full.

    • Constraints: Must be unique and not previously used (checked via usedPaymentIdHashes mapping).

    • Impact: Prevents replay attacks by ensuring each payment voucher can only be used once.

  • voucher.orderId

    • Control: Full.

    • Constraints: Included in signature hash but no direct validation.

    • Impact: Links payment to specific order for off-chain tracking and verification.

  • signature

    • Control: Full.

    • Constraints: ECDSA signature verification via _verifySignature() to ensure voucher was signed by an authorized signer.

    • Impact: Ensures voucher authenticity and prevents unauthorized voucher creation.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Zellic © 2025Back to top ↑