Go to app

Technical Root Cause: Non-Injective Encoding

Published 7/21/2026, 9:07:54 AM

Wanchain's Cardano-to-BNB Chain bridge was exploited on July 21, 2026, resulting in the theft of approximately 515 million NIGHT tokens, valued at between $9 million and $10 million USD [Source: https://phemex.com/news/article/wanchains-cardano-bridge-hacked-515-million-night-tokens-stolen-93993]. The incident was a signature replay attack caused by a fundamental flaw in how the bridge's smart contracts validated cross-chain messages.

Technical Root Cause: Non-Injective Encoding

The vulnerability resided in the TreasuryCheck validator on the Cardano side of the bridge. According to analysis by security firm BlockSec, the validator used a non-injective signed-message encoding method [Source: https://x.com/Phalcon_xyz/status/2079443108027421183].

  • The Flaw: When constructing the message to be signed by bridge relayers, the contract concatenated 14 variable-length fields (such as token amounts, recipient addresses, and transaction IDs) using an AppendByteString fold without using delimiters or length prefixes [Source: https://x.com/Phalcon_xyz/status/2079443108027421183].
  • The Mechanism: Because there were no boundaries between fields, different sets of data could produce the exact same byte string (a "collision"). For example, shifting a byte from the end of one field to the beginning of the next would result in the same concatenated string.
  • The Exploit: The attacker identified a previously valid signature and reorganized the variable-length field values to authorize a new, malicious transaction that resulted in the same hash. This allowed them to "replay" a valid signature to drain the bridge treasury [Source: https://crypto.news/wanchain-cardano-bridge-exploit-drains-515m-night-worth-9m/].

Impact and Response

The exploit led to a significant drop in the value of the NIGHT token and prompted an immediate response from the bridge and network teams.

Prevention Failure

Security analysts noted that the exploit was preventable using standard Cardano development practices. The bridge contract already included Cardano's native SerialiseData function, which provides unique, unambiguous CBOR encoding for data structures. However, the bridge implementation failed to use this function when building the signature hash, opting instead for the vulnerable direct concatenation method [Source: https://x.com/Phalcon_xyz/status/2079443108027421183].

The Midnight Foundation clarified that the exploit was isolated to Wanchain's third-party bridge infrastructure and did not compromise the core Midnight Network or its consensus mechanism [Source: https://crypto.news/wanchain-cardano-bridge-exploit-drains-515m-night-worth-9m/].