Inconsistent handler address decoding prevents any message from being executed
The contract expects the message handler to be encoded as an application ID in one place and as an application address in another, so the message digest differs and the execution check always fails. As a result, no message can be executed, tokens cannot be minted on the destination chain, and they remain locked on the source chain.
Folks Finance: Wormhole NTT on Algorand
Originally disclosed on Immunefi
57333 sc high inconsistent handler address decoding prevents any message from being executed
Submitted on Oct 25th 2025 at 10:19:41 UTC by @uhudo for Audit Comp | Folks Finance: Wormhole NTT on Algorand
- Report ID: #57333
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/main/ntt\\_contracts/transceiver/TransceiverManager.py
- Impact: Permanent freezing of funds
Description
Brief / Intro
The problem is that handler_address of a received message is expected to encode message_handler as an application ID at one point and as an application address at another point. This inconsistency prevents any message from being executed.
Consequence: no tokens can be minted on the destination chain while they get permanently locked on the source chain.
Vulnerability Details
TransceiverManagerdefinesmessage_handleras an application ID: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/TransceiverManager.py#L62- When receiving a message (
attestation_received()), it extractsmessage_handlerfromhandler_addressas if thehandler_addresswere an application ID: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/TransceiverManager.py#L194 - When performing the check for executing a message (
execute_message()inMessageHandlerofNttManager), it treatshandler_addressas an address: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/MessageHandler.py#L55 - Messages are identified via a hash of their contents (
calculate_message_digest()): https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/TransceiverManager.py#L230
Because the encoding/decoding expectations for handler_address differ (application ID vs address), the same logical message encoded differently yields different message digests. The inconsistency causes the check in execute_message() to fail for all received messages — effectively preventing execution.
Impact Details
No message can be executed due to the mismatch, therefore tokens cannot be minted on the destination chain while they remain permanently locked on the source chain.
References
- Defining
message_handleras application ID inTransceiverManager: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/TransceiverManager.py#L62 - Extracting
message_handlerfromhandler_addressas if it were an application ID inattestation_received()ofTransceiverManager: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/TransceiverManager.py#L194 - Performing a check for executing a message as if
handler_addresswas an address inexecute_message()withinMessageHandlerofNttManager: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/MessageHandler.py#L55 - Unique message identifier: https://github.com/Folks-Finance/algorand-ntt-contracts/blob/912c92d5219efe94ae707389da85c93e17e7e36b/ntt\\_contracts/transceiver/TransceiverManager.py#L230
Proof of Concept
An end-to-end test of all components used in the complete transfer flow demonstrates the bug. Replacing the tests in handle message of NttManager.test.ts with the following shows that executing the delivered message fails with "Message handler address mismatch":
describe("handle message", () => {
test("impossible to execute", async () => {
// create a transceiver
const transceiverFactory = localnet.algorand.client.getTypedAppFactory(MockTransceiverFactory, {
defaultSender: creator,
defaultSigner: creator.signer,
});
const messageFee = 100_000n;
const { result } = await transceiverFactory.send.create.create({
sender: creator,
args: [transceiverManagerAppId, messageFee, SECONDS_IN_DAY],
});
const transceiverAppId = result.appId
const transceiver = await transceiverFactory.getAppClientById({ appId: transceiverAppId })
const MESSAGE_HANDLER_ADMIN_ROLE = (appId: number | bigint) =>
keccak_256(Uint8Array.from([...enc.encode("MESSAGE_HANDLER_ADMIN_"), ...convertNumberToBytes(appId, 8)])).slice(
0,
16,
);
// add transceiver to TransceiverManager
const transceiverManager = await transceiverManagerFactory.getAppClientById({ appId: transceiverManagerAppId })
const APP_MIN_BALANCE = (203_200).microAlgos();
const fundingTranscieverTxn = await localnet.algorand.createTransaction.payment({
sender: creator,
receiver: getApplicationAddress(transceiverManagerAppId),
amount: APP_MIN_BALANCE,
});
const _ = await transceiverManager.newGroup()
.addTransaction(fundingTranscieverTxn)
.addTransceiver({
sender: admin,
args: [appId, transceiverAppId],
boxReferences: [
getAddressRolesBoxKey(MESSAGE_HANDLER_ADMIN_ROLE(appId), admin.publicKey),
getHandlerTransceiversBoxKey(appId),
],
})
.send();
// check there is sufficient capacity
const inboundBucketId = getInboundBucketIdBytes(PEER_CHAIN_ID);
const untrimmedAmount = 10_000n;
expect(await client.hasCapacity({ args: [inboundBucketId, untrimmedAmount] })).toBeTruthy();
// prepare message
const amount = untrimmedAmount / 10_000n;
const payload = getNttPayload(PEER_DECIMALS, amount, getRandomBytes(32), user.publicKey, SOURCE_CHAIN_ID);
const handlerAddress = convertNumberToBytes(appId, 32); // getApplicationAddress(appId).publicKey
const messageReceived = getMessageReceived(
PEER_CHAIN_ID,
getRandomMessageToSend({
sourceAddress: PEER_CONTRACT,
destinationChainId: Number(SOURCE_CHAIN_ID),
handlerAddress,
payload,
}),
);
const messageDigest = calculateMessageDigest(messageReceived);
// deliver message
const resultDelivery = await transceiver.send.deliverMessage({
sender: user,
args: [messageReceived],
appReferences: [transceiverManagerAppId, appId],
boxReferences: [
getHandlerTransceiversBoxKey(appId),
getTransceiverAttestationsBoxKey(messageDigest, transceiverAppId),
getNumAttestationsBoxKey(messageDigest),
],
extraFee: (1000).microAlgos(),
});
// execute message - fails
const addBalance = (22_900).microAlgo();
const fundingTxn = await localnet.algorand.createTransaction.payment({
sender: relayer,
receiver: getApplicationAddress(appId),
amount: addBalance,
});
await expect(
client
.newGroup()
.addTransaction(fundingTxn)
.executeMessage({
sender: relayer,
args: [messageReceived],
appReferences: [transceiverManagerAppId],
boxReferences: [
getMessagesExecutedBoxKey(messageDigest),
getBucketBoxKey(inboundBucketId),
getInboundQueuedTransfersBoxKey(messageDigest),
],
extraFee: (3000).microAlgos(),
})
.send(),
).rejects.toThrow("Message handler address mismatch");
});
});
(End of report)
Context
Folks Finance runs a Wormhole Native Token Transfer (NTT) deployment on Algorand. The contracts under review live in the algorand-ntt-contracts repository, and the report targets the transceiver layer, specifically ntt_contracts/transceiver/TransceiverManager.py. The transceiver layer is the part of NTT that carries attestations of a transfer from a source chain to a destination chain and hands the message to the message handler that finally executes it, which is where tokens get minted on the destination side.
A message carries a handler_address field that identifies which handler should process it. The TransceiverManager stores the configured message_handler as an application ID, and the message digest that uniquely identifies a message is computed over the message contents, including that handler_address. The report shows that the same field is interpreted as an application ID in one place and as an application address in another, and that this mismatch makes every delivered message fail at execution time.
Setup
The proof of concept is an end-to-end test built on a local Algorand network (localnet) using the typed application factories generated for the contracts. The test replaces the existing handle message block in NttManager.test.ts. The actors and objects involved are:
creator,admin,userandrelayeraccounts, each with a signer where needed.transceiverManagerAppId, the already deployedTransceiverManagerapplication.appId, the message handler application ID that is registered as a transceiver target and later used as the handler.- A freshly created
MockTransceiverapplication, created throughMockTransceiverFactory. - Constants such as
PEER_CHAIN_ID,SOURCE_CHAIN_ID,PEER_DECIMALS,PEER_CONTRACTandSECONDS_IN_DAYsupplied by the test harness.
The test exercises the full transfer flow: create a transceiver, register it with the TransceiverManager, deliver a message, then attempt to execute it.
Finding it
The researcher compared how handler_address is treated at three points in the code:
TransceiverManagerdefinesmessage_handleras an application ID (line 62 ofTransceiverManager.py).- When a message is received,
attestation_received()extractsmessage_handlerfromhandler_addressas ifhandler_addresswere an application ID (line 194 ofTransceiverManager.py). - When the message is executed,
execute_message()inMessageHandlerofNttManagertreatshandler_addressas an address (line 55 ofMessageHandler.py).
Messages are identified by a hash of their contents via calculate_message_digest() (line 230 of TransceiverManager.py). Because the encoding and decoding expectations for handler_address differ between the application ID view and the address view, the same logical message encoded in the two ways produces different message digests. The check in execute_message() therefore fails for every received message, and no message can be executed.
The report frames the consequence directly: no tokens can be minted on the destination chain while they are permanently locked on the source chain.
Exploitation
Step 1: create a transceiver
The test creates a MockTransceiver through the typed factory, with creator as the default sender and signer, and a message fee of 100_000n and a duration of SECONDS_IN_DAY.
const transceiverFactory = localnet.algorand.client.getTypedAppFactory(MockTransceiverFactory, {
defaultSender: creator,
defaultSigner: creator.signer,
});
const messageFee = 100_000n;
const { result } = await transceiverFactory.send.create.create({
sender: creator,
args: [transceiverManagerAppId, messageFee, SECONDS_IN_DAY],
});
const transceiverAppId = result.appId
const transceiver = await transceiverFactory.getAppClientById({ appId: transceiverAppId })
The created application ID is kept as transceiverAppId and the client is retrieved for later use.
Step 2: register the transceiver with the TransceiverManager
The test defines a helper that derives the MESSAGE_HANDLER_ADMIN_ROLE box key from the handler application ID, then funds the TransceiverManager application account with the minimum balance and adds the transceiver.
const MESSAGE_HANDLER_ADMIN_ROLE = (appId: number | bigint) =>
keccak_256(Uint8Array.from([...enc.encode("MESSAGE_HANDLER_ADMIN_"), ...convertNumberToBytes(appId, 8)])).slice(
0,
16,
);
// add transceiver to TransceiverManager
const transceiverManager = await transceiverManagerFactory.getAppClientById({ appId: transceiverManagerAppId })
const APP_MIN_BALANCE = (203_200).microAlgos();
const fundingTranscieverTxn = await localnet.algorand.createTransaction.payment({
sender: creator,
receiver: getApplicationAddress(transceiverManagerAppId),
amount: APP_MIN_BALANCE,
});
const _ = await transceiverManager.newGroup()
.addTransaction(fundingTranscieverTxn)
.addTransceiver({
sender: admin,
args: [appId, transceiverAppId],
boxReferences: [
getAddressRolesBoxKey(MESSAGE_HANDLER_ADMIN_ROLE(appId), admin.publicKey),
getHandlerTransceiversBoxKey(appId),
],
})
.send();
The addTransceiver call is made by admin with the handler appId and the new transceiverAppId, and references the role box and the handler transceivers box.
Step 3: confirm inbound capacity
Before building the message, the test checks that the inbound bucket for the peer chain has room for the amount.
const inboundBucketId = getInboundBucketIdBytes(PEER_CHAIN_ID);
const untrimmedAmount = 10_000n;
expect(await client.hasCapacity({ args: [inboundBucketId, untrimmedAmount] })).toBeTruthy();
Step 4: build the message with the handler encoded as an application ID
This is the crux of the proof. The handler address is produced with convertNumberToBytes(appId, 32), and the comment notes the alternative that would produce an address instead.
const amount = untrimmedAmount / 10_000n;
const payload = getNttPayload(PEER_DECIMALS, amount, getRandomBytes(32), user.publicKey, SOURCE_CHAIN_ID);
const handlerAddress = convertNumberToBytes(appId, 32); // getApplicationAddress(appId).publicKey
const messageReceived = getMessageReceived(
PEER_CHAIN_ID,
getRandomMessageToSend({
sourceAddress: PEER_CONTRACT,
destinationChainId: Number(SOURCE_CHAIN_ID),
handlerAddress,
payload,
}),
);
const messageDigest = calculateMessageDigest(messageReceived);
The message digest is computed over this message, and that digest is what later box references are keyed on.
Step 5: deliver the message
The message is delivered through the transceiver by user, with references to the TransceiverManager and the handler application, and box references for the handler transceivers, the transceiver attestations and the attestation count.
const resultDelivery = await transceiver.send.deliverMessage({
sender: user,
args: [messageReceived],
appReferences: [transceiverManagerAppId, appId],
boxReferences: [
getHandlerTransceiversBoxKey(appId),
getTransceiverAttestationsBoxKey(messageDigest, transceiverAppId),
getNumAttestationsBoxKey(messageDigest),
],
extraFee: (1000).microAlgos(),
});
The test then delivers the message and attempts execution.
Step 6: attempt execution and observe the failure
The relayer funds the handler application and then calls executeMessage with the same message. The test asserts that the call rejects with "Message handler address mismatch".
const addBalance = (22_900).microAlgo();
const fundingTxn = await localnet.algorand.createTransaction.payment({
sender: relayer,
receiver: getApplicationAddress(appId),
amount: addBalance,
});
await expect(
client
.newGroup()
.addTransaction(fundingTxn)
.executeMessage({
sender: relayer,
args: [messageReceived],
appReferences: [transceiverManagerAppId],
boxReferences: [
getMessagesExecutedBoxKey(messageDigest),
getBucketBoxKey(inboundBucketId),
getInboundQueuedTransfersBoxKey(messageDigest),
],
extraFee: (3000).microAlgos(),
})
.send(),
).rejects.toThrow("Message handler address mismatch");
The test expects the execution call to reject with "Message handler address mismatch", so the transfer never completes.
Root cause
The TransceiverManager treats message_handler as an application ID: it is configured as one and attestation_received() extracts it from handler_address on that basis. execute_message() in MessageHandler of NttManager instead treats handler_address as an application address. The two encodings of the same handler are not interchangeable, so the message digest computed over a message carrying the application ID encoding does not match what the execution path expects when it validates the handler address. The check fails and execution is blocked.
Because the digest is derived from the message contents, the mismatch is not a cosmetic decoding difference: it changes the identity of the message as seen by the execution path. The report does not describe any additional guard that would catch the inconsistency earlier, so the failure surfaces only when execution is attempted.
Impact
Every received message fails the handler address check in execute_message(), so no message can be executed. Tokens therefore cannot be minted on the destination chain, while the corresponding tokens remain permanently locked on the source chain. The report classifies this as a high severity smart contract issue with the impact "Permanent freezing of funds".
The condition is inherent to the encoding behaviour rather than to a particular user or message, since the report states that the inconsistency prevents any message from being executed.
Fix
The report does not describe a fix or a patch. The change it implies is to make the encoding of handler_address consistent across the three points: the definition of message_handler in TransceiverManager, the extraction in attestation_received(), and the check in execute_message() in MessageHandler of NttManager. Whichever representation is chosen, all three must agree so that the digest computed at delivery matches the handler address validated at execution.
Variants to test
- Compare every field that is serialised into a message digest against the representation used when the same field is validated later. A positive result is a message that delivers successfully but fails a later check with a mismatch error.
- Look for fields documented or typed as application IDs in one contract and as addresses in another. A positive result is a conversion helper such as
convertNumberToBytes(appId, 32)being used on one side and an address derivation such asgetApplicationAddress(appId).publicKeyon the other. - Exercise the full delivery-then-execution path in an end-to-end test rather than testing each contract in isolation. A positive result is a delivery that succeeds and an execution that reverts.
- Check whether the digest is recomputed from the raw message at execution time or from a normalised form. A positive result is a digest that differs between the two paths for the same logical message.
Hunting notes
This bug sits at the boundary between two contracts that share a serialised field: the transceiver that receives and stores the message, and the message handler that executes it. The signal during review is a field whose type is stated differently in different files, especially where one side uses an application ID and the other an address. Cross-chain messaging code is a good place to look because the same payload is encoded on one chain and decoded on another, and any disagreement about representation changes the digest that identifies the message.
The researcher demonstrated impact with an end-to-end test covering the complete transfer flow, showing execution failing with a specific error, which ties the abstract encoding mismatch to a concrete failure and to the permanent locking of funds on the source chain.
What happened, in plain words
Folks Finance uses a system called Wormhole NTT to move tokens between blockchains. Algorand is one of the blockchains involved. The report looks at the Algorand side of that system, in a repository called algorand-ntt-contracts, and specifically at a file called TransceiverManager.py.
To follow the story you need three ideas.
A blockchain is a shared record book that many computers keep copies of. Nobody can quietly edit old entries, and programs called smart contracts run on it. A smart contract is code that lives on the blockchain and does things like hold tokens or move them when certain conditions are met.
A token transfer between chains works in two halves. On the source chain, tokens are taken from the user and locked up. On the destination chain, the same number of tokens is created ("minted") for the user. If the second half never happens, the user's tokens are stuck in the lock on the first chain with nothing to show for them.
A message is the package of information that travels from the source side to the destination side. It says, in effect: "this transfer happened, please release these tokens to this person". The destination side has to read the message and act on it.
The report found that the destination side reads one field of that message, called handler_address, in two different ways in two different places. One place treats it as an application ID (a number that identifies a smart contract). Another place treats it as an application address (a longer string derived from that number). Because the two readings disagree, every message fails a check when the system tries to execute it. Execution never succeeds. The result is that no tokens are ever minted on the destination chain, while the originals stay locked on the source chain forever.
The report rates this High severity, with the impact "Permanent freezing of funds".
Context
Folks Finance runs a Wormhole Native Token Transfer (NTT) deployment on Algorand. NTT is the part of Wormhole that moves a token that already exists on one chain to another chain. The contracts under review live in the algorand-ntt-contracts repository, and the report targets the transceiver layer, specifically ntt_contracts/transceiver/TransceiverManager.py.
A transceiver is the component that carries a transfer's proof (called an attestation) from the source chain to the destination chain and hands the message to the message handler, the contract that finally executes it. Execution is the moment tokens get minted on the destination side. Think of the transceiver as a courier and the message handler as the clerk at the counter who actually pays out.
A message carries a handler_address field that says which handler should process it. The TransceiverManager stores the configured message_handler as an application ID. A message digest is a short fingerprint computed from the message's contents, including handler_address. The digest is how the system recognises a particular message later: same contents, same fingerprint; different contents, different fingerprint.
The report shows that the same field is interpreted as an application ID in one place and as an application address in another, and that this mismatch makes every delivered message fail at execution time.
Setup
The proof of concept is an end-to-end test. An end-to-end test runs the whole flow from start to finish on a test network, rather than checking one small piece in isolation. It runs on a local Algorand network (localnet), a private copy of the blockchain that runs on the tester's machine, using typed application factories generated for the contracts. A factory here is a helper object in the test code that creates and connects to contracts.
The test replaces the existing handle message block in NttManager.test.ts. The actors and objects involved are:
creator,admin,userandrelayeraccounts, each with a signer where needed. A signer is the piece of software that proves an account authorised an action, like a pen that only the account holder has.transceiverManagerAppId, the already deployedTransceiverManagerapplication.appId, the message handler application ID that is registered as a transceiver target and later used as the handler.- A freshly created
MockTransceiverapplication, created throughMockTransceiverFactory. Mock means a simplified stand-in used for testing. - Constants such as
PEER_CHAIN_ID,SOURCE_CHAIN_ID,PEER_DECIMALS,PEER_CONTRACTandSECONDS_IN_DAYsupplied by the test harness. A test harness is the surrounding code that supplies fixed values and helpers so the test can focus on the behaviour being checked.
The test exercises the full transfer flow: create a transceiver, register it with the TransceiverManager, deliver a message, then attempt to execute it.
Finding it
The researcher compared how handler_address is treated at three points in the code:
TransceiverManagerdefinesmessage_handleras an application ID (line 62 ofTransceiverManager.py).- When a message is received,
attestation_received()extractsmessage_handlerfromhandler_addressas ifhandler_addresswere an application ID (line 194 ofTransceiverManager.py). - When the message is executed,
execute_message()inMessageHandlerofNttManagertreatshandler_addressas an address (line 55 ofMessageHandler.py).
Messages are identified by a hash of their contents via calculate_message_digest() (line 230 of TransceiverManager.py). A hash is a one-way fingerprint: you can compute it from data, but you cannot work backwards from it, and any change to the data changes the fingerprint.
Because the encoding and decoding expectations for handler_address differ between the application ID view and the address view, the same logical message encoded in the two ways produces different message digests. The check in execute_message() therefore fails for every received message, and no message can be executed.
The report frames the consequence directly: no tokens can be minted on the destination chain while they are permanently locked on the source chain.
Exploitation
Step 1: create a transceiver
The test creates a MockTransceiver through the typed factory, with creator as the default sender and signer, and a message fee of 100_000n and a duration of SECONDS_IN_DAY.
const transceiverFactory = localnet.algorand.client.getTypedAppFactory(MockTransceiverFactory, {
defaultSender: creator,
defaultSigner: creator.signer,
});
const messageFee = 100_000n;
const { result } = await transceiverFactory.send.create.create({
sender: creator,
args: [transceiverManagerAppId, messageFee, SECONDS_IN_DAY],
});
const transceiverAppId = result.appId
const transceiver = await transceiverFactory.getAppClientById({ appId: transceiverAppId })
Line by line:
getTypedAppFactory(...)asks the local network for a factory that knows how to create and talk toMockTransceivercontracts. The two options set who sends by default (creator) and which signer is used by default (creator.signer).const messageFee = 100_000n;sets a fee of 100,000 units. Thenat the end means the number is a BigInt, a JavaScript number type that can hold very large whole numbers without losing precision, which matters when values represent money.transceiverFactory.send.create.create({...})actually creates the contract. The arguments passed to it are theTransceiverManagerapplication ID, the message fee and the duration.const transceiverAppId = result.appIdstores the ID the network assigned to the new contract.getAppClientById({ appId: transceiverAppId })fetches a client object for that contract so later steps can call it.
The created application ID is kept as transceiverAppId and the client is retrieved for later use.
Step 2: register the transceiver with the TransceiverManager
The test defines a helper that derives the MESSAGE_HANDLER_ADMIN_ROLE box key from the handler application ID, then funds the TransceiverManager application account with the minimum balance and adds the transceiver.
A box on Algorand is a piece of storage that a contract keeps outside its own code, addressed by a key. You can think of it as a labelled drawer in a filing cabinet: the contract must name the drawer it wants to open. A box key is the label on that drawer.
const MESSAGE_HANDLER_ADMIN_ROLE = (appId: number | bigint) =>
keccak_256(Uint8Array.from([...enc.encode("MESSAGE_HANDLER_ADMIN_"), ...convertNumberToBytes(appId, 8)])).slice(
0,
16,
);
// add transceiver to TransceiverManager
const transceiverManager = await transceiverManagerFactory.getAppClientById({ appId: transceiverManagerAppId })
const APP_MIN_BALANCE = (203_200).microAlgos();
const fundingTranscieverTxn = await localnet.algorand.createTransaction.payment({
sender: creator,
receiver: getApplicationAddress(transceiverManagerAppId),
amount: APP_MIN_BALANCE,
});
const _ = await transceiverManager.newGroup()
.addTransaction(fundingTranscieverTxn)
.addTransceiver({
sender: admin,
args: [appId, transceiverAppId],
boxReferences: [
getAddressRolesBoxKey(MESSAGE_HANDLER_ADMIN_ROLE(appId), admin.publicKey),
getHandlerTransceiversBoxKey(appId),
],
})
.send();
Line by line:
MESSAGE_HANDLER_ADMIN_ROLEis a small function. It takes an application ID, turns the text"MESSAGE_HANDLER_ADMIN_"into bytes, appends the ID as 8 bytes, hashes the result withkeccak_256, and keeps the first 16 bytes. The output is the label of the drawer that records who holds the admin role for that handler.getAppClientById(...)gets a client for the already deployedTransceiverManager.APP_MIN_BALANCE = (203_200).microAlgos()sets the minimum amount of Algorand's currency (microAlgos) that a contract account must hold. On Algorand, contracts need a small balance to exist and to store data.createTransaction.payment({...})builds a payment transaction fromcreatorto theTransceiverManager's account address, for that minimum balance.getApplicationAddress(...)converts an application ID into the account address that belongs to the contract.newGroup()starts a transaction group: several transactions that must all succeed together or all fail together. This is how Algorand lets one action depend on another in the same instant..addTransaction(fundingTranscieverTxn)puts the payment first, so the contract has funds before it is asked to store anything..addTransceiver({...})calls the contract'saddTransceivermethod asadmin, passing the handlerappIdand the newtransceiverAppId.boxReferenceslists the drawers the call needs to open: the role drawer for the admin and the drawer that holds the handler's transceivers..send()submits the group to the network.
The addTransceiver call is made by admin with the handler appId and the new transceiverAppId, and references the role box and the handler transceivers box.
Step 3: confirm inbound capacity
Before building the message, the test checks that the inbound bucket for the peer chain has room for the amount. A bucket here is a limit on how much can come in during a period, a safety cap so that a sudden flood of transfers cannot overwhelm the system.
const inboundBucketId = getInboundBucketIdBytes(PEER_CHAIN_ID);
const untrimmedAmount = 10_000n;
expect(await client.hasCapacity({ args: [inboundBucketId, untrimmedAmount] })).toBeTruthy();
Line by line:
getInboundBucketIdBytes(PEER_CHAIN_ID)computes the identifier of the bucket for incoming transfers from the peer chain.untrimmedAmount = 10_000nsets the amount to test with.hasCapacity(...)asks the contract whether that bucket can accept that amount, andexpect(...).toBeTruthy()asserts the answer is yes. If the bucket were full, the later steps would fail for an unrelated reason, so the test rules that out first.
Step 4: build the message with the handler encoded as an application ID
This is the crux of the proof. The handler address is produced with convertNumberToBytes(appId, 32), and the comment notes the alternative that would produce an address instead.
const amount = untrimmedAmount / 10_000n;
const payload = getNttPayload(PEER_DECIMALS, amount, getRandomBytes(32), user.publicKey, SOURCE_CHAIN_ID);
const handlerAddress = convertNumberToBytes(appId, 32); // getApplicationAddress(appId).publicKey
const messageReceived = getMessageReceived(
PEER_CHAIN_ID,
getRandomMessageToSend({
sourceAddress: PEER_CONTRACT,
destinationChainId: Number(SOURCE_CHAIN_ID),
handlerAddress,
payload,
}),
);
const messageDigest = calculateMessageDigest(messageReceived);
Line by line:
amount = untrimmedAmount / 10_000nscales the amount down, because the two chains count token units with different numbers of decimal places. Decimals are how many digits after the point a token amount can have; a token with 6 decimals counts one whole token as 1,000,000 units.getNttPayload(...)builds the inner payload: the amount, a random 32-byte value, the recipient's public key and the source chain ID. A public key is the shareable half of a cryptographic key pair; it identifies an account without revealing the secret half.handlerAddress = convertNumberToBytes(appId, 32)writes the handler's application ID into 32 bytes. The comment shows the other option,getApplicationAddress(appId).publicKey, which would produce the contract's account address instead. These two 32-byte values are not the same bytes, even though they refer to the same contract.getMessageReceived(...)wraps the payload in the outer message structure, with the peer chain, the source contract, the destination chain and the handler address.calculateMessageDigest(messageReceived)computes the fingerprint of the finished message. That fingerprint is what later box references are keyed on.
The message digest is computed over this message, and that digest is what later box references are keyed on.
Step 5: deliver the message
The message is delivered through the transceiver by user, with references to the TransceiverManager and the handler application, and box references for the handler transceivers, the transceiver attestations and the attestation count.
const resultDelivery = await transceiver.send.deliverMessage({
sender: user,
args: [messageReceived],
appReferences: [transceiverManagerAppId, appId],
boxReferences: [
getHandlerTransceiversBoxKey(appId),
getTransceiverAttestationsBoxKey(messageDigest, transceiverAppId),
getNumAttestationsBoxKey(messageDigest),
],
extraFee: (1000).microAlgos(),
});
Line by line:
deliverMessage({...})calls the transceiver's delivery method asuser, passing the message itself.appReferenceslists the other contracts this call needs to touch: theTransceiverManagerand the handler. On Algorand, a contract call must declare which other contracts it will read or write, so the network can check it in advance.boxReferenceslists the drawers to open: the handler's transceivers drawer, the drawer holding this transceiver's attestations for this message digest, and the drawer holding the count of attestations.extraFeeadds a small extra payment to cover the work of touching those extra contracts and boxes.
The test then delivers the message and attempts execution.
Step 6: attempt execution and observe the failure
The relayer funds the handler application and then calls executeMessage with the same message. A relayer is an account that submits transactions on behalf of others, usually for a small fee, so users do not have to do it themselves. The test asserts that the call rejects with "Message handler address mismatch".
const addBalance = (22_900).microAlgo();
const fundingTxn = await localnet.algorand.createTransaction.payment({
sender: relayer,
receiver: getApplicationAddress(appId),
amount: addBalance,
});
await expect(
client
.newGroup()
.addTransaction(fundingTxn)
.executeMessage({
sender: relayer,
args: [messageReceived],
appReferences: [transceiverManagerAppId],
boxReferences: [
getMessagesExecutedBoxKey(messageDigest),
getBucketBoxKey(inboundBucketId),
getInboundQueuedTransfersBoxKey(messageDigest),
],
extraFee: (3000).microAlgos(),
})
.send(),
).rejects.toThrow("Message handler address mismatch");
Line by line:
addBalance = (22_900).microAlgo()sets a small top-up amount for the handler contract's account.createTransaction.payment({...})builds a payment fromrelayerto the handler contract's account address, so the contract can pay for the storage it will use.expect(...).rejects.toThrow("Message handler address mismatch")wraps the whole call and states the expected outcome: the call must fail with exactly that error text. If it succeeded, the test would fail.newGroup()starts a transaction group, and.addTransaction(fundingTxn)puts the top-up payment first..executeMessage({...})calls the handler's execution method asrelayer, passing the same message that was delivered.appReferencesandboxReferencesagain declare the contracts and drawers the call needs: the record of executed messages, the inbound bucket, and the queue of inbound transfers for this digest.extraFeecovers the extra work..send()submits the group.
The test expects the execution call to reject with "Message handler address mismatch", so the transfer never completes.
Root cause
The TransceiverManager treats message_handler as an application ID: it is configured as one and attestation_received() extracts it from handler_address on that basis. execute_message() in MessageHandler of NttManager instead treats handler_address as an application address. The two encodings of the same handler are not interchangeable, so the message digest computed over a message carrying the application ID encoding does not match what the execution path expects when it validates the handler address. The check fails and execution is blocked.
Because the digest is derived from the message contents, the mismatch is not a cosmetic decoding difference: it changes the identity of the message as seen by the execution path. The report does not describe any additional guard that would catch the inconsistency earlier, so the failure surfaces only when execution is attempted.
Impact
Every received message fails the handler address check in execute_message(), so no message can be executed. Tokens therefore cannot be minted on the destination chain, while the corresponding tokens remain permanently locked on the source chain. The report classifies this as a high severity smart contract issue with the impact "Permanent freezing of funds".
The condition is inherent to the encoding behaviour rather than to a particular user or message, since the report states that the inconsistency prevents any message from being executed.
Fix
The report does not describe a fix or a patch. The change it implies is to make the encoding of handler_address consistent across the three points: the definition of message_handler in TransceiverManager, the extraction in attestation_received(), and the check in execute_message() in MessageHandler of NttManager. Whichever representation is chosen, all three must agree so that the digest computed at delivery matches the handler address validated at execution.
Variants to test
- Compare every field that is serialised into a message digest against the representation used when the same field is validated later. A positive result is a message that delivers successfully but fails a later check with a mismatch error.
- Look for fields documented or typed as application IDs in one contract and as addresses in another. A positive result is a conversion helper such as
convertNumberToBytes(appId, 32)being used on one side and an address derivation such asgetApplicationAddress(appId).publicKeyon the other. - Exercise the full delivery-then-execution path in an end-to-end test rather than testing each contract in isolation. A positive result is a delivery that succeeds and an execution that reverts.
- Check whether the digest is recomputed from the raw message at execution time or from a normalised form. A positive result is a digest that differs between the two paths for the same logical message.
Hunting notes
This bug sits at the boundary between two contracts that share a serialised field: the transceiver that receives and stores the message, and the message handler that executes it. The signal during review is a field whose type is stated differently in different files, especially where one side uses an application ID and the other an address. Cross-chain messaging code is a good place to look because the same payload is encoded on one chain and decoded on another, and any disagreement about representation changes the digest that identifies the message.
The researcher demonstrated impact with an end-to-end test covering the complete transfer flow, showing execution failing with a specific error, which ties the abstract encoding mismatch to a concrete failure and to the permanent locking of funds on the source chain.
Glossary
- Algorand: a blockchain platform where smart contracts and tokens run.
- Application address: the account address that belongs to a smart contract, derived from its application ID.
- Application ID: a number that identifies a smart contract on Algorand.
- Attestation: a proof, carried from the source chain, that a transfer happened.
- BigInt: a JavaScript number type for very large whole numbers, written with an
nsuffix. - Blockchain: a shared record book kept by many computers, where old entries cannot be quietly changed.
- Box: storage a contract keeps outside its code, addressed by a key.
- Box key: the label that identifies a particular box.
- Box reference: a declaration in a transaction naming a box the call needs to open.
- Bucket: a limit on how much can flow in during a period.
- Contract: see smart contract.
- Decimals: how many digits after the point a token amount can have.
- Digest: a short fingerprint computed from data, used to identify it.
- End-to-end test: a test that runs a whole flow from start to finish.
- Factory: a helper object in test code that creates and connects to contracts.
- Hash: a one-way fingerprint of data; any change to the data changes the fingerprint.
- Message: the package of information sent from the source side of a transfer to the destination side.
- Message handler: the contract that executes a delivered message and mints tokens.
- MicroAlgo: the smallest unit of Algorand's currency.
- Mock: a simplified stand-in used for testing.
- NTT (Native Token Transfer): Wormhole's system for moving a token that already exists on one chain to another chain.
- Payload: the inner content of a message, such as amount and recipient.
- Public key: the shareable half of a cryptographic key pair, used to identify an account.
- Relayer: an account that submits transactions on behalf of others.
- Signer: software that proves an account authorised an action.
- Smart contract: code that lives on a blockchain and performs actions such as holding or moving tokens.
- Test harness: surrounding test code that supplies fixed values and helpers.
- Token: a digital asset recorded on a blockchain.
- Transaction group: several Algorand transactions that all succeed or all fail together.
- Transceiver: the component that carries attestations between chains and hands messages to the handler.
- TransceiverManager: the contract that configures and tracks transceivers.
- Wormhole: a cross-chain messaging system used to move tokens and data between blockchains.