AddOwner functions lack validation, risking invalid owner data and transaction failures. #23
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
insufficient quality report
This report is not of sufficient quality
primary issue
Highest quality submission among a set of duplicates
Q-25
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_21_group
AI based duplicate group recommendation
Lines of code
https://github.com/code-423n4/2024-03-coinbase/blob/e0573369b865d47fed778de00a7b6df65ab1744e/src/SmartWallet/MultiOwnable.sol#L85-L87
https://github.com/code-423n4/2024-03-coinbase/blob/e0573369b865d47fed778de00a7b6df65ab1744e/src/SmartWallet/MultiOwnable.sol#L93-L95
Vulnerability details
Overview
MultiOwnable contract allows adding owners by providing an Ethereum address or a WebAuthn public key. However, there is a lack of proper input validation when adding owners, which could potentially lead to the addition of invalid or malformed owner data. This may result in signature validation failures for the affected owners, effectively bricking their ability to execute transactions.
Description
addOwnerAddress
andaddOwnerPublicKey
, which are responsible for adding new owners to the SmartWallet contract.addOwnerAddress
function:addOwnerPublicKey
function:Both functions take the owner data (Ethereum address or WebAuthn public key) as input, encode it using
abi.encode
, and pass it to the internal_addOwner
function.The issue lies in the lack of proper input validation when adding owners using the
addOwnerAddress
andaddOwnerPublicKey
functions.#L86
and #L94
These lines encode the owner data without any prior validation and pass it to the
_addOwner
function, which adds the owner to the contract's storage.The expected behavior is that only valid Ethereum addresses and WebAuthn public keys should be accepted as owners when calling the
addOwnerAddress
andaddOwnerPublicKey
functions, respectively. The functions should perform proper input validation to ensure the integrity and validity of the owner data before adding it to the contract.If the owner data is invalid or malformed, the signature validation will always fail for that specific owner, effectively bricking their ability to execute transactions.
Impact
Owners with invalid Ethereum addresses or malformed WebAuthn public keys will be unable to execute transactions, as the signature validation will always fail for them.
Recommended Mitigation Steps
For
addOwnerAddress
function:function addOwnerAddress(address owner) public virtual onlyOwner { + require(owner != address(0), "Invalid Ethereum address"); _addOwner(abi.encode(owner)); }
For
addOwnerPublicKey
function:function addOwnerPublicKey(bytes32 x, bytes32 y) public virtual onlyOwner { + require(isValidWebAuthnPublicKey(x, y), "Invalid WebAuthn public key"); _addOwner(abi.encode(x, y)); } function isValidWebAuthnPublicKey(bytes32 x, bytes32 y) internal pure returns (bool) { // Implement WebAuthn public key validation logic // Example: Check if the point (x, y) is on the secp256r1 curve // ... }
These measures ensure that only valid Ethereum addresses and WebAuthn public keys are accepted as owners. The
addOwnerAddress
function checks if the provided address is not the zero address, while theaddOwnerPublicKey
function includes a separate validation function (isValidWebAuthnPublicKey
) to check the validity of the WebAuthn public key.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: