Authorizing the remote sender inside a CCIP receiver

A destination contract accepts a call from its configured router. That establishes the local delivery path, but a privileged application message still needs an authorized sender on an authorized source chain.

Bind the application identity to its lane

Inside the receiver, inspect sourceChainSelector and decode sender according to the source address format. The fixture uses short names and illustrative selectors. The second message carries the same sender label from another chain and must fail the pair check. Store actual CCIP selectors as integers large enough for uint64.

const expected = { selector: 100n, sender: "bridge-A" };
for (const m of [{selector:100n,sender:"bridge-A"},{selector:101n,sender:"bridge-A"}])
  console.log(m.selector === expected.selector && m.sender === expected.sender);

Test the public entry point as well

Test direct calls by an arbitrary local address and router-delivered messages with an unexpected remote identity. The first exercises the router restriction, the second the application’s allowlist. For EVM senders compare decoded addresses rather than their display strings. A chain’s EVM chain ID and its CCIP selector identify the network in different namespaces; substituting one for the other can silently reject authorized traffic.

docs.chain.link CCIP EVM receiver