Prevent execution with invalid signatures
The Identity contract allowed a zero address to be added as a privileged signer during construction. If an invalid signature was used, the signature recovery function returned the zero address, which was then treated as privileged, allowing anyone to execute arbitrary transactions.
Submitted by gpersoon
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
Recommended Mitigation Steps
In the constructor of Identity.sol, add in the for loop the following:
require (addrs\[i] !=0,"Zero not allowed");
resolved in https://github.com/AmbireTech/adex-protocol-eth/commit/08d050676773fcdf7ec1c4eb53d51820b7e42534
GalloDaSballo (judge) commented:
This seems to be the risk of having
erecoverreturning 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
@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/IdentityProxyDeploywhich rolls out bytecode thatsstoresprivileges directly
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
Likely the constructor did not check that supplied addresses were non-zero, and the signature recovery function returned the zero address for invalid signatures, which was then treated as a valid privileged signer.
Impact
Anyone could perform any transaction on behalf of the contract if a zero address was accidentally included during construction.
What the attacker needed
Zero address included in constructor; attacker can call execute
The fix
The sponsor patched the issue by making the signature validator revert when recovering the zero address, and the judge recommended also adding a check in the constructor to disallow zero addresses.
How it was found
- Deploy the Identity contract with a zero address in the constructor's address list.
- Call the execute function with an invalid signature.
- The signature recovery returns the zero address, which is privileged, so the transaction executes.
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 smart contract had a list of trusted addresses. If one of those addresses was accidentally set to the special 'zero' address (which means 'no address'), then any invalid signature would be treated as coming from that zero address. Since the zero address was on the trusted list, anyone could then make the contract do things without proper authorisation.
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.