retryMessage unable to handle edge cases.
The retryMessage function does not check whether the receiver is banned or whether the message has been suspended after it entered a RETRIABLE state. An attacker could potentially cause a message to be retried even when the receiver is banned or the message is suspended, though the sponsor disputes that this is a vulnerability.
josephdara Follow with josephdara, grearlake and 6 others
Originally disclosed on Code4rena
Submitted by josephdara, also found by josephdara, grearlake, Shield, MrPotatoMagic (1, 2), Aymen0909, ladboy233, iamandreiski, lanrebayode77, t0x1c, and Fassi_Security (1, 2)
The function retryMessage() is unable to handle some edge scenarios listed below.
- Reverting or refunding a sender when the receiver is banned after the transaction is placed in a
RETRIABLEstate. - Message that is suspended after the transaction is placed in a
RETRIABLEstate.
Proof of Concept
A message is set to RETRIABLEin the processMessage when transfer fails or if the target address does not satisfy some conditions.
//IN PROCESSMESSAGE
if (_invokeMessageCall(_message, msgHash, gasLimit)) {
_updateMessageStatus(msgHash, Status.DONE);
} else {
_updateMessageStatus(msgHash, Status.RETRIABLE);
}
//_invokeMessageCall() FUNCTION
function _invokeMessageCall(
Message calldata _message,
bytes32 _msgHash,
uint256 _gasLimit
)
private
returns (bool success_)
{
if (_gasLimit == 0) revert B_INVALID_GAS_LIMIT();
assert(_message.from != address(this));
_storeContext(_msgHash, _message.from, _message.srcChainId);
if (
_message.data.length >= 4 // msg can be empty
&& bytes4(_message.data) != IMessageInvocable.onMessageInvocation.selector
&& _message.to.isContract()
) {
success_ = false;
} else {
(success_,) = ExcessivelySafeCall.excessivelySafeCall(
_message.to,
_gasLimit,
_message.value,
64, // return max 64 bytes
_message.data
);
}
// Must reset the context after the message call
_resetContext();
}
The issue here is, when the team attempts suspension of a message which is in a RETRIABLE state, the code does not block execution. Same or a banned address. This is because the proofReceipt[msgHash] which handles suspension is not checked. The addressBanned[_addr] is not checked too.
function retryMessage(
Message calldata _message,
bool _isLastAttempt
)
external
nonReentrant
whenNotPaused
sameChain(_message.destChainId)
{
// If the gasLimit is set to 0 or isLastAttempt is true, the caller must
// be the message.destOwner.
if (_message.gasLimit == 0 || _isLastAttempt) {
if (msg.sender != _message.destOwner) revert B_PERMISSION_DENIED();
}
bytes32 msgHash = hashMessage(_message);
if (messageStatus[msgHash] != Status.RETRIABLE) {
revert B_NON_RETRIABLE();
}
// Attempt to invoke the messageCall.
if (_invokeMessageCall(_message, msgHash, gasleft())) {
_updateMessageStatus(msgHash, Status.DONE);
} else if (_isLastAttempt) {
_updateMessageStatus(msgHash, Status.FAILED);
}
Recommended Mitigation Steps
Recheck necessary details to verify that the transaction is still good to go. Check the proofReceipt[msgHash].receivedAt and the addressBanned[_addr]
adaki2004 (Taiko) disputed and commented:
I’d dispute this with an addition (see end sentence).
2 cases mentioned here:
- Reverting or refunding a sender when the receiver is banned after the transaction is placed in a RETRIABLE state.
Intentional to NOT refund sender when he/she is banned. (Tho we might remove the “banAddress”, because it confuses a lot of people. The original intention behind banning an address is: NOT be able to call another , very important contract (
message.to) on behalf of theBridge, like theSignalService.)
- Message that is suspended after the transaction is placed in a RETRIABLE state. Not to refund suspended messages is a feature, it is a failsafe/security mechanism. In such case we need to use it, it would be a severe situation and we do not necessary want to refund (by default) the owner, since it might be a fake message on the destination chain. (That can be one reason - so makes no sense to refund). Also suspension would never happen after RETRIABLE. If we suspend message it is between NEW and (DONE or RETRIABLE).
So as we considering removing banning addresses (and not allow
SignalServiceto be called) for avoid confusion, but not because it is an issue, but a simplification and to avoid confusion. https://github.com/taikoxyz/taiko-mono/pull/16604
Using this issue to aggregate all of the issues around ban list functionality that has since been removed from the sponsors code base.
Note: For full discussion, see here.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the retryMessage function does not re-check the proofReceipt suspension status or the addressBanned mapping before invoking the message call.
Impact
A message could be retried even if the receiver is banned or the message is suspended, though the sponsor argues this is intentional and not a security issue.
What the attacker needed
Message in RETRIABLE state; receiver banned or message suspended
The fix
The sponsor removed the ban list functionality to avoid confusion, but did not treat the missing checks as a vulnerability.
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.
A smart contract bridge lets users send messages between blockchains. If a message fails, it can be retried later. This report says the retry function does not re-check some safety conditions (like whether the receiver is banned or the message is suspended) that were set after the first failure, so a retry might go through when it should not.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.