Diamond Hands Inu Honeypot

Reported loss Not disclosed
Ethereum
Honeypot

What happened

Diamond Hands Inu (DHINU) is an Ethereum token whose transfer path runs through a burnTokenCheck modifier. The owner, a _safeOwner address, owner-whitelisted addresses and transfers into the owner pass freely. For other holders, the default path is a require that lets a transfer through only when the recipient is the Uniswap V2 router address hard-coded as _unirouter; otherwise it reverts with "ERC20: transfer amount exceeds balance".

A sell through a trading pair sends tokens to the pair, not to the router, so by default it reverts for an ordinary holder. The owner can also change this default: a self-transfer by the owner sets _sellAmount, and after that a transfer from an ordinary holder with a smaller amount can pass without going to the router. The owner can also whitelist or blacklist addresses and can mint to itself.

De.Fi's REKT database lists the token as an Exit Scam/Honeypot and says the contract owner could restrict users from selling.

How it happened

  1. The constructor sets _owner and _safeOwner to the deployer and calls _mint(_owner, initialSupply*(10**18)), which creates 1,000,000,000 tokens (18 decimals) for the owner.
  2. Every transfer and transferFrom goes through _approveCheck, which carries the modifier burnTokenCheck(sender,recipient,amount).
  3. In the modifier, a sender that is _owner while _owner == _safeOwner passes and _safeOwner is set to the recipient. After that, a transfer passes if sender == _owner || sender == _safeOwner || recipient == _owner. Inside that branch, if sender == _owner && sender == recipient, the transfer also sets _sellAmount = amount. So once _safeOwner has moved off the owner, the owner can set _sellAmount with a self-transfer.
  4. For any other sender, a whitelisted sender (_whiteAddress[sender] == true) can transfer to any recipient. A blacklisted sender passes only if sender == _safeOwner or recipient == _unirouter.
  5. A sender that is neither whitelisted nor blacklisted is checked against _sellAmount, which starts at 0. While _sellAmount is 0, amount < _sellAmount is false, so the code reaches require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance"); and the transfer reverts unless the recipient is the router (the owner as recipient was already allowed in step 3). If the owner has set _sellAmount through a self-transfer, a transfer with amount < _sellAmount can pass with no router requirement, and the sender is blacklisted and removed from the whitelist only if recipient == _safeOwner. A transfer with amount >= _sellAmount still faces the router require.
  6. A sell through a pair is a transferFrom(holder, pair, amount). The recipient is the pair, so by default, for a holder who is not whitelisted, it reverts and the balance is not debited. Whether a given sell can pass depends on whether the owner has set _sellAmount and whether amount is below it. Buys, where the pair is the sender, can only pass if the pair is _safeOwner or whitelisted, or if the _sellAmount path applies; the source does not show which address the pair was or what _sellAmount was set to.
  7. The owner controls the lists: increaseAllowance whitelists addresses, addApprove blacklists them (and removes them from the whitelist), decreaseAllowance(address safeOwner) sets _safeOwner, and multiTransfer whitelists the first approvecount receivers. These function names do not match what they do.
  8. _mint is public with require(msg.sender == _owner, ...) and adds to _balances[_owner], so the owner can create new supply for itself at any time. The source alone does not show whether this was done.
  9. What happened on-chain (sell attempts, liquidity removal, losses, any _sellAmount value) was not established by the opened sources. De.Fi's REKT database lists the token as a honeypot.

Protocol details

Classification Token
Protocol Type Exit Scam/Honeypot
Affected asset / contract DHINU

Build your security review skills

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.