EIP-712 SIGN_MODE_DIRECT signatures do not cover timeout, unordered, and fee granter/payer fields
Description
When a transaction is signed with SIGN_MODE_DIRECT using an EIP-712 signature (the path Web3 wallets such as MetaMask use to sign Cosmos transactions), the timeout_timestamp, unordered, Fee.Granter, and Fee.Payer fields are not covered by the signature. Anyone who sees the signed transaction before it is committed can change them, and the signature still verifies. Depending on the field and the chain's configuration, a deadline can be bypassed, a transaction can be resubmitted as unordered, or a fee can be shifted onto an existing fee allowance. The messages, fee amount, and signer cannot be changed. Transactions signed with standard Cosmos signatures are not affected.
Details
cosmos/evm's EIP-712 verification path (ethereum/eip712, decodeProtobufSignDoc and its legacy counterpart legacyDecodeProtobufSignDoc) decodes a protobuf SignDoc and converts it into EIP-712 typed data before verifying the secp256k1 signature. The typed data covers the messages, memo, chain ID, account number, sequence, fee amount, and gas limit. It does not cover body.timeout_timestamp, body.unordered, auth_info.fee.granter, or auth_info.fee.payer, and the existing guard that rejects fields not represented in the typed data (TimeoutHeight, ExtensionOptions, NonCriticalExtensionOptions) did not include them. Changing any of these four fields on a SIGN_MODE_DIRECT transaction signed via EIP-712 therefore leaves the EIP-712 hash unchanged, and the original signature remains valid. The messages, fee amount, and signer cannot be changed.
- Fee granter. If
Fee.Granteris set to an account with an existing allowance toward the signer,DeductFeeDecoratorcalls intox/feegrant, which validates the fee and messages against that allowance and deducts the fee from the granter, up to the allowance's limits. If no such allowance exists, the transaction is rejected. - Fee payer. If
Fee.Payeris changed, the transaction is rejected because cosmos-sdk requires the fee payer to sign it. - Timeout timestamp. A party holding the signed transaction can remove or extend its
timeout_timestamp, allowing it to be included after the deadline the signer set. For ordered transactions the account sequence is still covered by the signature, so the transaction can only be included while the signer's sequence still matches; once the signer submits any other transaction at that sequence, the held transaction can no longer be included. - Unordered. This only applies to chains that enable unordered transactions in
x/auth, which is disabled by default inevmd. Unordered transactions must be signed with sequence 0, do not increment the account sequence, and are deduplicated by(signer, timeout_timestamp). Because neitherunorderednortimeout_timestampis covered by the EIP-712 signature, on such chains a party holding an EIP-712-signed transaction with sequence 0 (any unordered transaction, or the first transaction sent from an account) can mark it unordered and choose a newtimeout_timestampwithin the chain's maximum TTL, and submit it again under a fresh nonce.
The SIGN_MODE_LEGACY_AMINO_JSON EIP-712 path is not affected: a non-empty value for any of these fields adds data that is not declared in the EIP-712 types, so typed-data encoding fails and the signature does not verify.
Patches
The fix extends the unsupported-fields guard in decodeProtobufSignDoc and legacyDecodeProtobufSignDoc to reject any sign doc that sets timeout_timestamp, unordered, Fee.Granter, or Fee.Payer. Transactions carrying these fields now fail EIP-712 verification instead of being verified against typed data that omits them.
Chain operators must upgrade to v0.6.4 or v0.7.4 (or later). After the fix, EIP-712-signed transactions that set timeout_timestamp, unordered, Fee.Granter, or Fee.Payer are rejected. Wallet users who need any of these (a transaction deadline, unordered submission, or feegrant-sponsored fees) must sign those transactions with a non-EIP-712 sign mode.
Workarounds
There is no configuration-only workaround. Chains that cannot upgrade immediately can add an ante decorator ahead of signature verification that rejects transactions setting any of these fields when they are signed by an ethsecp256k1 key.
The unordered impact can be mitigated on its own by disabling unordered transactions (authkeeper.WithUnorderedTransactions(false), the default in evmd). With unordered transactions disabled, the chain rejects any transaction marked unordered, so this field cannot be used to resubmit a signed transaction. Chains that never enabled unordered transactions are not affected by this part of the issue.
References
Credits
Originally reported through the Cosmos bug bounty program by sec-agents.
Please reach out to our security email, security@cosmoslabs.io to get further details, or via our bug bounty program immunefi.com/