-
Notifications
You must be signed in to change notification settings - Fork 14
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
Arbitrary transactions possible due to insufficient signature validation #175
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
edited-by-warden
H-04
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Comments
code423n4
added
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
labels
Jan 7, 2023
gzeon-c4 marked the issue as primary issue |
c4-judge
added
the
primary issue
Highest quality submission among a set of duplicates
label
Jan 17, 2023
gzeon-c4 marked the issue as satisfactory |
c4-judge
added
the
satisfactory
satisfies C4 submission criteria; eligible for awards
label
Jan 17, 2023
This was referenced Jan 17, 2023
Closed
Closed
This was referenced Jan 17, 2023
Closed
c4-sponsor
added
the
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
label
Jan 19, 2023
livingrockrises marked the issue as sponsor confirmed |
#485 is not duplicate of this issue |
This was referenced Jan 19, 2023
#132 is not duplicate of this issue. |
c4-judge
added
the
selected for report
This submission will be included/highlighted in the audit report
label
Feb 10, 2023
gzeon-c4 marked the issue as selected for report |
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
Something isn't working
edited-by-warden
H-04
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L342
Vulnerability details
Impact
A hacker can create arbitrary transaction through the smart wallet by evading signature validation.
Major impacts:
Proof of Concept
The protocol supports contract signed transactions (eip-1271). The support is implemented in the
checkSignature
call when providing a transaction:https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L218
https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L342
checkSignature
DOES NOT Validate that the_signer
or caller is the owner of the contract.A hacker can craft a signature that bypasses the signature structure requirements and sets a hacker controlled
_signer
that always returnEIP1271_MAGIC_VALUE
from theisValidSignature
function.As
isValidSignature
returnsEIP1271_MAGIC_VALUE
and passed the requirements, the functioncheckSignatures
returns gracefully and the transaction execution will continue. Arbitrary transactions can be set by the hacker.Impact #1 - Self destruct and steal all funds
Consider the following scenario:
FakeSigner
that always returnsEIP1271_MAGIC_VALUE
SelfDestructingContract
thatselfdestruct
s when calledexecTransaction
functionSelfDestructingContract
function toselfdestruct
FakeSigner
that always returnsEIP1271_MAGIC_VALUE
Impact #2 - Update implementation and lock out EOA
FakeSigner
that always returnsEIP1271_MAGIC_VALUE
MaliciousImplementation
that is fully controlled ONLY by the hackerexecTransaction
functionupdateImplementation
function to update the implementation toMaliciousImplementation
. This is possible becauseupdateImplementation
permits being called fromaddress(this)
FakeSigner
that always returnsEIP1271_MAGIC_VALUE
MaliciousImplementation
Foundry POC
The POC will demonstrate impact #1. It will show that the proxy does not exist after the attack and EOAs cannot interact with the wallet.
The POC was built using the Foundry framework which allowed me to validate the vulnerability against the state of deployed contract on goerli (Without interacting with them directly). This was approved by the sponsor.
The POC use a smart wallet proxy contract that is deployed on
goerli
chain:proxy: 0x11dc228AB5BA253Acb58245E10ff129a6f281b09
You will need to install a foundry. Please follow these instruction for the setup:
https://book.getfoundry.sh/getting-started/installation
After installing, create a workdir by issuing the command:
forge init --no-commit
Create the following file in
test/DestroyWalletAndStealFunds.t.sol
:To run the POC and validate that the proxy does not exist after destruction:
Expected output:
To run the POC and validate that the EOA cannot interact with the wallet after destruction:
Expected output:
Tools Used
Foundry, VS Code
Recommended Mitigation Steps
The protocol should validate before calling
isValidSignature
that_signer
isowner
The text was updated successfully, but these errors were encountered: