Attacker can perform griefing for process() in PromiseRouter by reverting calls to callback() in callbackAddress
The process() function in PromiseRouter calls a user-supplied callback contract without catching reverts, so if that callback reverts the whole transaction reverts. An attacker could set up a callback that reverts to grief relayers who call process(), causing them to lose gas and not receive the callback fee.
process() in PromiseRouter is used for process stored callback function and anyone calls it gets callbackFee and it calls callback() function of callbackAddress. but attacker set a callbackAddress that reverts on callback() and cause process() caller griefing. attacker can perform this buy front running or complex logic.
Proof of Concept
This is process() code:
/**
* @notice Process stored callback function
* @param transferId The transferId to process
*/
function process(bytes32 transferId, bytes calldata _message) public nonReentrant {
// parse out the return data and callback address from message
bytes32 messageHash = messageHashes[transferId];
if (messageHash == bytes32(0)) revert PromiseRouter__process_invalidTransferId();
bytes29 _msg = _message.ref(0).mustBePromiseCallback();
if (messageHash != _msg.keccak()) revert PromiseRouter__process_invalidMessage();
// enforce relayer is whitelisted by calling local connext contract
if (!connext.approvedRelayers(msg.sender)) revert PromiseRouter__process_notApprovedRelayer();
address callbackAddress = _msg.callbackAddress();
if (!AddressUpgradeable.isContract(callbackAddress)) revert PromiseRouter__process_notContractCallback();
uint256 callbackFee = callbackFees[transferId];
// remove message
delete messageHashes[transferId];
// remove callback fees
callbackFees[transferId] = 0;
// execute callback
ICallback(callbackAddress).callback(transferId, _msg.returnSuccess(), _msg.returnData());
emit CallbackExecuted(transferId, msg.sender);
// Should transfer the stored relayer fee to the msg.sender
if (callbackFee > 0) {
AddressUpgradeable.sendValue(payable(msg.sender), callbackFee);
}
}
As you can see it calls ICallback(callbackAddress).callback(transferId, _msg.returnSuccess(), _msg.returnData()); and if that call reverts then whole transaction would revert. so attacker can setup callbackAddress that revert and the caller of process() wouldn’t get any fee and lose gas.
Tools Used
VIM
Recommended Mitigation Steps
Change the code so it won’t revert if call to callbackAddress reverts.
If the callback would revert, normally it won’t be called.
However, the attacker (griefer) could potentially frontrun the relayer’s callback transaction (which is already submitted / in the mempool) and update the state of their callback contract in such a way to cause this subsequent callback to fail. Why would they do that? Nothing is gained, only losses are incurred on both sides.
This seems like it should be invalid, but it also seems like we should be doing a try/catch on principle though. Perhaps the issue is misrepresented here - it’s not so much an attack vector as it’s ‘best practice’ / QA issue.
Let’s de-escalate to QA issue. Confirming, but would be great to get a second look from @LayneHaber on this.
EDIT: Changed my mind, think the risk level is appropriate.
If you change the message, the following check(s) would fail (since the hash is put onchain when the message is propagated by nomad):
bytes32 messageHash = messageHashes[transferId];
if (messageHash == bytes32(0)) revert PromiseRouter__process_invalidTransferId();
bytes29 _msg = _message.ref(0).mustBePromiseCallback();
if (messageHash != _msg.keccak()) revert PromiseRouter__process_invalidMessage();
An attacker cannot falsify this message because sending messages on the router is restricted via the onlyConnext modifier, so I don’t think changing the callbackAddress is a valid attack strategy.
If we extend this concern to any failing callback, then any revert would not be executed. In most cases, this would be caught in offchain simulations meaning the relayer would not submit the transaction (and then nobody could process the callback). This means that integrators must handle failures within their code. This is a common practice when writing crosschain handlers (i.e. nomad handle should not revert as the message cannot be reprocessed, functions called via execute should handle errors unless sending funds to a recovery address is okay, etc.).
Don’t think this qualifies as a value leak, but because it is potentially unprocessable will leave the severity at 2 and move the label to “acknowledged”.
I guess this issue has the same concerns as M-01 (Issue #220). Even if the onus is on the caller of process to simulate the call beforehand, it seems likely that the transaction could be front-run and prove to be poor user experience for relayers.
I don’t think its realistic that relayers would call this function without first simulating the transaction to see if the callback fails, but I guess the bridge user could set the callback address up as a honey pot such that simulated transactions are successful.
It probably makes sense to remove the main culprit of the issue by using a try/catch statement for the ICallback(callbackAddress).callback(transferId, _msg.returnSuccess(), _msg.returnData()); call.
The original report as published on Code4rena, by unforgiven. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The process() function does not use a try/catch around the external callback call, so any revert in the callback reverts the entire transaction.
Impact
A relayer calling process() could lose gas and not receive the callback fee if the callback reverts, but the attacker gains nothing and the message hash check prevents changing the callback address.
What the attacker needed
Attacker can set callback address; relayer calls process(); callback reverts
The fix
The code should be changed to use a try/catch around the callback call so that a revert in the callback does not revert the whole process() transaction.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A smart contract function called process() lets anyone trigger a callback to another contract and earn a fee. If that callback fails (reverts), the whole transaction fails, so the caller loses the gas they paid and gets no fee. An attacker could make a callback that always fails to waste relayers' money.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.