NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

`depositTokens` does not return the message nonce making it non-trivial to cancel them

Summary

Canceling a message through startRequestCancellation and cancelRequest is virtually impossible for a non-sophisticated user because he has no knowledge about the needed nonce.

Vulnerability Details

In order to call the cancel functions (startRequestCancellation and cancelRequest), the nonce used when sending the message is needed. This nonce is returned by the call to sendMessageToL2 in depositTokens.

function depositTokens(
uint256 salt,
address collectionL1,
snaddress ownerL2,
uint256[] calldata ids,
bool useAutoBurn
)
external
payable
{
// [...]
​
uint256[] memory payload = Protocol.requestSerialize(req);
if (payload.length >= MAX_PAYLOAD_LENGTH) {
revert TooManyTokensError();
}
IStarknetMessaging(_starknetCoreAddress).sendMessageToL2{value: msg.value}(
snaddress.unwrap(_starklaneL2Address),
felt252.unwrap(_starklaneL2Selector),
payload
);
​
emit DepositRequestInitiated(req.hash, block.timestamp, payload);
}

The problem is that this nonce is not returned by depositTokens. This means that the user calling it has no clue about what the used nonce was as it is starknet-internal.

Impact

Since the user does not know what their nonce was, they also cannot use the functionality provided to cancel failed messages.
Now the nonce is emitted in an event by the StarknetMessaging contract but finding the correct event if multiple bridgings have been done is non-trivial especially for a non-sophisticated user.

Proof of Concept

As shown in Vulnerability Details, depositTokens does not return anything, showing that the nonce provided by starknet is just ignored instead of being returned to the user.

Tools Used

Manual review

Recommended Mitigation

In order to make the cancel-functionality actually usable, I would recommend returning the nonce to the user when calling depositTokens.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Informational / Gas

Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.