Sharp Mustard Gazelle
Medium
In the Ethos protocol’s createAttestation
function, the signature validation process accepts signatures formatted as standard Ethereum-signed messages (see https://eips.ethereum.org/EIPS/eip-191). This introduces a vulnerability where signatures meant for Ethereum transactions and signed by the expectedSigner
can be reused to forge attestations within the Ethos protocol. This could undermine trust in the attestations, as malicious actors may create false attestations by reusing valid Ethereum transaction signatures.
The createAttestation
function uses the SignatureControl library to validate attestation signature. The validateSignature
calls the signatureVerifier
contract without modifying the message hash. At the end the signature is verified as following:
function verifySignature(
address expectedSigner,
bytes32 messageHash,
bytes memory signature
) external view returns (bool) {
bytes32 ethSignedMessageHash = _getEthSignedMessageHash(messageHash);
return SignatureChecker.isValidSignatureNow(expectedSigner, ethSignedMessageHash, signature);
}
function _getEthSignedMessageHash(bytes32 messageHash) private pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", messageHash));
}
The vulnerability arises because verifySignature
uses Ethereum's default signature format (\x19Ethereum Signed Message:\n
+ message.length
+ message
). This format is widely used for transaction messages, so a signature intended for an Ethereum transaction can be reused within the Ethos protocol to falsely validate attestations, provided the message hash can be crafted similarly. See Web3.js documentation for example: https://web3js.readthedocs.io/en/v1.2.11/web3-eth-accounts.html#id13. Most of wallets also follow this method.
No response
- The
expectedSigner
has to sign an ethereum transaction.
- An Ethos-authorized signer creates a valid Ethereum transaction with a public signature.
- The attacker obtains the signer’s publicly available transaction signature.
- The attacker manipulates the
createAttestation
parameters to match the message hash of the original Ethereum transaction. - Using the obtained signature, the attacker submits a false attestation to the Ethos protocol. Due to Ethereum's signing format, Ethos incorrectly validates the forged signature.
Compromising the protocol’s integrity by allowing unauthorized or fabricated attestations.
No response
Implement EIP-712-compliant signing for attestations to ensure that only specifically formatted signatures intended for Ethos attestations are valid, preventing signature reuse from unrelated Ethereum transactions.