<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg" -->

---
title: Solving Damn Vulnerable DeFi V4: Level 2- Naive Receiver
description: A walkthrough of solving the 'Naive Receiver' challenge (Level 2) in Damn Vulnerable DeFi V4. The exploit combines an access control flaw in...
canonical: https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Solving Damn Vulnerable DeFi V4: Level 2- Naive Receiver | daily.dev
og:description: A walkthrough of solving the 'Naive Receiver' challenge (Level 2) in Damn Vulnerable DeFi V4. The exploit combines an access control flaw in...
og:url: https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg
og:image: https://api.daily.dev/og/posts/sGR6y88vg.png
og:image:alt: Solving Damn Vulnerable DeFi V4: Level 2- Naive Receiver
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Solving Damn Vulnerable DeFi V4: Level 2- Naive Receiver

**[Coins Bench](https://daily.dev/sources/coinsbench)** · 3 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of solving the 'Naive Receiver' challenge (Level 2) in Damn Vulnerable DeFi V4. The exploit combines an access control flaw in FlashLoanReceiver's onFlashLoan function (ignoring the initiator parameter) with a meta-transaction spoofing vulnerability in NaiveReceiverPool's _msgSender() implementation, allowing an attacker to drain 10 WETH from a user via forced flash loan fees and then withdraw the pool's remaining funds by forging the last 20 bytes of msg.data to impersonate the deployer through the BasicForwarder. Full Foundry proof-of-concept code is included, batching 10 flash loan calls plus a spoofed withdrawal into a single multicall executed via a signed forwarder request.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://coinsbench.com/solving-damn-vulnerable-defi-v4-level-2-naive-receiver-750d85959ddc>

## Questions this post answers

### How does the access control vulnerability in the Damn Vulnerable DeFi Naive Receiver flash loan work?

The onFlashLoan function in FlashLoanReceiver.sol ignores its initiator address parameter, so it never verifies who actually triggered the flash loan. This lets an attacker repeatedly call flashLoan on behalf of a victim, forcing them to pay the fixed 1 WETH fee per call without their consent, draining 10 WETH across ten forced flash loans.

_Developers auditing flash loan contracts can find similar access control writeups curated on daily.dev._

### How can msg.sender spoofing through a trusted forwarder be exploited in a Solidity contract?

In NaiveReceiverPool, the _msgSender() override trusts msg.data's last 20 bytes as the real sender whenever the call comes from a designated relayer, instead of properly verifying the caller. An attacker can craft calldata through the trusted BasicForwarder with any address appended as the final 20 bytes, impersonating that account to call functions like withdraw on its behalf.

_Teams building meta-transaction relayers can track exploit patterns like this via daily.dev when hardening contract security._

## Similar posts on daily.dev

- [Damn Vulnerable DeFi Challenges 2 Naive receiver Walkthrough](https://daily.dev/posts/damn-vulnerable-defi-challenges-2-naive-receiver-walkthrough-yxvr17ys9) · Coins Bench · 0 upvotes · 0 comments
- [Solving Damn Vulnerable DeFi V4: Level 4- Side Entrance](https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-4--side-entrance-klhs1n1t1) · Coins Bench · 0 upvotes · 0 comments
- [Solving Damn Vulnerable DeFi V4: Level 3- Truster](https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-3--truster-txk8enrbt) · Coins Bench · 0 upvotes · 0 comments
- [Solving Damn Vulnerable DeFi V4: Level 7- Compromised](https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-7--compromised-lgnp95eei) · Coins Bench · 0 upvotes · 0 comments
- [Solving Damn Vulnerable DeFi V4: Level 9- puppetV2](https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-9--puppetv2-prluwyee1) · Coins Bench · 0 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#smart-contracts](https://daily.dev/tags/smart-contracts), [#solidity](https://daily.dev/tags/solidity), [#defi](https://daily.dev/tags/defi)

[View this post on daily.dev](https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Solving Damn Vulnerable DeFi V4: Level 2- Naive Receiver","url":"https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg"},"datePublished":"2026-08-28T18:51:26.695Z","dateModified":"2026-08-28T18:51:52.070Z","description":"A walkthrough of solving the 'Naive Receiver' challenge (Level 2) in Damn Vulnerable DeFi V4. The exploit combines an access control flaw in...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0068995ccd03ff1f03b5b8e861a042cb?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0068995ccd03ff1f03b5b8e861a042cb?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Coins Bench","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Coins Bench","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ba340d3c8caa4c2586911332928e24d9","url":"https://daily.dev/sources/coinsbench"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,smart-contracts,solidity,defi","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Coins Bench","item":"https://daily.dev/sources/coinsbench"},{"@type":"ListItem","position":3,"name":"Solving Damn Vulnerable DeFi V4: Level 2- Naive Receiver"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/solving-damn-vulnerable-defi-v4-level-2--naive-receiver-sgr6y88vg#faq","mainEntity":[{"@type":"Question","name":"How does the access control vulnerability in the Damn Vulnerable DeFi Naive Receiver flash loan work?","acceptedAnswer":{"@type":"Answer","text":"The onFlashLoan function in FlashLoanReceiver.sol ignores its initiator address parameter, so it never verifies who actually triggered the flash loan. This lets an attacker repeatedly call flashLoan on behalf of a victim, forcing them to pay the fixed 1 WETH fee per call without their consent, draining 10 WETH across ten forced flash loans. Developers auditing flash loan contracts can find similar access control writeups curated on daily.dev."}},{"@type":"Question","name":"How can msg.sender spoofing through a trusted forwarder be exploited in a Solidity contract?","acceptedAnswer":{"@type":"Answer","text":"In NaiveReceiverPool, the _msgSender() override trusts msg.data's last 20 bytes as the real sender whenever the call comes from a designated relayer, instead of properly verifying the caller. An attacker can craft calldata through the trusted BasicForwarder with any address appended as the final 20 bytes, impersonating that account to call functions like withdraw on its behalf. Teams building meta-transaction relayers can track exploit patterns like this via daily.dev when hardening contract security."}}]}
```

