@integraledger/lcp-binding-evm-common 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @integraledger/lcp-binding-evm-common
2
2
 
3
+ ## 0.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1da6c07: `verifyEip3009Signature` threw on an attacker-chosen signature instead of answering `false`. Its docblock
8
+ promises the opposite — it "Answers `false` rather than throwing for the two UNTRUSTED inputs" — and a
9
+ seller pre-flighting an inbound x402 `PaymentPayload` was crashed by a hand-built 65-byte string that costs
10
+ no key, no chain and no funds to produce.
11
+
12
+ `isCanonicalSignature` checked shape, low-s and `v ∈ {27, 28}`, and not that `r` and `s` are in range.
13
+ Measured: `r=0x11…, s=0` threw, `r=0, s=0x11…` threw, and `r` at or above `n` threw. `"not-a-signature"`
14
+ was the only malformed shape the suite drove, and the regex already refused that — so every gate past the
15
+ regex was untested against a hostile value.
16
+
17
+ The range rules are the token's, on the same footing low-s is: `ecrecover` answers the ZERO ADDRESS rather
18
+ than reverting for `r = 0`, `s = 0` or a component at or above `n`, and OpenZeppelin's `ECRecover.recover`
19
+ — which `FiatTokenV2` routes through — reverts on the zero signer. `1 <= r < n` and `s !== 0` are now part
20
+ of the predicate. Low-s already caps `s` below `n/2`, so on the `s` side the only value the rule adds is
21
+ zero.
22
+
23
+ The gates went into the predicate rather than a `try` in the caller deliberately: a `try` would also swallow
24
+ an unencodable `typedData`, which is this deployment's own domain being wrong, and would tell an operator
25
+ with a mis-copied `tokenName` that every honest payer is a forger. That case still throws, as the head note
26
+ reserves.
27
+ - Updated dependencies [83ae16e]
28
+ - Updated dependencies [431b8ec]
29
+ - Updated dependencies [9c42f73]
30
+ - @integraledger/lcp-kernel@0.15.1
31
+ - @integraledger/lcp-binding-core@0.15.1
32
+ - @integraledger/lcp-authority@0.15.1
33
+
3
34
  ## 0.15.0
4
35
 
5
36
  ### Patch Changes
package/dist/eip3009.d.ts CHANGED
@@ -104,10 +104,11 @@ export interface LcpEvmSigner {
104
104
  /**
105
105
  * Whether the 65-byte signature is one `FiatTokenV2` will accept at all, before asking who signed it.
106
106
  *
107
- * Not a style check. Both rules come straight out of the token's `ECRecover.sol`, and skipping either one
108
- * turns {@link verifyEip3009Signature} from *"the chain will accept this"* into *"some chain might"*.
107
+ * Not a style check. Every rule comes straight out of the token's `ECRecover.sol` and the `ecrecover`
108
+ * precompile beneath it, and skipping any one turns {@link verifyEip3009Signature} from *"the chain will
109
+ * accept this"* into *"some chain might"* — or, for the range rules, into a throw.
109
110
  *
110
- * ⭐ Exported so the boundary is reachable by a test. `s === n/2` is ACCEPTED (the token's guard is
111
+ * ⭐ Exported so the boundaries are reachable by a test. `s === n/2` is ACCEPTED (the token's guard is
111
112
  * `s > n/2`), and no signing run will ever produce that value — so an off-by-one there is invisible from
112
113
  * the public predicate, where such a signature simply fails to recover and answers `false` either way.
113
114
  */
@@ -1 +1 @@
1
- {"version":3,"file":"eip3009.d.ts","sourceRoot":"","sources":["../src/eip3009.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,GAAG,EAER,KAAK,eAAe,EACrB,MAAM,MAAM,CAAC;AAEd,qFAAqF;AACrF,eAAO,MAAM,gCAAgC;aAC3C,yBAAyB;iBACrB,IAAI,EAAE,MAAM;iBAAE,IAAI,EAAE,SAAS;;iBAC7B,IAAI,EAAE,IAAI;iBAAE,IAAI,EAAE,SAAS;;iBAC3B,IAAI,EAAE,OAAO;iBAAE,IAAI,EAAE,SAAS;;iBAC9B,IAAI,EAAE,YAAY;iBAAE,IAAI,EAAE,SAAS;;iBACnC,IAAI,EAAE,aAAa;iBAAE,IAAI,EAAE,SAAS;;iBACpC,IAAI,EAAE,OAAO;iBAAE,IAAI,EAAE,SAAS;;CAE1B,CAAC;AAEX;kFACkF;AAClF,wBAAgB,aAAa,C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G;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,iBAAiB,GAAG;IAC3D,aAAa,EAAE,oBAAoB,CAAC;IACpC,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CA+BA;AAED,qHAAqH;AACrH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAClB;AA2BD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAmB/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CAgBlB"}
package/dist/eip3009.js CHANGED
@@ -80,13 +80,25 @@ export function buildEip3009TypedData(i) {
80
80
  * credential the chain refuses, and the seller has already served the resource by then.
81
81
  */
82
82
  const SECP256K1_HALF_N = 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;
83
+ /**
84
+ * secp256k1's group order — the range `ecrecover` itself requires of `r` and `s`.
85
+ *
86
+ * ⛔ **The gate low-s does not cover, and the one a hostile counterparty reaches for.** `ecrecover` answers
87
+ * the ZERO ADDRESS rather than reverting for `r = 0`, `s = 0`, or either component at or above `n`, and
88
+ * OpenZeppelin's `ECRecover.recover` — which `FiatTokenV2` routes through — then reverts on the zero
89
+ * signer. These are refusals of the TOKEN on exactly the footing low-s is, so they belong in the same
90
+ * predicate rather than in a caller's `try`. Low-s already caps `s` below `n/2`, so on the `s` side the
91
+ * only value this rule adds is zero.
92
+ */
93
+ const SECP256K1_N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
83
94
  /**
84
95
  * Whether the 65-byte signature is one `FiatTokenV2` will accept at all, before asking who signed it.
85
96
  *
86
- * Not a style check. Both rules come straight out of the token's `ECRecover.sol`, and skipping either one
87
- * turns {@link verifyEip3009Signature} from *"the chain will accept this"* into *"some chain might"*.
97
+ * Not a style check. Every rule comes straight out of the token's `ECRecover.sol` and the `ecrecover`
98
+ * precompile beneath it, and skipping any one turns {@link verifyEip3009Signature} from *"the chain will
99
+ * accept this"* into *"some chain might"* — or, for the range rules, into a throw.
88
100
  *
89
- * ⭐ Exported so the boundary is reachable by a test. `s === n/2` is ACCEPTED (the token's guard is
101
+ * ⭐ Exported so the boundaries are reachable by a test. `s === n/2` is ACCEPTED (the token's guard is
90
102
  * `s > n/2`), and no signing run will ever produce that value — so an off-by-one there is invisible from
91
103
  * the public predicate, where such a signature simply fails to recover and answers `false` either way.
92
104
  */
@@ -98,7 +110,16 @@ export function isCanonicalSignature(signature) {
98
110
  const parts = /^0x([0-9a-fA-F]{64})([0-9a-fA-F]{64})([0-9a-fA-F]{2})$/.exec(signature);
99
111
  if (parts === null)
100
112
  return false;
101
- if (BigInt(`0x${parts[2]}`) > SECP256K1_HALF_N)
113
+ const r = BigInt(`0x${parts[1]}`);
114
+ const s = BigInt(`0x${parts[2]}`);
115
+ // RANGE before malleability. `1 <= r < n` and `s !== 0`: outside these the recovery does not merely
116
+ // yield the wrong answer, it raises — which is how an attacker-chosen 65 bytes, costing no key, no
117
+ // chain and no funds, crashed a seller pre-flighting an inbound payload instead of being refused.
118
+ if (r === 0n || r >= SECP256K1_N)
119
+ return false;
120
+ if (s === 0n)
121
+ return false;
122
+ if (s > SECP256K1_HALF_N)
102
123
  return false;
103
124
  const v = Number.parseInt(parts[3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,KAAK,CAAC;IAC3B,IAAI,CAAC,GAAG,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,SAA2B,EAC3B,SAAiB,EACjB,cAAsB;IAEtB,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,cAAc,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,uGAAuG;IACvG,uGAAuG;IACvG,yDAAyD;IACzD,MAAM,SAAS,GAAY,MAAM,uBAAuB,CAAC;QACvD,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,SAAS,EAAE,SAAgB;KAC5B,CAAC,CAAC;IACH,oGAAoG;IACpG,6DAA6D;IAC7D,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,UAAU,CAAC,cAAc,CAAC,CAAC;AAC9D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraledger/lcp-binding-evm-common",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Shared EVM machinery for LCP rail bindings: typed-data construction and signature verification.",
5
5
  "keywords": [
6
6
  "lcp",
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "homepage": "https://github.com/IntegraLedger/integra-protocol/tree/main/packages/binding-evm-common#readme",
45
45
  "dependencies": {
46
- "@integraledger/lcp-authority": "0.15.0",
47
- "@integraledger/lcp-binding-core": "0.15.0",
48
- "@integraledger/lcp-kernel": "0.15.0",
46
+ "@integraledger/lcp-authority": "0.15.1",
47
+ "@integraledger/lcp-binding-core": "0.15.1",
48
+ "@integraledger/lcp-kernel": "0.15.1",
49
49
  "viem": "2.55.19"
50
50
  },
51
51
  "devDependencies": {
package/src/eip3009.ts CHANGED
@@ -159,13 +159,27 @@ export interface LcpEvmSigner {
159
159
  const SECP256K1_HALF_N =
160
160
  0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;
161
161
 
162
+ /**
163
+ * secp256k1's group order — the range `ecrecover` itself requires of `r` and `s`.
164
+ *
165
+ * ⛔ **The gate low-s does not cover, and the one a hostile counterparty reaches for.** `ecrecover` answers
166
+ * the ZERO ADDRESS rather than reverting for `r = 0`, `s = 0`, or either component at or above `n`, and
167
+ * OpenZeppelin's `ECRecover.recover` — which `FiatTokenV2` routes through — then reverts on the zero
168
+ * signer. These are refusals of the TOKEN on exactly the footing low-s is, so they belong in the same
169
+ * predicate rather than in a caller's `try`. Low-s already caps `s` below `n/2`, so on the `s` side the
170
+ * only value this rule adds is zero.
171
+ */
172
+ const SECP256K1_N =
173
+ 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
174
+
162
175
  /**
163
176
  * Whether the 65-byte signature is one `FiatTokenV2` will accept at all, before asking who signed it.
164
177
  *
165
- * Not a style check. Both rules come straight out of the token's `ECRecover.sol`, and skipping either one
166
- * turns {@link verifyEip3009Signature} from *"the chain will accept this"* into *"some chain might"*.
178
+ * Not a style check. Every rule comes straight out of the token's `ECRecover.sol` and the `ecrecover`
179
+ * precompile beneath it, and skipping any one turns {@link verifyEip3009Signature} from *"the chain will
180
+ * accept this"* into *"some chain might"* — or, for the range rules, into a throw.
167
181
  *
168
- * ⭐ Exported so the boundary is reachable by a test. `s === n/2` is ACCEPTED (the token's guard is
182
+ * ⭐ Exported so the boundaries are reachable by a test. `s === n/2` is ACCEPTED (the token's guard is
169
183
  * `s > n/2`), and no signing run will ever produce that value — so an off-by-one there is invisible from
170
184
  * the public predicate, where such a signature simply fails to recover and answers `false` either way.
171
185
  */
@@ -178,7 +192,14 @@ export function isCanonicalSignature(signature: string): boolean {
178
192
  signature,
179
193
  );
180
194
  if (parts === null) return false;
181
- if (BigInt(`0x${parts[2] as string}`) > SECP256K1_HALF_N) return false;
195
+ const r = BigInt(`0x${parts[1] as string}`);
196
+ const s = BigInt(`0x${parts[2] as string}`);
197
+ // RANGE before malleability. `1 <= r < n` and `s !== 0`: outside these the recovery does not merely
198
+ // yield the wrong answer, it raises — which is how an attacker-chosen 65 bytes, costing no key, no
199
+ // chain and no funds, crashed a seller pre-flighting an inbound payload instead of being refused.
200
+ if (r === 0n || r >= SECP256K1_N) return false;
201
+ if (s === 0n) return false;
202
+ if (s > SECP256K1_HALF_N) return false;
182
203
  const v = Number.parseInt(parts[3] as string, 16);
183
204
  return v === 27 || v === 28;
184
205
  }