DeFi Security AllianceRequest an audit
Menu

EVM patterns

ERC20 Permit: ERC2612 Allowances and Application Authority

A permit grants a token allowance. The application must separately authorize the action using it. ERC20 permit security therefore requires both tolerant handling of already submitted signatures and a verified relationship between the funding owner and the beneficiary.

A metal permission card crossing a blue frame beside a token routing switch, separating allowance from application authority.

Key facts

Original execution
48 local EVM cases, 3 routes, 4 signature states, 2 callers, 2 prior allowances
Bound application routes
Strict route succeeded 2/16. Tolerant route 6/16
Unsafe application fixture
6 other-caller cases assigned credit from the holder's funds
Pinned implementation
OpenZeppelin Contracts 5.4.0 with 24 unchanged imported files
Scope
Credit assignment tested. No withdrawal or realized loss measured

Read the signed allowance before interpreting the action

A holder signs permission for a deposit contract to spend tokens. Someone else submits that signature first. The token records the allowance, but the holder's combined deposit transaction can now fail when it tries to submit the same permit again. No signature forgery is needed. This illustrative sequence follows directly from a reusable submission route paired with a single-use nonce.

ERC20 permit security concerns both the signed allowance and the application consuming it. The Final ERC2612 standard adds signed approval to ERC20. A successful permit sets an allowance, advances the owner's nonce and emits Approval. It does not transfer funds. Nor does it sign every instruction that a deposit, swap or payment application might attach to that allowance.

The signed message has a precise scope. Read these fields together with the domain before asking whether the application can perform an action:

owner
The address granting permission over its tokens.
spender
The address receiving the allowance. A deposit contract can be the spender while a different account submits the transaction.
value
The allowance being established, expressed in the token's integer units.
nonce
The owner's current permit counter, included in the signed message even though the standard function does not take it as a separate argument.
deadline
The latest block timestamp at which the signed permit may be accepted.

The EIP712 domain supplies context such as chain and verifying contract. Inspect the actual token's domain name and version rather than borrowing them from a different deployment. The pinned implementation used below constructs its separator with the current chain identifier and contract address. Typed data encoding does not supply application replay protection by itself.

A beneficiary, minimum swap output or application-specific deposit instruction is absent from the standard permit message. An interface that displays a friendly action description still needs an authorization mechanism matching that description. The token checks the message it receives. It cannot infer an additional instruction from the surrounding screen.

What 48 local EVM cases actually did

Method

DeFiSec executed a complete fixture grid on . Each case deployed a fresh token and a fresh application. Real typed-message signatures were produced from a fixed test key and checked by the unchanged OpenZeppelin implementation. These are executed EVM observations, with deliberately limited application code.

Population
48 cases: 3 application modes, 4 signature states, 2 caller identities and 2 prior allowance states. Each mode has 16 cases. No rows were excluded.
Application modes
A strict caller-bound permit followed by a deposit. A caller-bound route that catches permit failure. An intentionally unsafe tolerant route accepting a supplied owner while crediting the caller.
Signature states
Fresh at its deadline, already submitted, expired or signed for another spender. The other-spender signature is submitted to this application's spender argument, making verification fail.
Balances and permission
The holder starts with 100 raw units. The application attempts to pull 40 and credit its caller by 40. Prior allowance is either 0 or 40. The second caller has no tokens or approvals of its own.
Clock and code
Block timestamp 1000. Deadline 1000 except the expired signature's 999. OpenZeppelin Contracts 5.4.0, Solidity 0.8.36, Forge 1.5.1, Cancun, optimizer enabled and compilation through the intermediate representation.
Source integrity
The official package archive passed its published SHA512 integrity check. Its 24 required Solidity files were extracted unchanged.

The repository retains seo/research/erc2612-permit-security-2026-11-16/PermitMatrix.t.sol, measurement.py and measurement.json, including raw observations, versions and hashes. These repository paths are not public download links. A second execution reproduced every row. Separate branch and conservation checks verified all 48 outcomes.

Results

Application outcomes in the complete local grid, observed . Each row has the same 16 inputs.
Application routeSucceededRevertedOther caller credited
Strict, caller bound2140
Tolerant, caller bound6100
Tolerant, supplied owner1246

The tolerant bound route completed more intended owner calls than the strict route. Its success count alone does not establish a general safety score. Removing the owner binding increased successful calls again, including 6 cases that funded another caller's credit from the holder's balance. The defect is in our deliberately unsafe application fixture, not an OpenZeppelin vulnerability.

Selected fixture rows. Prior and remaining allowance are holder-to-application values. Nonce is read after the application call.
Route and callerSignaturePrior allowanceOutcomeCaller creditNonceRemaining allowance
Strict bound, ownerAlready submitted0Reverted0140
Tolerant bound, ownerAlready submitted0Succeeded4010
Tolerant bound, ownerExpired40Succeeded4000
Tolerant bound, ownerExpired0Reverted000
Tolerant unbound, otherFresh0Succeeded4010
Tolerant bound, otherFresh40Reverted0040

All 20 successful rows left the holder with 60 units, the application with 40 and the caller with 40 units of application credit. The 28 rejected application calls retained the holder's 100 units and no credit. For already submitted signatures, the earlier permit had established allowance and nonce before the attempted deposit. A later deposit revert did not erase that earlier state. A failed permit's nonce update within the rejected call did roll back.

Limits

  • No public network, fork, transaction ordering probability or gas benchmark was measured.
  • The application only pulls tokens and assigns credit. There is no withdrawal implementation, so the credit error is not a measurement of realized theft.
  • Only this library version, exact finite allowance and these sequential nonce signatures were executed. Contract-wallet signatures, DAI permits and Permit2 remain outside the grid.
  • Production tokens with fees, callbacks or custom upgrades need their own accounting and authorization tests.

Bind the funding source and the deposit credit

The unsafe fixture accepts a holder address supplied by anyone and pulls that holder's tokens into the application. It then credits the transaction caller. A valid permit for the application supplies the token-level allowance, but it does not authorize this beneficiary assignment. Both checks can look locally reasonable while their combination assigns the wrong account a balance.

For a direct self-service deposit, OpenZeppelin's permit security considerations bind the funding owner to msg.sender. The same account supplies the ordinary action authority. Merely comparing the supplied owner with the signer recovered by the token does not resolve the beneficiary question: those addresses can match while an unrelated caller still chooses the application credit.

Choose the application authority from the actual call context. These are review criteria beyond the fixture grid.
ContextFunding authorityRequired evidence
Direct owner depositAuthenticated caller funds its own actionThe same actor determines the token source and the accepted credit policy
Relayed application actionSeparately authenticated owner instructionThe instruction binds beneficiary, action parameters and its own replay boundary
Intentional gift depositAuthorized payer chooses a permitted beneficiaryThe gifting rule is explicit. A third party cannot reinterpret an unrelated permit

Relaying changes the model. The transaction submitter may be a service rather than the token holder, so replacing a supplied owner with the raw caller can break a legitimate relay design. Authenticate the application request first. A trusted-forwarder integration also needs the effective sender and forwarder trust checks. A permit's arbitrary submission route does not create that trust.

Allowance and application authority meet at the deposit Token permit validation establishes a spender allowance. Independently authenticated application instructions establish the funding actor and beneficiary. Both feed the deposit, whose actual receipt and credited account must agree with the application policy. Token signature and allowanceOwner, spender and amount Application authorizationPayer, beneficiary and action Pull the permitted fundsApply the authorized action Check actual receiptReconcile the credit
A deposit joins two independent permission paths before producing an application balance.
  1. Read the token's signed allowance independently from the application instruction.
  2. Establish who can authorize the payer, beneficiary and requested action in the actual calling context.
  3. After the transfer, reconcile the received assets with the credit assigned under that policy. A valid token signature cannot replace this relationship.

Handle used nonces without accepting a failed action

Anyone can submit the standard permit. Its current owner nonce can be consumed before a combined application call executes. In our already-submitted rows, the earlier submission succeeds and establishes the intended allowance. Repeating the signature inside a strict deposit then fails verification against the advanced counter. This is an ordering failure in the combined workflow, even though the token enforced replay protection correctly.

The documented tolerant pattern attempts the permit and then relies on an independently authorized token transfer. Here is its narrow shape for a direct owner-funded action. The surrounding application still needs its own state and accounting controls:

Caller binding and a checked token pull remain necessary when a permit failure is tolerated.
try token.permit(msg.sender, address(this), value, deadline, v, r, s) {
} catch {
}
IERC20(address(token)).safeTransferFrom(msg.sender, address(this), value);
// Apply the separately authorized application action.

Catching an exception does not validate the rejected signature. The expired owner signature succeeded as an application deposit only when the application already had enough allowance. Without that allowance, the same tolerant route reverted at the token pull. Preserve that distinction in telemetry: signature accepted, transfer completed and application action recorded are different observations.

The deadline has a similarly narrow role. ERC2612 allows submission when block time is less than or equal to the deadline. Our fresh positive controls executed at equality. OpenZeppelin 5.4.0 rejects when block.timestamp > deadline. An established allowance has no standard ERC2612 expiry merely because the permit's deadline passes. A wallet or front end can impose a stricter submission margin, but that local policy is distinct from the token's boundary.

When investigating ERC2612InvalidSigner, reconstruct the actual domain, spender, amount and current owner nonce. A signature for another spender fails even though its cryptography was correctly produced for that other message. For ERC2612ExpiredSignature, compare timestamps in the transaction's execution context. Do not treat every error as evidence that another party submitted first.

Pending signatures also share a sequential counter for each owner in this implementation. Signatures made against the same current nonce compete for that position. A later-nonce signature cannot skip the required current value. Read nonces(owner) from the relevant token rather than substituting the account's transaction nonce. General signature replay controls remain a separate review layer.

Match the token and wallet permit scheme

A function named permit is insufficient evidence of a compatible message. Check the deployed implementation and its ABI, then test the actual wallet route. The same user-facing approval button can conceal different on-chain permission systems.

Source-derived compatibility boundaries, inspected . Only the first route was executed in this study.
RouteRelevant differenceIntegration consequence
Pinned ERC2612 implementationECDSA signer recovery with the current owner nonceMatch the token domain and split signature arguments
DAI-style permitBoolean allowed and expiry change the signed messageUse its actual interface. Replacing a field label is insufficient
Permit2A separate contract exposes SignatureTransfer and AllowanceTransferReview its token approval layer and selected mechanism independently
Contract-wallet fundingERC1271 signature validation is a separate capabilityProvide a supported authorization route without assuming ECDSA recovery invokes the wallet

The Permit2 overview describes its two mechanisms. Its revocation and nonce behavior must not be inferred from this ERC2612 grid. Use the separate Permit2 permission and revocation guide. DAI's message differences are explicitly documented in the ERC2612 standard's compatibility discussion.

The pinned token recovers a signer with ECDSA.recover. It does not call isValidSignature on a holder contract. That implementation boundary motivates an ordinary approved-transfer entrypoint where appropriate, rather than a universal claim that contract wallets cannot participate in token applications. Review the wallet-specific path through ERC1271 signature validation.

SafeERC20.safeTransferFrom handles transfer call and return behavior. It cannot prove that an application assigned a beneficiary correctly. A successful helper call also leaves implementation-specific accounting questions. Fee-charging tokens, for example, need a tested relationship between actual receipt and minted credit. Our ordinary token fixture does not exercise those behaviors.

An upgradeable token adds another reason to pin implementation evidence. A front end can keep the same token address while different logic handles a later request. The fixture does not deploy a proxy or simulate an upgrade. Record which implementation was inspected and repeat the negative controls after a relevant change, including any change to domain construction or transfer accounting. A passing result for the library fixture does not certify a deployed wrapper.

Gasless approval describes who submits the approval transaction. Someone still submits an on-chain transaction and pays its execution cost. An unavailable relay can withhold a signature. A bounded deadline limits that submission option. Keep a usable supported path when the optional signing route is unavailable.

Make authorization evidence part of the release

Review the token and application together at the revision being shipped. A permit test that checks only the nonce and allowance can miss the credit assignment. Conversely, rejecting every reused signature can make an intended deposit unnecessarily fail even after its allowance was correctly established.

  1. Record the chain, token address, application address and source revision. Capture the token's domain and permit interface from that deployment.
  2. Run positive controls for the intended funding actor, beneficiary and amount. Include the direct approved-transfer entrypoint and every supported wallet context.
  3. Change the domain, spender, nonce and deadline independently. Verify both the permit result and the complete application's resulting state.
  4. Submit the permit separately before the combined action. Confirm that the supported fallback preserves caller authority and still rejects insufficient allowance or balance.
  5. Attempt to fund an unrelated caller's credit with another holder's signature or existing allowance. The application's documented authorization rule must decide that case.
  6. Reconcile asset receipt, credit and failure rollback, including any supported token fees or callbacks. Record the exact negative controls that establish each claimed boundary.

Permit also inherits the allowance replacement ordering concern. Setting a new signed allowance does not erase spending that happened before that update. Use the ERC20 allowance replacement analysis when an integration changes an existing spending limit. Prefer a limit matching the intended operation where the product permits it, and inspect any residual permission after the action.

An external review can evaluate those artifacts against a defined scope. The Pharos Production member profile is a provider reference. Evidence from a review still needs the actual token, application and tested revision. The security tools hub helps choose supporting checks without converting a detector result into an authorization proof.

Apply the model to a fresh case: an authorized relay submits a deposit whose permit was already used. The decisive question is whether the relay's separately authenticated request still authorizes this payer and beneficiary. If it does, existing allowance may support the checked transfer. If the only evidence is the token permit, the application's action authority remains unproven.

Frequently asked questions

Does approve zero invalidate an unsubmitted ERC2612 permit?

Not by itself in the inspected implementation. ERC20 approve changes allowance without consuming the permit nonce. A still valid signature using the current nonce can later establish the signed allowance. Review signature invalidation through the actual token implementation. A transaction changing allowance is a different operation.

Can the ERC2612 permit owner be the zero address?

No. The standard explicitly excludes the zero owner. Signature validation must not turn a failed recovery into permission for the zero address. This is a source-derived requirement, not an additional case in the executed grid.

Will the pinned token accept an equivalent high s signature?

The OpenZeppelin 5.4.0 ECDSA helper rejects high s signature values. Its canonical-signature check is implementation evidence, not a claim that the experiment exercised malleability or every ERC2612 implementation applies the same helper.

Comments

0

    Leave a comment

    Share a question or observation about this article.

    10 to 3,000 characters.