Closed c4-bot-4 closed 8 months ago
raymondfam marked the issue as insufficient quality report
raymondfam marked the issue as primary issue
Verification check should be QA at best considering the call would still fail and no exploit could be made.
The core claim:
An attacker could provide an empty or malformed clientDataJSON string that would still pass the keccak256 check against EXPECTED_TYPE_HASH. This could allow the attacker to bypass the verification process and potentially exploit the contract.
is not true. All the if
in the verify
functions end with a return false;
, so there is no opportunity to "bypass the signature verification".
3docSec marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-03-coinbase/blob/e0573369b865d47fed778de00a7b6df65ab1744e/src/WebAuthnSol/WebAuthn.sol#L104-L162
Vulnerability details
Impact
The
WebAuthn.sol
contract which is a very critical component of the smart wallet system and is designed to verify WebAuthn Authentication Assertions. The contract's current implementation does not explicitly validate the length of theclientDataJSON string
or the extracted slices, such as_type
. This could potentially enable an attacker to exploit the contract by providing an empty or malformed clientDataJSON string that would still pass the validation checks.To add more context,
slice
function in Solidity does not inherently validate the length of the extracted substring; it simply extracts a substring based on the provided indices. If theclientDataJSON
string is shorter than expected, the slice function will return an empty string or a string shorter than expected, which could still pass thekeccak256
check if the expected hash value is also derived from an empty or shorter string 45.The
keccak256
hash function is deterministic and will produce the same output for different inputs of the same length, even if the content is different. This means that if an attacker can manipulate the input string to be of the same length as the expected input, they could potentially bypass the validation checks by providing a malformed or emptyclientDataJSON
string that still results in a validkeccak256
hash when compared againstEXPECTED_TYPE_HASH
Contract Analysis:
The
WebAuthn.sol
contract includes averify
function that processes aWebAuthnAuth
struct, which contains aclientDataJSON
string. This string is sliced to extract the type and challenge, but the contract lacks explicit checks to ensure that theclientDataJSON
string is of the expected length or that the extracted slices are not empty.https://github.com/code-423n4/2024-03-coinbase/blob/e0573369b865d47fed778de00a7b6df65ab1744e/src/WebAuthnSol/WebAuthn.sol#L116-L119
Potential Exploit:
An attacker could provide an empty or malformed
clientDataJSON
string that would still pass thekeccak256
check againstEXPECTED_TYPE_HASH
. This could allow the attacker to bypass the verification process and potentially exploit the contract.POC Test Contract:
To demonstrate the potential issue, a test contract could be created that attempts to call the
verify
function with an empty or malformedclientDataJSON
string. The test contract should be designed to pass thekeccak256
check but fail the length check, thus demonstrating the vulnerability.Recommended Mitigation Steps:
Explicit length checks for the
clientDataJSON
string and the extracted slices should be included. This can be done by adding require statements to ensure that theclientDataJSON
string is not empty and that the extracted slices are of the expected length.Assessed type
Other