Reproduced Exploit
Nexus: onlyDeposit reverts for both deposit contracts
onlyDeposit uses msg.sender != depositETH || msg.sender != depositUSD. Every address fails at least one of those comparisons, including the two deposit contracts the modifier exists to allow. Both bridge calls revert. Messaging.sent stays 0, so the destination never sees a deposit. Replacing || wit…
Loss
sendMessage reverts for DepositETH and DepositUSD. No bridge message is delivered. sent stays 0
Chain
Ethereum
Category
access-control
Date
Nov 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 44981-h-01-incorrect-access-control-logic-in-onlydeposit-modifier. Standalone Foundry PoC and full write-up: 44981-h-01-incorrect-access-control-logic-in-onlydeposit-modifier_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/access-control/broken-logic·vuln/logic/wrong-condition
Key info#
| Field | Value |
|---|---|
| Loss | sendMessage reverts for DepositETH and DepositUSD. No bridge message is delivered. sent stays 0 |
| Vulnerable contract | Messaging.onlyDeposit |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-11 |
| Compiler | solc 0.8.27, cancun, via IR |
TL;DR#
onlyDeposit uses msg.sender != depositETH || msg.sender != depositUSD. Every address fails at least one of those comparisons, including the two deposit contracts the modifier exists to allow. Both bridge calls revert. Messaging.sent stays 0, so the destination never sees a deposit. Replacing || with && lets either deposit contract through and still rejects a stranger.
The vulnerable code#
modifier onlyDeposit() {
attempts++;
if (fixedMode) {
if (msg.sender != depositETH && msg.sender != depositUSD) revert NotDepositContract(msg.sender);
} else if (msg.sender != depositETH || msg.sender != depositUSD) {
revert NotDepositContract(msg.sender); // @> VULN: OR is true for every caller, including both deposit contracts
}
_;
}
The review's change:
- if (msg.sender != depositETH || msg.sender != depositUSD) revert NotDepositContract(msg.sender);
+ if (msg.sender != depositETH && msg.sender != depositUSD) revert NotDepositContract(msg.sender);
The same OR is present on Messaging and MessagingBera.
Root cause#
An address cannot equal two different deposit contracts at once. If the caller is DepositETH it is not DepositUSD, so the second comparison is true and the modifier reverts. The same thing happens for DepositUSD. A stranger reverts too, which is why a quick test that only uses an unauthorized caller looks fine.
Preconditions#
setDepositshas recorded the two deposit contracts.- Each deposit contract calls
sendMessagefrombridge. That call is the cross-chain announcement. - The destination id used here is 101, which the body would accept if the modifier passed.
Attack walkthrough#
- DepositETH calls
bridge. The escrow line runs, thensendMessage. - The modifier increments
attemptsand hits the OR.NotDepositContractreverts the call. - The low-level call returns false.
sentis still 0 because the revert rolled the attempt back. - DepositUSD takes the same path and also reverts.
runrequires both rejections andsent == 0.- The control with
&&delivers both messages and leavessentat 2. A stranger still reverts.
Diagrams#
Impact#
The bridge cannot announce a deposit. Every call from the authorized deposit contracts reverts, so the destination credit stays 0. Users cannot complete the messaging step the deposit contracts exist to perform. This is a liveness break of sendMessage, not a permissionless drain. The fixed modifier shows the two intended callers succeed.
How to reproduce#
cd 44981-h-01-incorrect-access-control-logic-in-onlydeposit-modifier_exp
forge test -vv
test_exploit_both_deposit_contracts_are_rejected asserts both bridges revert and sent is 0. test_control_and_lets_either_deposit_contract_send asserts both messages are delivered and a stranger still reverts.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/44981-h-01-incorrect-access-control-logic-in-onlydeposit-modifier.md
- Pashov review: https://github.com/pashov/audits/blob/master/team/md/Nexus-security-review_2024-11-29.md
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 44981-h-01-incorrect-access-control-logic-in-onlydeposit-modifier_exp (evm-hack-registry mirror).
- AuditVault finding: 44981-h-01-incorrect-access-control-logic-in-onlydeposit-modifier.
Alerts & third-party analyses
These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.