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

Prevent execution with invalid signatures #13

Open
code423n4 opened this issue Oct 16, 2021 · 4 comments
Open

Prevent execution with invalid signatures #13

code423n4 opened this issue Oct 16, 2021 · 4 comments
Assignees
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Warden finding disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate Another warden found this issue resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) 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

Handle

gpersoon

Vulnerability details

Impact

Suppose one of the supplied addrs[i] to the constructor of Identity.sol happens to be 0 ( by accident).

In that case: privileges[0] = 1

Now suppose you call execute() with an invalid signature, then recoverAddrImpl will return a value of 0 and thus signer=0.
If you then check "privileges[signer] !=0" this will be true and anyone can perform any transaction.

This is clearly an unwanted situation.

Proof of Concept

https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/Identity.sol#L23-L30

https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/Identity.sol#L97-L98

Tools Used

Recommended Mitigation Steps

In the constructor of Identity.sol, add in the for loop the following:
require (addrs[i] !=0,"Zero not allowed");

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Warden finding labels Oct 16, 2021
code423n4 added a commit that referenced this issue Oct 16, 2021
@Ivshti
Copy link
Member

Ivshti commented Oct 19, 2021

duplicate of #2

@Ivshti Ivshti added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate Another warden found this issue sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Oct 19, 2021
@Ivshti
Copy link
Member

Ivshti commented Oct 19, 2021

resolved in AmbireTech/adex-protocol-eth@08d0506

@Ivshti Ivshti added the resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) label Oct 19, 2021
@Ivshti Ivshti self-assigned this Oct 19, 2021
@GalloDaSballo
Copy link
Collaborator

This seems to be the risk of having erecover returning zero, any invalid signature ends up being usable from any address to execute arbitrary logic.

Mitigation can be achieved by either reverting when about to return address(0), which the sponsor has used for mitigation

The other mitigation is to ensure that an account with address(0) cannot have privileges set to 1

I believe mitigation from sponsor to be sufficient, however I'd recommend adding a check against having address(0) in the constructor for Identity.sol just to be sure

@Ivshti
Copy link
Member

Ivshti commented Oct 21, 2021

@GalloDeSballo an extra check is superfluous IMO, not only cause the revert on 0 in SIgnatureValidatorV2 guarantees that this is fixed, but also because it has to be in three places: constructor, setAddrPrivilege and the account creation system in js/IdentityProxyDeploy which rolls out bytecode that sstores privileges directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Warden finding disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate Another warden found this issue resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) 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

3 participants