Back to articles
The DBXen ERC2771 Identity Confusion: Why _msgSender() msg.sender Is DeFi's Most Underrated Bug Class

The DBXen ERC2771 Identity Confusion: Why _msgSender() msg.sender Is DeFi's Most Underrated Bug Class

via Dev.toohmygod

On March 12, 2026, a seemingly mundane bug — using msg.sender in one place and _msgSender() in another — cost DBXen $149K across Ethereum and BNB Chain. The attacker didn't need a flash loan. Didn't need to manipulate an oracle. They just needed the protocol to disagree with itself about who was calling. This is a post-mortem, a pattern catalog, and a detection guide rolled into one. The Setup: ERC2771 and Meta-Transactions ERC2771 is the standard for gasless meta-transactions. A trusted forwarder relays a user's signed transaction, and the receiving contract extracts the real sender from the calldata tail instead of trusting msg.sender (which would be the forwarder's address). The pattern looks like this: function _msgSender() internal view override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // Extract real sender from last 20 bytes of calldata assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return msg.sender; } } When you inherit f

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles