Reproduced Exploit
Nexus: DSRStrategy.deposit never approves DAI, so 1,000 DAI cannot reach sDAI
deposit calls sDAI.deposit(_value, address(this)) and does not approve DAI. sDAI moves DAI with transferFrom, so the call reverts. The strategy already holds 1,000 DAI from fund(), the quoted function has no idle-DAI withdraw, and the sDAI balance stays 0. Adding DAI.approve(sDAI, _value) before th…
Loss
1,000 DAI stuck in DSRStrategy. sDAI minted is 0
Chain
Ethereum
Category
logic
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: 44982-h-02-lack-of-approval-before-depositing-dai-into-dsr-contrac. Standalone Foundry PoC and full write-up: 44982-h-02-lack-of-approval-before-depositing-dai-into-dsr-contrac_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/logic/missing-allowance·vuln/dos/frozen-funds
Key info#
| Field | Value |
|---|---|
| Loss | 1,000 DAI stuck in DSRStrategy. sDAI minted is 0 |
| Vulnerable contract | DSRStrategy.deposit |
| 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 |
| Bug class | Missing ERC-20 approval before sDAI.deposit pulls DAI |
TL;DR#
deposit calls sDAI.deposit(_value, address(this)) and does not approve DAI. sDAI moves DAI with transferFrom, so the call reverts. The strategy already holds 1,000 DAI from fund(), the quoted function has no idle-DAI withdraw, and the sDAI balance stays 0. Adding DAI.approve(sDAI, _value) before the deposit mints 1,000 sDAI and leaves the strategy with no DAI.
Background#
Pashov Audit Group, Nexus security review dated 2024-11-29, finding H-02. The review's diff is one approval line in front of sDAI(DSR_DEPOSIT_ADDRESS).deposit. This reduction uses that function body and an sDAI mock whose deposit pulls DAI one-for-one, which is the Pot/sDAI shape the missing approval breaks.
The vulnerable code#
function deposit(uint256 _value) public returns (uint256) {
sdai.deposit(_value, address(this)); // @> VULN: no DAI.approve(sDAI) before deposit, so the pull reverts
return 100;
}
The report's fix:
function deposit(uint256 _value) public returns (uint256) {
+ IERC20(DAI_ADDRESS).approve(DSR_DEPOSIT_ADDRESS, _value);
sDAI(DSR_DEPOSIT_ADDRESS).deposit(_value, address(this));
return 100;
}
Root cause#
sDAI.deposit spends the caller's DAI allowance. The strategy is the caller and its allowance is 0, so every deposit reverts after the DAI has already been transferred into the strategy by a separate fund.
Preconditions#
- 1,000 DAI has been transferred into
DSRStrategy. depositis the only path that moves that DAI into sDAI. The quoted function does not send idle DAI back out.- No privileged role is required to call
deposit. It is public, as in the report.
Attack walkthrough#
- The depositor funds 1,000 DAI into the strategy.
deposit(1000)callssDAI.depositwith no approval.- sDAI's
transferFromreverts because the allowance is 0. - The strategy still holds 1,000 DAI. Its sDAI balance is 0.
- The control approves DAI,
depositreturns 100, and the strategy holds 1,000 sDAI.
Diagrams#
Impact#
1,000 DAI sits in the strategy and cannot be deposited into the DSR. No sDAI is minted, so the position earns nothing, and the quoted contract has no withdraw that returns the idle DAI. The control moves the same 1,000 DAI into 1,000 sDAI.
Remediation#
Approve DAI to the sDAI contract for _value immediately before deposit, as the review diff shows.
How to reproduce#
cd 44982-h-02-lack-of-approval-before-depositing-dai-into-dsr-contrac_exp
forge test -vv
test_exploit_deposit_reverts_and_dai_sticks asserts the revert, a 1,000 DAI balance, and a 0 sDAI balance. test_control_approve_mints_sdai asserts the approval path returns 100 and mints 1,000 sDAI.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/44982-h-02-lack-of-approval-before-depositing-dai-into-dsr-contrac.md
- Pashov review: https://github.com/pashov/audits/blob/master/team/md/Nexus-security-review_2024-11-29.md
- Quoted function:
DSRStrategy.deposit
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 44982-h-02-lack-of-approval-before-depositing-dai-into-dsr-contrac_exp (evm-hack-registry mirror).
- AuditVault finding: 44982-h-02-lack-of-approval-before-depositing-dai-into-dsr-contrac.
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.