DApp Pentesting Guide
A comprehensive guide for security testing of decentralized applications.
Understanding DApp Architecture
Before testing, identify which architecture type you're dealing with:
API-less DApps
- Fully decentralized, no centralized backend
- Client interacts directly with blockchain via wallet
- Attack surface: primarily client-side and smart contract
- Focus: wallet interactions, transaction signing, smart contract vulnerabilities
API-Enabled DApps
- Blockchain core with centralized APIs for data
- Mostly decentralized (e.g., NFT minting apps)
- Attack surface: API endpoints + client-side + smart contracts
- Focus: API security, image upload handling, minting logic
Full-Scale DApps
- Blockchain + centralized backend + APIs
- Partially decentralized (e.g., cross-chain bridges)
- Attack surface: backend, APIs, client, smart contracts
- Backend can perform blockchain operations
- Focus: backend-blockchain sync, bridge logic, admin keys
Web2 Vulnerabilities in DApps
Traditional web vulnerabilities still apply but with amplified impact in Web3 contexts.
Client-Side Vulnerabilities (High Impact)
- XSS: Can execute JS to interact with wallet and convince users to sign malicious transactions
- Content tampering: Can modify transaction details before user signs
- Impact: Even with wallet review, attackers can trick users into signing harmful operations
Server-Side Vulnerabilities
- Present in DApps with backend servers
- Impact varies by architecture:
- Backend-only public data: reduced attack surface
- Backend with private keys: catastrophic (fund theft, account takeover)
- Test for: exposed keys, admin access, API authentication
Web3-Specific Attack Vectors
Mishandled On-Chain Transactions
- Incorrectly formatted or unrestricted transaction APIs
- Lack of response-waiting and block-confirmation logic
- Exposure of sensitive data in transactions
- Improper handling of failed, reverted, or internally-typed transactions
- Malicious calldata injections
Smart-Contract-Driven Backend Attacks
- Storing/syncing sensitive data between contracts and databases without validation
- Unchecked event emissions or contract addresses
- Exploitable contract vulnerabilities poisoning backend logic
Flawed Crypto-Asset Operations
- Misprocessing different token types (native vs. ERC-20)
- Ignoring decimal precision
- Failed transfers or internal transactions
- Accepting fake, deflationary, rebase, or slippage-prone tokens without validation
- Payload injections via token metadata
Common Vulnerability Scenarios
1. Wasted Crypto in Gas via Unrestricted API
What to test: Can you force the backend to call smart contract functions that consume gas?
How to test:
- Send requests with no limits to trigger backend contract calls
- Example: Send ETH account numbers to registration endpoints without rate limiting
Impact: Attacker forces victim to pay gas fees
2. DoS via Poor Transaction Time Handling
What to test: Does the backend keep HTTP requests open until transactions complete?
How to test:
- Send multiple concurrent requests to exhaust backend resources
- Monitor backend resource usage during slow blockchain confirmations
Impact: Denial of service
3. Backend-Blockchain Desync (Race Condition)
What to test: Does the backend give items/funds before blockchain confirmation?
How to test:
- Send withdrawal request, then immediately use those funds for purchases
- Attempt to use same coins for multiple purchases before balance updates
Impact: Free items, double-spending
4. Smart Contract Address Validation
What to test: Does the backend validate contract addresses properly?
How to test:
- Deploy fake contract with similar address
- Send funds to fake contract, trick backend into thinking it's the real contract
- Test bridge endpoints with malicious contract addresses
Impact: Token theft, bridge exploits
5. Mishandling of Asset Classes
What to test: Does the backend confuse different asset types?
How to test:
- Send scam NFTs to an address expecting native tokens
- Test with rebase tokens, deflationary tokens, tokens with unusual decimals
- Send tokens with malicious metadata
Impact: Asset theft, platform exploitation
Testing Methodology
Phase 1: Reconnaissance
- Identify DApp architecture type (API-less, API-enabled, Full-scale)
- Map all endpoints and APIs
- Identify smart contracts involved (addresses, functions)
- Understand wallet integration (MetaMask, WalletConnect, etc.)
- Document all blockchain interactions
Phase 2: Client-Side Testing
- Test for XSS (critical in DApps - can manipulate wallet interactions)
- Check for content tampering opportunities
- Verify wallet interaction security
- Test transaction signing flows
- Review how transaction details are displayed to users
Phase 3: Backend/API Testing
- Test transaction handling endpoints
- Verify block confirmation logic (does it wait for confirmations?)
- Check for rate limiting on blockchain operations
- Test smart contract address validation
- Test asset type handling and validation
- Look for exposed private keys or admin credentials
Phase 4: Smart Contract Testing
- Review contract code for vulnerabilities
- Test event emission handling
- Verify asset type handling (ERC-20, ERC-721, native tokens)
- Check for reentrancy and other common issues
- Test with edge case tokens (rebase, deflationary, high decimals)
Phase 5: Integration Testing
- Test backend-blockchain synchronization
- Verify transaction confirmation flows
- Test race condition scenarios (withdrawal + purchase)
- Validate asset class handling across the stack
- Test failed/reverted transaction handling
Key Considerations
- Client-side vulnerabilities have amplified impact in DApps since clients perform blockchain operations
- Backend can be a single point of failure even in "decentralized" apps
- Transaction confirmation is critical - never assume immediate finality
- Asset type validation is essential - don't trust metadata or assume token types
- Gas costs can be weaponized - limit backend blockchain operations
- Wallet interactions are trust boundaries - users may not understand what they're signing
Quick Reference: Attack Vector Checklist
References
1---2name: pentest-dapps3description: How to pentest decentralized applications (DApps). Use this skill whenever the user mentions DApps, Web3 applications, blockchain applications, smart contracts, or wants to audit/penetrate test any decentralized application. This includes NFT platforms, DeFi protocols, cross-chain bridges, and any application that interacts with blockchain technology. Make sure to use this skill when the user asks about Web3 security, DApp vulnerabilities, or blockchain application testing.4---56# DApp Pentesting Guide78A comprehensive guide for security testing of decentralized applications.910## Understanding DApp Architecture1112Before testing, identify which architecture type you're dealing with:1314### API-less DApps15- Fully decentralized, no centralized backend16- Client interacts directly with blockchain via wallet17- Attack surface: primarily client-side and smart contract18- **Focus**: wallet interactions, transaction signing, smart contract vulnerabilities1920### API-Enabled DApps21- Blockchain core with centralized APIs for data22- Mostly decentralized (e.g., NFT minting apps)23- Attack surface: API endpoints + client-side + smart contracts24- **Focus**: API security, image upload handling, minting logic2526### Full-Scale DApps27- Blockchain + centralized backend + APIs28- Partially decentralized (e.g., cross-chain bridges)29- Attack surface: backend, APIs, client, smart contracts30- Backend can perform blockchain operations31- **Focus**: backend-blockchain sync, bridge logic, admin keys3233## Web2 Vulnerabilities in DApps3435Traditional web vulnerabilities still apply but with amplified impact in Web3 contexts.3637### Client-Side Vulnerabilities (High Impact)38- **XSS**: Can execute JS to interact with wallet and convince users to sign malicious transactions39- **Content tampering**: Can modify transaction details before user signs40- **Impact**: Even with wallet review, attackers can trick users into signing harmful operations4142### Server-Side Vulnerabilities43- Present in DApps with backend servers44- **Impact varies by architecture**:45 - Backend-only public data: reduced attack surface46 - Backend with private keys: catastrophic (fund theft, account takeover)47- **Test for**: exposed keys, admin access, API authentication4849## Web3-Specific Attack Vectors5051### Mishandled On-Chain Transactions52- Incorrectly formatted or unrestricted transaction APIs53- Lack of response-waiting and block-confirmation logic54- Exposure of sensitive data in transactions55- Improper handling of failed, reverted, or internally-typed transactions56- Malicious calldata injections5758### Smart-Contract-Driven Backend Attacks59- Storing/syncing sensitive data between contracts and databases without validation60- Unchecked event emissions or contract addresses61- Exploitable contract vulnerabilities poisoning backend logic6263### Flawed Crypto-Asset Operations64- Misprocessing different token types (native vs. ERC-20)65- Ignoring decimal precision66- Failed transfers or internal transactions67- Accepting fake, deflationary, rebase, or slippage-prone tokens without validation68- Payload injections via token metadata6970## Common Vulnerability Scenarios7172### 1. Wasted Crypto in Gas via Unrestricted API73**What to test:** Can you force the backend to call smart contract functions that consume gas?74**How to test:**75- Send requests with no limits to trigger backend contract calls76- Example: Send ETH account numbers to registration endpoints without rate limiting77**Impact:** Attacker forces victim to pay gas fees7879### 2. DoS via Poor Transaction Time Handling80**What to test:** Does the backend keep HTTP requests open until transactions complete?81**How to test:**82- Send multiple concurrent requests to exhaust backend resources83- Monitor backend resource usage during slow blockchain confirmations84**Impact:** Denial of service8586### 3. Backend-Blockchain Desync (Race Condition)87**What to test:** Does the backend give items/funds before blockchain confirmation?88**How to test:**89- Send withdrawal request, then immediately use those funds for purchases90- Attempt to use same coins for multiple purchases before balance updates91**Impact:** Free items, double-spending9293### 4. Smart Contract Address Validation94**What to test:** Does the backend validate contract addresses properly?95**How to test:**96- Deploy fake contract with similar address97- Send funds to fake contract, trick backend into thinking it's the real contract98- Test bridge endpoints with malicious contract addresses99**Impact:** Token theft, bridge exploits100101### 5. Mishandling of Asset Classes102**What to test:** Does the backend confuse different asset types?103**How to test:**104- Send scam NFTs to an address expecting native tokens105- Test with rebase tokens, deflationary tokens, tokens with unusual decimals106- Send tokens with malicious metadata107**Impact:** Asset theft, platform exploitation108109## Testing Methodology110111### Phase 1: Reconnaissance1121. Identify DApp architecture type (API-less, API-enabled, Full-scale)1132. Map all endpoints and APIs1143. Identify smart contracts involved (addresses, functions)1154. Understand wallet integration (MetaMask, WalletConnect, etc.)1165. Document all blockchain interactions117118### Phase 2: Client-Side Testing1191. Test for XSS (critical in DApps - can manipulate wallet interactions)1202. Check for content tampering opportunities1213. Verify wallet interaction security1224. Test transaction signing flows1235. Review how transaction details are displayed to users124125### Phase 3: Backend/API Testing1261. Test transaction handling endpoints1272. Verify block confirmation logic (does it wait for confirmations?)1283. Check for rate limiting on blockchain operations1294. Test smart contract address validation1305. Test asset type handling and validation1316. Look for exposed private keys or admin credentials132133### Phase 4: Smart Contract Testing1341. Review contract code for vulnerabilities1352. Test event emission handling1363. Verify asset type handling (ERC-20, ERC-721, native tokens)1374. Check for reentrancy and other common issues1385. Test with edge case tokens (rebase, deflationary, high decimals)139140### Phase 5: Integration Testing1411. Test backend-blockchain synchronization1422. Verify transaction confirmation flows1433. Test race condition scenarios (withdrawal + purchase)1444. Validate asset class handling across the stack1455. Test failed/reverted transaction handling146147## Key Considerations148149- **Client-side vulnerabilities have amplified impact** in DApps since clients perform blockchain operations150- **Backend can be a single point of failure** even in "decentralized" apps151- **Transaction confirmation is critical** - never assume immediate finality152- **Asset type validation is essential** - don't trust metadata or assume token types153- **Gas costs can be weaponized** - limit backend blockchain operations154- **Wallet interactions are trust boundaries** - users may not understand what they're signing155156## Quick Reference: Attack Vector Checklist157158- [ ] Unrestricted transaction APIs (gas waste)159- [ ] Poor transaction time handling (DoS)160- [ ] Backend-blockchain desync (race conditions)161- [ ] Smart contract address validation162- [ ] Asset class mishandling163- [ ] XSS with wallet interaction164- [ ] Exposed backend keys165- [ ] Failed transaction handling166- [ ] Token metadata injection167- [ ] Event emission validation168169## References170171- [Web2 Meets Web3: Hacking Decentralized Applications](https://www.certik.com/resources/blog/web2-meets-web3-hacking-decentralized-applications)