# Accessing the incorrect offset to get the nonce when a flag is 0x06 in RootBridgeAgent::anyExecute() will lead to marked as executed incorrect nonces and could potentially cause a DoS

RootBridgeAgent::anyExecute reads the nonce at the wrong byte offset for flag 0x06, marking incorrect nonces as executed and potentially causing a DoS.

- Payout: Contest reward
- Severity: high
- Program: Maia DAO Ecosystem
- Credited: 0xStalin
- Disclosed: 2023-09-18
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-05-maia-findings/issues/267
- Library page: https://bugbountylibrary.com/r/c4%3A2023-05-maia%3AH-26
- Tags: domain:web3 impact:dos kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** RootBridgeAgent::anyExecute() cross-chain message decoder
**Root cause:** For flag 0x06 the nonce sits at data[22:26] (after the 1-byte hTokens length), but the code reads data[PARAMS_START_SIGNED:25] = data[21:25], shifting the nonce by one byte.
**Steps:**
1. Inspect IRootBridgeAgent data layout: flag(1b) + address(20b) + hTokens.length(1b) + nonce(4b) for callOutSignedMultiple=0x06.
2. Note BranchBridgeAgent encodes nonce at data[22:26].
3. Read RootBridgeAgent.sol L1083-1085: nonce = uint32(bytes4(data[PARAMS_START_SIGNED:25])) i.e. data[21:25].
4. Observe the read includes the length byte and drops the last nonce byte, producing a wrong nonce value.
5. Wrong nonce gets marked executed, so the real nonce later reverts as already-executed -> DoS.
**How found:** Code-reading against the documented byte layout in IRootBridgeAgent; compared the encoder in BranchBridgeAgent (nonce at data[22:26]) with the decoder offset in RootBridgeAgent and spotted the one-byte shift.
**Exploitation:** Attacker triggers a 0x06 callOutSignedMultiple message; the misparsed nonce is recorded as executed, so the legitimate nonce is rejected as already executed, blocking that deposit path.
**Insight:** When a protocol documents a packed byte layout, diff every decoder offset against the encoder field-by-field; a single length byte inserted before a field shifts all subsequent offsets and silently corrupts parsed values.
