Skip to content
Access control Audit finding Intermediate

TridentNFT.permit should always check recoveredAddress != 0

The permit function in TridentNFT fails to check that the recovered address from a signature is not the zero address when the zero address is approved as an operator. If a user accidentally sets the zero address as an operator, anyone can steal tokens by submitting an invalid signature that recovers to the zero address.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by pauliax

The TridentNFT.permit function ignores the recoveredAddress != 0 check if isApprovedForAll[owner][recoveredAddress] is true.

Impact

If a user accidentally set the zero address as the operator, tokens can be stolen by anyone as a wrong signature yield recoveredAddress == 0.

Recommended Mitigation Steps

Change the require logic to recoveredAddress != address(0) && (recoveredAddress == owner) || isApprovedForAll[owner][recoveredAddress]).

sarangparikh22 (Sushi) confirmed

alcueca (judge) commented:

Assets are not at direct risk, but they are at risk. It wouldn’t be obvious to anyone that setting the zero address to the operator would lead to loss of assets. Severity 2.

The original report as published on Code4rena, by cmichel. 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 permit function's require statement does not enforce that recoveredAddress is not the zero address when isApprovedForAll[owner][recoveredAddress] is true.

What the attacker needed

User sets zero address as operator

The fix

The require logic should be changed to check that recoveredAddress is not the zero address and that it is either the owner or an approved operator.

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 lets users approve others to manage their NFTs. The approval function had a flaw: if someone approved the zero address (which means no one), then any bad signature would be treated as coming from that zero address and could be used to steal tokens. The fix is to always reject signatures that recover to the zero address.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by cmichel

View all

196 more disclosed reports, best first.

More from Sushi Trident contest phase 2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.