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.4metadata:5 source: https://skillmd.com/skills/abelrguezr/pentest-dapps6---78# DApp Pentesting Guide910A comprehensive guide for security testing of decentralized applications.1112## Understanding DApp Architecture1314Before testing, identify which architecture type you're dealing with:1516### API-less DApps17- Fully decentralized, no centralized backend18- Client interacts directly with blockchain via wallet19- Attack surface: primarily client-side and smart contract20- **Focus**: wallet interactions, transaction signing, smart contract vulnerabilities2122### API-Enabled DApps23- Blockchain core with centralized APIs for data24- Mostly decentralized (e.g., NFT minting apps)25- Attack surface: API endpoints + client-side + smart contracts26- **Focus**: API security, image upload handling, minting logic2728### Full-Scale DApps29- Blockchain + centralized backend + APIs30- Partially decentralized (e.g., cross-chain bridges)31- Attack surface: backend, APIs, client, smart contracts32- Backend can perform blockchain operations33- **Focus**: backend-blockchain sync, bridge logic, admin keys3435## Web2 Vulnerabilities in DApps3637Traditional web vulnerabilities still apply but with amplified impact in Web3 contexts.3839### Client-Side Vulnerabilities (High Impact)40- **XSS**: Can execute JS to interact with wallet and convince users to sign malicious transactions41- **Content tampering**: Can modify transaction details before user signs42- **Impact**: Even with wallet review, attackers can trick users into signing harmful operations4344### Server-Side Vulnerabilities45- Present in DApps with backend servers46- **Impact varies by architecture**:47 - Backend-only public data: reduced attack surface48 - Backend with private keys: catastrophic (fund theft, account takeover)49- **Test for**: exposed keys, admin access, API authentication5051## Web3-Specific Attack Vectors5253### Mishandled On-Chain Transactions54- Incorrectly formatted or unrestricted transaction APIs55- Lack of response-waiting and block-confirmation logic56- Exposure of sensitive data in transactions57- Improper handling of failed, reverted, or internally-typed transactions58- Malicious calldata injections5960### Smart-Contract-Driven Backend Attacks61- Storing/syncing sensitive data between contracts and databases without validation62- Unchecked event emissions or contract addresses63- Exploitable contract vulnerabilities poisoning backend logic6465### Flawed Crypto-Asset Operations66- Misprocessing different token types (native vs. ERC-20)67- Ignoring decimal precision68- Failed transfers or internal transactions69- Accepting fake, deflationary, rebase, or slippage-prone tokens without validation70- Payload injections via token metadata7172## Common Vulnerability Scenarios7374### 1. Wasted Crypto in Gas via Unrestricted API75**What to test:** Can you force the backend to call smart contract functions that consume gas?76**How to test:**77- Send requests with no limits to trigger backend contract calls78- Example: Send ETH account numbers to registration endpoints without rate limiting79**Impact:** Attacker forces victim to pay gas fees8081### 2. DoS via Poor Transaction Time Handling82**What to test:** Does the backend keep HTTP requests open until transactions complete?83**How to test:**84- Send multiple concurrent requests to exhaust backend resources85- Monitor backend resource usage during slow blockchain confirmations86**Impact:** Denial of service8788### 3. Backend-Blockchain Desync (Race Condition)89**What to test:** Does the backend give items/funds before blockchain confirmation?90**How to test:**91- Send withdrawal request, then immediately use those funds for purchases92- Attempt to use same coins for multiple purchases before balance updates93**Impact:** Free items, double-spending9495### 4. Smart Contract Address Validation96**What to test:** Does the backend validate contract addresses properly?97**How to test:**98- Deploy fake contract with similar address99- Send funds to fake contract, trick backend into thinking it's the real contract100- Test bridge endpoints with malicious contract addresses101**Impact:** Token theft, bridge exploits102103### 5. Mishandling of Asset Classes104**What to test:** Does the backend confuse different asset types?105**How to test:**106- Send scam NFTs to an address expecting native tokens107- Test with rebase tokens, deflationary tokens, tokens with unusual decimals108- Send tokens with malicious metadata109**Impact:** Asset theft, platform exploitation110111## Testing Methodology112113### Phase 1: Reconnaissance1141. Identify DApp architecture type (API-less, API-enabled, Full-scale)1152. Map all endpoints and APIs1163. Identify smart contracts involved (addresses, functions)1174. Understand wallet integration (MetaMask, WalletConnect, etc.)1185. Document all blockchain interactions119120### Phase 2: Client-Side Testing1211. Test for XSS (critical in DApps - can manipulate wallet interactions)1222. Check for content tampering opportunities1233. Verify wallet interaction security1244. Test transaction signing flows1255. Review how transaction details are displayed to users126127### Phase 3: Backend/API Testing1281. Test transaction handling endpoints1292. Verify block confirmation logic (does it wait for confirmations?)1303. Check for rate limiting on blockchain operations1314. Test smart contract address validation1325. Test asset type handling and validation1336. Look for exposed private keys or admin credentials134135### Phase 4: Smart Contract Testing1361. Review contract code for vulnerabilities1372. Test event emission handling1383. Verify asset type handling (ERC-20, ERC-721, native tokens)1394. Check for reentrancy and other common issues1405. Test with edge case tokens (rebase, deflationary, high decimals)141142### Phase 5: Integration Testing1431. Test backend-blockchain synchronization1442. Verify transaction confirmation flows1453. Test race condition scenarios (withdrawal + purchase)1464. Validate asset class handling across the stack1475. Test failed/reverted transaction handling148149## Key Considerations150151- **Client-side vulnerabilities have amplified impact** in DApps since clients perform blockchain operations152- **Backend can be a single point of failure** even in "decentralized" apps153- **Transaction confirmation is critical** - never assume immediate finality154- **Asset type validation is essential** - don't trust metadata or assume token types155- **Gas costs can be weaponized** - limit backend blockchain operations156- **Wallet interactions are trust boundaries** - users may not understand what they're signing157158## Quick Reference: Attack Vector Checklist159160- [ ] Unrestricted transaction APIs (gas waste)161- [ ] Poor transaction time handling (DoS)162- [ ] Backend-blockchain desync (race conditions)163- [ ] Smart contract address validation164- [ ] Asset class mishandling165- [ ] XSS with wallet interaction166- [ ] Exposed backend keys167- [ ] Failed transaction handling168- [ ] Token metadata injection169- [ ] Event emission validation170171## References172173- [Web2 Meets Web3: Hacking Decentralized Applications](https://www.certik.com/resources/blog/web2-meets-web3-hacking-decentralized-applications)