# Self-attestation module status bypass

Auth that asks msg.sender to vouch for itself, paired with unconstrained caller-supplied targets or calldata

_Area: Smart contract access control and control flow. Seen in 2 disclosed reports; latest 2026-10-01. Updated 2026-11-17._

## How it works
A privileged contract decides whether the caller is allowed by asking the caller about itself: `ISafe(msg.sender).isModuleEnabled(address(this))`, `isWhitelisted`, `supportsInterface`, or any similar query where the answer comes from the untrusted party. The assumption that breaks is that the caller's answer reflects real, externally-verified state. A one-line fake contract returns `true` and passes. The same shape appears when a contract executes logic in the wrong identity context: deferred fields, closures or generated entry points run under the invoker rather than the definer, so attacker-planted logic inherits a privileged user's rights [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md)[E2](https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md)[E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md).

## Where it shows up
- Auth checks of the form `IThing(msg.sender).isX(...)` or `supportsInterface` on the caller, with no independent registry lookup [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md)
- Privileged functions that take a caller-supplied target address and caller-supplied calldata, then `approve` + raw `call` with no allowlist [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md)
- Macro-generated entry points that emit `<Type>::func()` instead of `<Type as Trait>::func()`, letting a same-named inherent function shadow the trait's auth-checked body [E2](https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md)
- Computed/future fields, stored closures, defined APIs or events evaluated at query time under the invoking user's context rather than the definer's [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md)
- Any place where "who defined this" and "whose permissions run it" can diverge

## How to review
State the invariant: every privileged action must be authorized against state the caller cannot forge — a registry the contract itself reads, a stored owner/definer identity, or a signature over the actual call. Check that (a) no auth decision is sourced from `msg.sender`'s own answer about itself [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md); (b) outbound calls go to an allowlisted target with constrained selectors, not arbitrary calldata [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md); (c) generated code uses fully-qualified trait paths so name collisions cannot rebind to unchecked inherent functions [E2](https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md); (d) deferred evaluation captures the definer's identity, not the invoker's [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md).

## How finders spotted it
- Read verified adapter source and noticed `_start` trusted `msg.sender`'s own `isModuleEnabled()` reply, then saw `_swap` raw-call an unconstrained caller-supplied router — combined into a confused deputy against any Safe that enabled the module [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md)
- Compared the macro's generated call form against Rust's name-resolution rule that inherent functions win over trait functions, spotting the silent rebind [E2](https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md)
- Asked whose privileges evaluate a future/closure at query time versus who defined it, exposing the definition-vs-execution context gap [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md)

## Variants seen
- Self-attestation of module-enabled status plus unconstrained router call, chained into a multi-Safe drain [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md)
- Codegen name collision dropping trait auth checks in generated Wasm entry points [E2](https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md)
- Confused deputy via deferred fields/closures running as the privileged invoker [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md)

## Impact and severity
E1 let a fake Safe force real victim Safes to drain weETH collateral, escalated by chaining permissionless debt repayment, two module-driven drains, a swap and a flash repayment in one atomic tx — critical, scaling to every Safe that enabled the module [E1](https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md). E3 gives full root-owner takeover from a low-privilege write; read-only touch yields limited DoS or exfiltration [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md). E2 bypasses trait auth checks in exported entry points [E2](https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md).

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **surrealdb (rust)** < 2.5.0, fixed in 2.5.0: SurrealDB Affected by Confused Deputy Privilege Escalation through Future Fields and Functions. Report: https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md. Fix: https://github.com/surrealdb/surrealdb/commit/f515c91363ee735aa1bc08580d9e7fa0de6e736f

## Evidence
- E1: https://bugbountylibrary.com/r/dhl%3A20261001-flashloopadapter.md
- E2: https://bugbountylibrary.com/r/ghsa%3AGHSA-4chv-4c6w-w254.md
- E3: https://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v.md
