Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No zero value return check in ecrecover in signature verification in HolographFactory contract #357

Closed
Tracked by #88
code423n4 opened this issue Oct 25, 2022 · 4 comments
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax responded The Holograph team has reviewed and responded sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographFactory.sol#L320-L335
https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographFactory.sol#L220

Vulnerability details

Impact

The _verifySigner() function in HolographFactory contract makes a ecrecover() call without checking for address(0) result. Due to user controlled signer input, it is possible for anyone to call the deployHolographableContract() function with address(0) as signer, and crafting signature input such that ecrecover() would return address(0) , then this will return true in _verifySigner() allowing the user to deploy contracts.

Proof of Concept

 return (ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), v, r, s) == signer ||
      ecrecover(hash, v, r, s) == signer);

The code snippet above is missing a check to ensure the ecrecover() result != address(0).

With above bug, Alice can;

  1. craft the signature input in HolographFactory.deployHolographableContract() to ensure ecrecover would return address(0).
  2. input address(0) as signer
  3. With signature and signer controlled by Alice, Alice calls deployHolographableContract and passes the require check in line 220 and is able to deploy contracts from the Factory contract.

Tools Used

Manual review

Recommended Mitigation Steps

Add a check to ensure that ecrecover returned result is not equals to address(0)

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Oct 25, 2022
code423n4 added a commit that referenced this issue Oct 25, 2022
@JustDravee
Copy link

I actually submitted this as QA, with way less details and no description of real impact though : #221
Nice report!

@gzeoneth gzeoneth added the disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) label Oct 28, 2022
@gzeoneth
Copy link
Member

true but lack exploit, doesn't seems the attacker can do anything with address(0) deployed a HolographableContract

@alexanderattar
Copy link

Low severity since it sets owner/admin to zero address, and would render the contract unusable

@alexanderattar alexanderattar added sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") responded The Holograph team has reviewed and responded labels Nov 8, 2022
@gzeoneth gzeoneth added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Nov 19, 2022
@gzeoneth
Copy link
Member

Consider with #303

@gzeoneth gzeoneth added the duplicate This issue or pull request already exists label Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax responded The Holograph team has reviewed and responded sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

4 participants