Skip to content
Business logic Audit finding Intermediate

Invalid addresses will be accepted as resolvers, possibly bricking assets

The hexToAddress utility truncates a 256-bit value to 160 bits without checking that the discarded upper bits are zero, so an invalid DNS address can be accepted as a valid resolver. This can cause the ENS node to be set to an incorrect owner address, potentially bricking it.

Trust Follow

Originally disclosed on Code4rena

Submitted by Trust

The hexToAddress utility parses a string into an address type.

    function hexToAddress(
        bytes memory str,
        uint256 idx,
        uint256 lastIdx
    ) internal pure returns (address, bool) {
        if (lastIdx - idx < 40) return (address(0x0), false);
        (bytes32 r, bool valid) = hexStringToBytes32(str, idx, lastIdx);
        return (address(uint160(uint256(r))), valid);
    }

The issue is that in the return statement, the bytes32 type is reduced from 256 bits to 160 bits, without checking that the truncated bytes are zero. When the upper bits are not zero, the bytes32 is not a valid address and the function must return false in the second parameter. However, it instead returns an incorrect trimmed number.

The utility is used in the flow below:

proveAndClaim
	_claim
		getOwnerAddress
			parseRR
				parseString
					hexToAdress

The incorrect address would be returned from _claim and then used as the owner address for ens.setSubnodeOwner. This would brick the node.

function proveAndClaim(
    bytes memory name,
    DNSSEC.RRSetWithSignature[] memory input
) public override {
    (bytes32 rootNode, bytes32 labelHash, address addr) = _claim(
        name,
        input
    );
    ens.setSubnodeOwner(rootNode, labelHash, addr);
}

Impact

Lack of validation can lead to ENS addresses becoming permanently bricked.

Recommended Mitigation Steps

Add a check for the upper 96 bits in the highlighted return statement.

Note for judge

Historically, the judge has awarded medium severity to various issues which rely on some user error, are easy to check/fix and present material risk. I respect this line of thought and for the sake of consistency I believe this submission should be judged similarly.

Arachnid (ENS) disputed and commented:

The upshot of this is that if you provide an invalid address in DNS, it will be set to a (possibly different) invalid address in ENS. This can be fixed by correcting the address in DNS and calling proveAndClaim again. I would argue this should be considered minor at best.


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

Root cause

The function truncates a 256-bit value to 160 bits without verifying that the upper 96 bits are zero, so invalid addresses are not rejected.

Impact

An invalid DNS address could be accepted, causing the ENS node to be set to an incorrect owner address and potentially bricking it, though the ENS developer notes it can be fixed by correcting the DNS record and calling proveAndClaim again.

What the attacker needed

Invalid address in DNS record; attacker can trigger proveAndClaim

The fix

Add a check that the upper 96 bits are zero before accepting the address.

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.

When converting a long hexadecimal string to an Ethereum address, the code cuts off the extra bits without checking if they are zero. This means a malformed address from DNS can be treated as valid, and the system may assign ownership of a name to the wrong address, making it unusable.

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.

More by Trust

View all

77 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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.