Skip to content
Crypto Audit finding Advanced

Factory.sol : Issue with arbitrary data as signature in signature based call and deploy methods

The Factory contract's deploy and call methods accept signatures without a domain separator or chain ID, making them generic. An attacker could replay signatures across chains or projects, or trick users into signing compatible data, to deploy or call contracts without authorisation.

obront Follow with 8olidity, bin2chen and 5 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-nftport-judging/issues/106

Found by

obront, 8olidity, bin2chen, ak1, minhquanym, ctf_sec, JohnSmith, Lambda

Summary

In Factory contract, deploy and call methods are using the signature based approach for deployment. This is not safe when we look at the way the signature is comes from user.

Vulnerability Detail

https://github.com/sherlock-audit/2022-10-nftport/blob/main/evm-minting-master/contracts/Factory.sol#L147-L225

In above line of codes, user is allowed for deployment by using the signature data. This could have multiple impacts as explained in Impact section.

Impact

  1. Signature replay attack.
  2. Signature reuse across different NFT Port projects if it is to be launched in multiple chains.

Because the chain ID is not included in the data, all signatures are also valid when the project is launched on a chain with another chain ID. For instance, let’s say it is also launched on Polygon. An attacker can now use all of the Ethereum signatures there. Because the Polygon addresses of user’s (and potentially contracts, when the nonces for creating are the same) are often identical, there can be situations where the payload is meaningful on both chains. 3. Signature without domain , nonces are not safe along with the standard specified in EIP 712. 4. Signature reuse from different Ethereum projects & phishing

Because the signature is very generic, there might be situations where a user has already signed data with the same format for a completely different Ethereum application. Furthermore, an attacker could set up a DApp that uses the same format and trick someone into signing the data. Even a very security-conscious owner that has audited the contract of this DApp (that does not have any vulnerabilities and is not malicious, it simply consumes signatures that happen to have the same format) might be willing to sign data for this DApp, as he does not anticipate that this puts his NFT Port project in danger.

Code Snippet

https://github.com/sherlock-audit/2022-10-nftport/blob/main/evm-minting-master/contracts/Factory.sol#L147-L225

Tool used

Manual Review

Recommendation

I strongly recommend to follow EIP-712 and not implement your own standard / solution. While this also improves the user experience, this topic is very complex and not easy to get right, so it is recommended to use a battle-tested approach that people have thought in detail about. All of the mentioned attacks are not possible with EIP-712: 1.) There is always a domain separator that includes the contract address. 2.) The chain ID is included in the domain separator 5.) There is a type hash (of the function name / parameters) 6.) The domain separator does not allow reuse across different projects, phishing with an innocent DApp is no longer possible (it would be shown to the user that he is signing data for Rigor, which he would off course not do on a different site)

Discussion

hyperspacebunny

Fixed in https://github.com/nftport/evm-minting-sherlock-fixes/pull/18

rayn731

Fixed, follows EIP-712 standard for hashing and signing data.

The original report as published on Sherlock, by obront. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

An attacker could replay signatures to deploy or call contracts on other chains or projects, or phish users into signing compatible data, potentially leading to unauthorised actions.

What the attacker needed

Signature without domain separator; project deployed on multiple chains; attacker obtains a valid signature

The fix

The issue was fixed by following the EIP-712 standard for hashing and signing data, which includes a domain separator with contract address and chain ID.

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.

A signature is like a digital autograph proving you approved something. Here, the contract checked the autograph but not what it was for, so the same autograph could be reused elsewhere. This could let someone else deploy or call contracts as if you had approved it.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by obront

View all

46 more disclosed reports, best first.

More from NFTPort

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.