Killua
← All parts Bug Hunting Field Guide · Part 4 of 8

Signature validation: trust nothing you didn't derive

Killua · 7 min read

Every signature check answers two questions: who signed? and is that who I trust? The bugs in this guide each delete one of those answers.

This guide covers two closely related bugs. In the first, a permit never asks the second question. In the second, a wallet lets the attacker supply the answer.

The bug in one sentence

ecrecover is a calculator, not an authenticator. For a well-formed (v, r, s) it returns some address, and address(0) when recovery fails. So a check that stops at “not zero”, or compares against an expected signer the attacker picked, accepts signatures nobody ever made.

A real case: Lixir vault tokens (Ethereum, June 2026)

Lixir’s vault tokens shipped a hand-written permit, the ERC-2612 approve-by-signature flow. The correct version, as in OpenZeppelin’s ERC20Permit, ends with two conditions:

address recovered = ecrecover(digest, v, r, s);
require(recovered != address(0)); // reject failed recovery
require(recovered == owner);      // and bind it to the actual owner

Lixir’s version kept only the first line. Any well-formed signature, made with no private key at all, recovered to some address, passed the non-zero check, and granted a max allowance over any holder’s tokens.

The attacker reused one constant signature across 82 holders. They forged allowances everywhere, then burned vault shares through the vault’s own withdraw functions to take the underlying: about 2.6 ETH, 4,478 USDC, 3,610 USDT and 24,183 LIX.

The habit this teaches: at every ecrecover call, read the next five lines and look for the == owner comparison. If it isn’t there, that’s the whole bug.

The math: one signature, many victims

Forging costs nothing extra per victim. You pick one signature once. The payoff grows with the number of holders:

profit = Σ over holders ( min(balance, forged allowance) ) − gas

There’s no per-victim work, no private key and no flash loan. The same bytes are reused because nothing ties them to anyone.

The attack, step by step

Step What happens What the check sees
1 Pick a constant (v, r, s). Sign nothing. —
2 Call permit(holder, attacker, max, ..., v, r, s) for each holder recovered != 0 passes
3 An Approval(holder → attacker, max) event fires No == owner check stops it
4 Withdraw from each holder’s position using the forged allowance Forged allowance, real balance
5 Repeat across every holder Same bytes every time

Why it worked: three facts

  1. Authority comes from recovery. The permit grants spending power based on ecrecover’s output.
  2. No identity binding. It checks for non-zero only, never recovered == owner.
  3. The grant can be spent. The forged allowance reaches withdraw paths that move real value.

Fact 2 is a one-clause bug. require(recovered != address(0) && recovered == owner) would have stopped every call in this incident. That’s why reading a few lines past every recovery site pays off.

Two patterns in one family

Pattern A, the missing owner check (Lixir). Signature-based authority, a comparison that stops at the zero sentinel, and an authorization that moves value.

Pattern B, the attacker-named verifier (Sodium, Lumi, Mure, below). The signer’s address travels inside the caller’s bytes and gets “verified” with EIP-1271 against a contract the attacker controls. Secondary checks compare one attacker-supplied value with another. The real proof only runs later, after billing has already happened.

Here the comparison exists. Its expected signer is just attacker-chosen. So it’s not enough to find a comparison. You have to ask where the expected signer comes from.

How to hunt for it

Lookalikes that are safe, and why

Fixes that work

The same bug in other clothes

Test yourself

  1. A hand-written permit checks only that the recovered address is non-zero. Verdict? Critical. One constant signature forges every holder’s allowance.
  2. The comparison is there: recovered == admin. Safe? Not until you’ve checked admin can’t be zero or attacker-set.
  3. A wallet verifies EIP-1271 against input-named signers but caps gas at the base fee. Severity? Reduced, not cleared. The cap closes the billing channel, but forged execution, as with Lumi, is unaffected.
  4. The digest skips the nonce and deadline but binds owner and amount. Which bug is this? Not this one. That’s replay (part 6 of this series): a genuine signature with too broad a scope. Keep the two apart: who signed versus what the signature covers.

Recap