Skip to content
Smart contracts Audit finding Advanced

Missing recursive calls handling in OffchainDNSResolver CCIP-aware contract

The OffchainDNSResolver contract's resolveCallback function does not catch OffchainLookup errors from a nested CCIP-aware resolver, so a nested error with an incorrect sender field is passed to the client. This could cause the client to perform an off-chain lookup against the wrong contract, leading to incorrect resolution.

MalfurionWhitehat Follow

Originally disclosed on Code4rena

Submitted by MalfurionWhitehat

https://github.com/code-423n4/2023-04-ens/blob/main/contracts/dnsregistrar/OffchainDNSResolver.sol#L109-L113 https://github.com/code-423n4/2023-04-ens/blob/main/contracts/dnsregistrar/OffchainDNSResolver.sol#L119

The resolveCallback function from OffchainDNSResolver is used as part of the EIP-3668 standard to properly resolve DNS names using an off-chain gateway and validating RRsets against the DNSSEC oracle.

The issue is that the function lacks proper error handling, specifically, a try/catch block to properly bubble up OffchainLookup error from the dnsresolver extracted from the RRset. As the EIP specifies,

When a CCIP-aware contract wishes to make a call to another contract, and the possibility exists that the callee may implement CCIP read, the calling contract MUST catch all OffchainLookup errors thrown by the callee, and revert with a different error if the sender field of the error does not match the callee address. […] Where the possibility exists that a callee implements CCIP read, a CCIP-aware contract MUST NOT allow the default solidity behaviour of bubbling up reverts from nested calls.

Impact

As per the EIP, the result would be an OffchainLookup that looks valid to the client, as the sender field matches the address of the contract that was called, but does not execute correctly.

Proof of Concept

  1. Client calls OffchainDNSResolver.resolve, which reverts with OffchainLookup, and prompts the client to execute resolveCallback after having fetched the necessary data from the gatewayURL
  2. The RRset returned by the gateway contains a dnsresolver that is a CCIP-aware contract, and also supports the IExtendedDNSResolver.resolve.selector interface
  3. Calling IExtendedDNSResolver(dnsresolver).resolve(name,query,context); could trigger another OffchainLookup error, but with a sender that does not match the dnsresolver, which would be just returned to the client without any modifications
  4. As a result, the sender field would be incorrect as per the EIP

Recommended Mitigation Steps

Use the recommended example from the EIP in order to support nested lookups.

Arachnid (ENS) confirmed


The original report as published on Code4rena, by MalfurionWhitehat. 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.

How it worked

Impact

The client could receive an OffchainLookup error with an incorrect sender field, leading to a failed or incorrect resolution, though the text does not specify further consequences.

What the attacker needed

A CCIP-aware nested resolver in the RRset; client follows EIP-3668 flow

The fix

The resolveCallback function should be updated to catch OffchainLookup errors from nested calls and validate the sender field, as shown in the EIP-3668 example.

How it was found

  1. Client calls OffchainDNSResolver.resolve, which reverts with OffchainLookup and prompts the client to call resolveCallback after fetching data from the gateway.
  2. The RRset returned by the gateway contains a dnsresolver that is CCIP-aware and supports the IExtendedDNSResolver.resolve selector.
  3. Calling resolve on that dnsresolver could trigger another OffchainLookup error with a sender that does not match the dnsresolver.
  4. That error is returned to the client without modification, so the sender field is incorrect per the EIP.

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.

This is about a smart contract that helps resolve DNS names using off-chain data. When it calls another contract that also uses off-chain data, it should check for a special error and handle it properly, but it doesn't, so the client might get confused about which contract to ask for data.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by MalfurionWhitehat

View all

3 more disclosed reports, best first.

More from ENS

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.