Why a hook cannot tell it is being probed
To cheat Sworn a hook would have to answer the probe honestly and the execution dishonestly, which means telling them apart. Here is everything it could try.
tx.gasprice, tx.origin, block.*- The probe runs in the same transaction. Every one of these is identical.
msg.sender, call depth, calldata- Probe and execution go through the same external self-call. The
probing flag is read only after the last externally observable call. gasleft()- Both get the same stipend, enforced against EIP-150’s 63/64 rule.
- A counter in storage
- The probe reverts, so its own bookkeeping rolls back with it.
- A counter in transient storage
- EIP-1153 slots do not survive the revert either.
- Refusing to be probed
- A reverting candidate is skipped, and the swap settles through another.
A hook that wants to overcharge you has to overcharge the probe by the same amount, at which point Sworn routes around it and the hook earns nothing.
Twelve attacker capabilities, each with a working fixture in ToxicHooks.sol that tries the attack and fails.