repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
dapps-decentralizedapplications.mdMarkdown151 lines16.3 KiBsource raw download

title: "DApps - Decentralized Applications" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/dapps-DecentralizedApplications.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/dapps-DecentralizedApplications.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

DApps - Decentralized Applications#

What is a DApp?#

A decentralized application (DApp) places some application state or execution in smart contracts or another peer-to-peer protocol. Many production DApps are hybrid systems with a normal web frontend, RPC provider, indexer, and centralized API around the on-chain component; “decentralized” therefore describes an architectural property, not a guarantee of security or the absence of servers.[1]

Web3 DApp Architecture#

According to this post there are 3 different types of Web3 DApps architecture:[1]

"API-less" DApps#

These DApps are built on top of a blockchain and do not rely on any centralized APIs or backend. You could think that the blockchain is the actual backend of the application. They are fully decentralized and can be accessed directly through the blockchain.

In order to interact with the blockchain the client will usually use a wallet. The wallet will sign the transactions and send them to the blockchain. The client might also use a node to read data from the blockchain.

"API-Enabled" DApps#

These DApps are built on top of a blockchain but also rely on centralized APIs usually to gather information. They are mostly decentralized because even if they rely on a centralized API, the core functionality of the DApp is still on the blockchain. The communication of the client with the blockchain is usually done through a wallet.

A good example of this type of DApp is a NFT minting application. The server allows images to be uploaded but the minting is done by the client through a wallet.

"Full-Scale" DApps#

These DApps are built on top of a blockchain but also rely on centralized APIs and backend servers. They could be partially decentralized as the client might be able to perform operations on the blockchain using a wallet. However, usually the backend will also be able to perform operations on the blockchain.

A good example for this type of DApp is a cross-chain bridge where an offchain component is needed to communicate with both smart contracts in different blockchains to perform the transfer of assets.

Web2 vulnerabilities#

Web2 vulnerabilities still affect these kinds of applications although their impact might vary:

Of course, if the DApp is not using a backend or the backend used only offers public chain data or static pages, the attack surface of the DApp is reduced.

Web3 attack surface#

Moving checks on-chain changes the trust boundaries but does not inherently reduce the attack surface. The smart contracts, frontend, wallet/provider bridge, RPC and indexing infrastructure, relayers, and centralized APIs must all be assessed.

It might be possible to group web3 DApps vulnerabilities in the following categories:

Frontend, provider and wallet discovery abuse#

Modern DApps often assume that the wallet/provider layer is just plumbing, but this is an attack surface by itself:

When reviewing a DApp, treat the wallet connection layer exactly like an authentication boundary: inspect provider discovery, event handling (accountsChanged, chainChanged), transaction building after chain switches, and whether external wallet metadata is reflected in the DOM without sanitization.

Web3 Signing Workflow Compromise Safe Delegatecall Proxy Takeover

Signature-based approvals and gasless abuse#

In many DApps, the most dangerous action is no longer an on-chain approve, but an off-chain signature that a relayer or router later cashes in.

From a tester perspective, search the frontend and backend for permit, permit2, eth_signTypedData, personal_sign, isValidSignature, and any API that stores signatures for later broadcast. Confirm that nonces, deadlines, chain/domain separation, spender binding, and intended execution path are actually validated server-side or on-chain.

Off-chain state, finality and indexer desynchronization#

DApps usually do not read raw chain state directly for every action. They rely on RPC providers, webhooks, indexers, caches, and message queues. This introduces new exploitation opportunities:

When attacking this layer, review how the DApp handles confirmations, reorg rollbacks, duplicate deliveries, and contract-address allowlists in event consumers. A block seen at the chain tip is not necessarily finalized, so indexers and value-moving backends must distinguish inclusion from finality and be able to reconcile a reorganization.[6]

Some examples from this post:[1]

Wasting Funds: Forcing backend to perform transactions#

In the scenario Wasted Crypto in Gas via Unrestricted API, the attacker can force the backend to call functions of a smart contract that will consume gas. The attacker, just sending an ETH account number and with no limits, will force backend to call the smart contract to register it, which will consume gas.

DoS: Poor transaction handling time#

In the scenario Poor Transaction Time Handling Leads to DoS, it is explained that because the backend will keep the HTTP request open until a transaction is performed, a user can easily send several HTTP requests to the backend, which will consume all the resources of the backend and will lead to a DoS.

Backend<-->Blockchain desync - Race condition#

In the scenario Poor Transaction Time Handling Leads to Race Condition, it is explained that in a game it was possible for the user to send a withdrawal request to the backend which would send the user coins, but while the transaction was still being processed, the user was able to use those coins to purchase items in the game, getting them for free.

Another example could be to use the same coins to purchase different items as the backend is immediately giving the item to the user without waiting for the transaction to be confirmed and therefore waiting for the user balance in the blockchain to be reduced.

Smart contract address validation#

In the scenario Bridge Backend Lacks Smart Contract Address Validation it is explained how the backend was not properly checking the address of the smart contract, so it was possible for an attacker to deploy a fake smart contract, put funds on it, send the transaction to the backend and the backend would think that the user sent funds to the real smart contract and would give the user the tokens.

Mishandling of Asset Classes#

In the scenario Mishandling of Asset Classes, it is explained that the backend confused a scam NFT in an address with 1 MATIC, therefore allowing an attacker to send hundreds of scam NFTs to the address and get 1 MATIC from the platform for each of them.

More recent DApps may expose relayer, bundler, or paymaster APIs to sponsor user actions. These systems introduce a classic Web2 abuse surface around a Web3 execution engine:

Keep this page generic, but note that account-abstraction-specific bugs are covered in more detail here:

Erc 4337 Smart Account Security Pitfalls

References#