Skip to content
Crypto Audit finding Advanced

Incorrect implementation of EIP- domain separat

The contract builds its EIP-712 domain separator using a type hash that does not match the expected domain type schema, so the separator is non-standard. The author states this does not directly introduce a security vulnerability but could cause signatures to fail validation externally and create mismatched assumptions between the contract and clients.

cheatcode Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

29002 - [SC - Insight] Incorrect implementation of EIP- domain separat...

Submitted on Mar 4th 2024 at 13:58:49 UTC by @cheatcode for Boost | eBTC

Report ID: #29002

Report type: Smart Contract

Report severity: Insight

Target: https://github.com/ebtc-protocol/ebtc/blob/release-0.7/packages/contracts/contracts/BorrowerOperations.sol

Impacts:

  • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

Description

Brief/Intro

See below

Vulnerability Details

EIP-712 provides a standard for signing typed structured data in Ethereum smart contracts, using the concept of domain separation to prevent collisions and replay attacks.

A key component of validation is the domain separator, which uniquely identifies the specific contract and chain for message signing purposes. The domain separator is constructed from:

  • DOMAIN_TYPEHASH: The keccak256 hash of the EIP-712 domain schema definition itself (the actual string types used like name, version etc.)
  • Contract Specific Values: Domain values like name, version, chain ID and contract address.

In the current contract, the _TYPE_HASH variable used in the domain separator construction does not match the expected DOMAIN_TYPEHASH. Upon closer inspection, it is aligned closer to the hash of the full message type itself rather than the domain type schema.

Impact Details

While this does not directly introduce security vulnerabilities per se, it indicates a gap in properly differentiating between DOMAIN_TYPEHASH and actual message TYPEHASH as EIP-712 expects

References

Add any relevant links to documentation or code

Proof of Concept

This could lead to the following issues:

  • Domain separators constructed incorrectly as per standards
  • Signatures validated against such separators fail externally
  • Mismatched assumptions between contract and clients
  • Confusing for future audit and maintenance

Recommendations

  1. Introduce a properly defined DOMAIN_TYPEHASH constant
  2. Construct domain separator by passing DOMAIN_TYPEHASH and contract-specific values
  3. Optionally validate both DOMAIN_TYPEHASH and message TYPEHASH on chain

This will greatly improve standards compliance, clarity and future security.

The original report as published on Immunefi, by cheatcode. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract used the message type hash instead of a dedicated DOMAIN_TYPEHASH constant when constructing the EIP-712 domain separator.

Impact

The author states this does not directly introduce security vulnerabilities, but it could cause signatures to fail external validation and create mismatched assumptions between the contract and clients.

What the attacker needed

None

The fix

The report recommends defining a proper DOMAIN_TYPEHASH constant and constructing the domain separator from it plus the contract-specific values.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

EIP-712 is a way for contracts to check that a signed message really came from a specific contract on a specific chain. It does this by mixing in a 'domain separator', a value built from a fixed type description plus details like the contract address and chain ID. Here the fixed type description used was the wrong one, so the separator does not follow the standard and other software may reject signatures made for this contract.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by cheatcode

View all

7 more disclosed reports, best first.

More from eBTC

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.