Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 2.38 KB

File metadata and controls

61 lines (39 loc) · 2.38 KB

Quiet Cyan Hyena

High

Malicious user can steal another's attestation.

Summary

EthosAttestation._keccakForCreateAttestation() function uses abi.encodePacked(), which is vulnerable to hash collision attacks. By exploiting this vulnerability, malicious user can steal another user's attestation.

https://github.com/sherlock-audit/2024-10-ethos-network/blob/main/ethos/packages/contracts/contracts/EthosAttestation.sol#L528

Root Cause

EthosAttestation._keccakForCreateAttestation() function is following.

  function _keccakForCreateAttestation(
    uint256 profileId,
    uint256 randValue,
    string calldata account,
    string calldata service,
    string calldata evidence
  ) private pure returns (bytes32) {
    return keccak256(abi.encodePacked(profileId, randValue, account, service, evidence));
  }

As can be seen, the function uses abi.encodePacked() to encode the message. Here service refers to the social media service (e.g., x.com or fb.com) and account refers to the user's account name (e.g., benwalther256 or ivansolo512). Since there is no restrictions on service and account, this can lead to hash collisions. By exploiting this vulnerability, a malicious user can steal another user's attestation.

Internal pre-conditions

No response

External pre-conditions

There must exist social media services whose names have an inclusion relationship (e.g., fb.com and xfb.com).

Attack Path

  1. Assume that there exist social media services named fb.com and xfb.com.
  2. A user has an account named auser on xfb.com with a high reputation.
  3. An attacker creates an account named auserx on fb.com.
  4. The attacker obtains a signature sig1 in Ethos web app using account = 'auserx' and service = 'fb.com'.
  5. The attacker creates an attestation by calling EthosAttestation.createAttestation() function with account = 'auser', service = 'xfb.com' and signature = 'sig1'.
  6. Thus the attacker has stolen attestation from another user with a high reputation.

Impact

A malicious attacker can increase his reputation by stealing another user's attestation. This harms the legitimate user by stealing their account attestation and reputation.

PoC

No response

Mitigation

Use abi.encode() function instead of abi.encodePacked() in the EthosAttestation._keccakForCreateAttestation() to avoid hash collisions.