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

Try-Catch block fails to provide detailed error messages

https://github.com/Cyfrin/2024-07-zaros/blob/main/src/external/chainlink/ChainlinkUtil.sol#L41-L57

Summary

Within ChainlinkUtil.sol, the formatting of the try-catch block causes it to always revert with Errors.InvalidSequencerUptimeFeedReturn() instead of intended error messages.

Description

In the ChainlinkUtil.sol contract, the try-catch block is used to handle errors from the sequencerUptimeFeed.latestRoundData() function. However, the current implementation will always catch any revert within the try block and subsequently revert with Errors.InvalidSequencerUptimeFeedReturn(). This behavior overrides more specific error messages that provide better context for debugging and error logging.

Impact

Functionally, the impact on the protocol is minimal since the operation will still revert. However, this issue can hinder future debugging and error logging efforts because it obscures the specific cause of the error by replacing it with a more generic message.

Proof of Concept

The following code demonstrates the issue:

if (address(sequencerUptimeFeed) != address(0)) {
try sequencerUptimeFeed.latestRoundData() returns (
uint80, int256 answer, uint256 startedAt, uint256, uint80
) {
bool isSequencerUp = answer == 0;
if (!isSequencerUp) {
revert Errors.OracleSequencerUptimeFeedIsDown(address(sequencerUptimeFeed));
}
uint256 timeSinceUp = block.timestamp - startedAt;
if (timeSinceUp <= Constants.SEQUENCER_GRACE_PERIOD_TIME) {
revert Errors.GracePeriodNotOver();
}
} catch {
revert Errors.InvalidSequencerUptimeFeedReturn();
}
}

In this scenario, any revert within the try block will trigger the catch block, which will then revert with Errors.InvalidSequencerUptimeFeedReturn(), masking the original error message.

Tools Used

Manual Review

Recommended Mitigation Steps

Remove Try-Catch Block: Eliminate the try-catch block entirely. Instead, allow the function to revert with the original, more descriptive error messages.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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