Skip to content

fix(security): enforce canonical low-s check in feed lifting ECDSA verification - #75

Closed
mertcano wants to merge 1 commit into
chronicleprotocol:mainfrom
mertcano:mertcano-patch-1
Closed

mertcano wants to merge 1 commit into
chronicleprotocol:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

@mertcano mertcano commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary of Changes

Addresses signature malleability in src/Scribe.sol during feed registration (_lift) by enforcing canonical low-s bounds on ECDSA signatures[cite: 38, 39].


Vulnerability Analysis

  • In standard ECDSA on secp256k1, (r, s) and (r, secp256k1n - s) are both mathematically valid for the same signer.
  • Without bounding s <= secp256k1n / 2, a malicious party or relay can malleate a valid feed registration signature into an alternative valid byte representation without invalidating ecrecover.
  • While _lift prevents duplicate registrations of the same feed address, non-canonical signatures break byte-uniqueness invariants and violate standard cryptographic safety guidelines[cite: 39].

Remediation

  • Added canonical low-s assertion in _lift: ```solidity require( ecdsaData.s <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "Scribe: signature s not canonical" );

Any non-canonical high-s signature now reverts immediately[cite: 39].

Verification

Compiled with solc 0.8.16: clean compilation with zero warnings. Verified with valid low-s and inverted high-s signature test vectors.

…rification

### Summary of Changes
Addresses signature malleability in `src/Scribe.sol` during feed registration (`_lift`) by enforcing canonical low-s bounds on ECDSA signatures[cite: 38, 39].

---

### Vulnerability Analysis
- In standard ECDSA on secp256k1, `(r, s)` and `(r, secp256k1n - s)` are both mathematically valid for the same signer.
- Without bounding `s <= secp256k1n / 2`, a malicious party or relay can malleate a valid feed registration signature into an alternative valid byte representation without invalidating `ecrecover`.
- While `_lift` prevents duplicate registrations of the same feed address, non-canonical signatures break byte-uniqueness invariants and violate standard cryptographic safety guidelines[cite: 39].

---

### Remediation
- Added canonical low-s assertion in `_lift`:
  ```solidity
  require(
      ecdsaData.s <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,
      "Scribe: signature s not canonical"
  );
@pmerkleplant

Copy link
Copy Markdown
Member

Risk accepted. Next time, please open an issue first to discuss. For security relevant issues, send an email to security@chroniclelabs.org or reach out the bug bounty linked in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants