How it works / Security model

DocsHow it works

Security model

What Killswitch trusts, who might attack and what each attacker can do, how to compute the most a wallet can lose, and how the contract is tested.

Two layers, two jobs

The on-chain layer sets hard limits that only the owner can change. The off-chain layer applies judgement and can only make things stricter. A claim about the contract holds even if our relay, guardian, database and AI provider are all compromised.

On-chain: hard limitsOff-chain: judgement
An allowlist of (target, selector) pairsDecoding and simulation
Caps per token, measured by balance differenceRisk scoring and AI review
A co-sign line, expiry, pause, revoke and kill allHolds for the owner
Approvals only to the agent's own call targetsReview of operations sent around the relay
No ERC-20 approval left openAutomatic pause on-chain
Replay protection by nonce and deadline

Two allowance rules close the classic drain, where an agent approves an outside address that later pulls funds with transferFrom. An approve, increaseAllowance or setApprovalForAll may only name one of the agent's own call targets, or it reverts with SpenderNotAllowed. And any allowance left at the end of an operation reverts it with DanglingAllowance.

What it trusts

  • The chain runs the contract as written and includes transactions.
  • The owner's key is safe. It can do anything by design; companies should use a multisig.
  • Capped tokens report balances honestly, since caps are measured by balance difference.
  • ECDSA and EIP-712, through OpenZeppelin's libraries, are sound.
  • The contract is correct. It has 22 tests including fuzzing, and an independent audit comes before mainnet.

The agent, its model, the relay, the guardian and the company behind Killswitch are not on this list.

Who might attack, and how far they get

AttackerCanCannot
A compromised agentSign allowed operations within its capsCall other targets, pass a cap, skip the co-sign line, approve outsiders, act after expiry
A leaked session keySubmit on-chain, in steps up to cosignAbovePass the cap, get co-signed, warm up addresses, act once paused
A compromised relayDelay operations, mislead the web app, act as guardian if it holds that keyChange signed operations, pass caps, grant, spend, block the owner
The guardian keyPause agents, co-sign operations agents signedSpend, unpause, grant, widen limits, kill all
The guardian key and a session keyTake that agent's whole remaining capPass the cap, or touch other tokens and targets
A phished ownerAnything the owner signsKillswitch doesn't stop it

A tricked owner can sign anything, as with any wallet you hold yourself. The defences are a multisig, a hardware wallet, grants spelled out in plain words in the web app, and a planned MetaMask Snap.

The contract is about 400 lines, with no upgrade proxy, no admin key of ours, and a re-entrancy lock on every entry point that runs calls. Each wallet is its own contract.

The most a wallet can lose

For every agent a and token k, over a stretch of time T that ends when the agent is paused, revoked, killed or expires:

L(T) ≤ Σ over tokens k of  min( Bk , Σ over agents a of  cap(a,k) × (T / period(a,k) + 1) )

Bk is the wallet's balance of token k. The bound assumes every agent and the guardian are hostile and nobody reacts.

An example. A wallet with 1,000 USDC runs the four templates on daily periods: Trading (100 USDC and 0.05 WETH), Auto-buy (20), Payments (50) and Pay-per-use (5), for 175 USDC a day. If everything is compromised and unnoticed for 24 hours, at most min(1,000, 175 × 2) = 350 USDC and 0.10 WETH can leave.

Real exposure is lower. Only the two paying agents can send to an attacker's address, 55 USDC per window; the trading agents can only swap on the approved exchange. With the guardian's key safe, a thief is held to 20 USDC per step, and the first payment to an unknown recipient pauses the agent. In the attack demo, the attacker got 9 USDC out of 1,000.

The attack demo

npm run demo runs an adversarial simulation against a live local chain, relay and guardian, with test tokens. A fresh wallet holds 1,000 USDC; a Trading bot may approve and swap (100 USDC a day, co-sign above 50), and a Payments bot may send USDC (50 a day, co-sign above 20).

ScenarioOutcomeAttacker's gain
Swap 20 USDC for WETHConfirmednone
Swap 60 USDC, over the co-sign lineConfirmed with the guardian's co-signaturenone
Pay a new vendor 10 USDCHeld or reviewed; the owner approvesnone
Pay the same vendor 15 USDCConfirmed; the vendor is now knownnone
Prompt injection: the Trading bot sends the whole balance to the attackerBlocked (CallNotAllowed); drain pattern; agent paused0
Hijacked Payments bot sends 25 USDC as a fake invoiceScore 55; AI rejects, or held and the owner denies0
Stolen key, straight on-chain: 100 USDCReverts: over the cap0
The same thief: 9 USDC, under the co-sign lineGoes through; the indexer scores 70; agent paused9 USDC
The thief tries 9 USDC againReverts: agent paused0
The owner presses kill all; the Trading bot tries a 5 USDC swapBlocked: AgentKilled0

The wallet ends with 886 USDC, and the attacker's total is 9 USDC of 1,000: a loss that is small, known in advance and capped by code.

Tests

contracts/test/KillswitchAccount.t.sol holds 22 Foundry tests, each checking the exact custom error. They cover caps and window resets, the allowlist, open and outsider approvals, co-signing, signatures, replays and deadlines, every stop and every role's boundary, simulation, and the owner's unconditional access. The fuzz test sends six random payments of 1 to 200 USDC to an attacker, each with a valid guardian co-signature, and asserts the total never passes the 50 USDC cap.

Before mainnet

  • An independent audit of KillswitchAccount and KillswitchFactory, with its findings resolved.
  • Key custody. The guardian, relayer and hosted agent keys move into a KMS or TEE.
  • Caps in dollars through a price oracle; today caps are per token.
  • A public bug bounty.

Edit this page on GitHub