You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All three shares are required to recover the secret, and the binding ensures the three problem instances are cryptographically linked.
157
157
158
+
> ⚠️ Implementation note: the library prefers native SHAKE256 (XOF) support. If the runtime lacks native SHAKE256, kMOSAIC falls back to a counter-mode SHA3-256 based construction which may not provide the same security margins as a native XOF. For production deployments, ensure your runtime supports SHAKE256 or use an environment that provides it.
Copy file name to clipboardExpand all lines: SECURITY_REPORT.md
+41-8Lines changed: 41 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,27 @@ while (idx < n) {
181
181
182
182
This eliminates statistical bias by rejecting values that would cause modular reduction bias.
183
183
184
+
### VULN-014: Decapsulation throws on malformed ciphertext (implicit oracle)
185
+
186
+
**File:**`src/kem/index.ts`
187
+
**Lines:** 360-420 (approx)
188
+
**Status:** ✅ **FIXED**
189
+
190
+
#### Description
191
+
192
+
Certain malformed or corrupted ciphertexts (for example, a truncated NIZK proof or malformed fragment lengths) could cause `decapsulate()` to throw exceptions or exhibit distinguishable behavior. This could be used as a decryption oracle by an attacker to learn about ciphertext validity.
193
+
194
+
#### Fix Applied
195
+
196
+
- Compute the **implicit rejection value** early from the raw ciphertext bytes and use it as the default return value on any validation failure.
197
+
- Wrap critical parsing and verification steps in try/catch blocks: serialization, component decryption (SLSS/TDD/EGRW), NIZK deserialization and verification, and re-encapsulation. Any failure marks decapsulation as invalid but does not throw.
198
+
- Normalize share lengths (expect 32-byte shares) and use zeroed fallbacks to avoid reconstruction exceptions.
199
+
- Replace direct ciphertext byte comparison with fixed-length SHA3-256 hash comparisons to avoid leaks from variable-length ciphertexts.
200
+
- Add a public key consistency check: `sha3_256(serializePublicKey(publicKey)) === secretKey.publicKeyHash`; treat mismatches as invalid decapsulation.
201
+
- Added unit tests exercising tampering and malformed inputs: `test/kem-malformed.test.ts`.
202
+
203
+
These changes ensure `decapsulate()` always returns a 32-byte pseudorandom secret (implicit reject) on invalid input, preventing oracle-style leakage.
204
+
184
205
---
185
206
186
207
### VULN-005: Potential Integer Precision Issues
@@ -257,17 +278,21 @@ JavaScript's garbage collector may copy buffer contents during compaction. The `
257
278
258
279
**File:**`src/utils/shake.ts`
259
280
**Lines:** 82-100
260
-
**Status:**🟡 ACKNOWLEDGED
281
+
**Status:**✅ MITIGATED
261
282
262
283
#### Description
263
284
264
285
The counter-mode SHA3-256 fallback is not a proven XOF construction. While unlikely to be used on Node.js/Bun, security properties are unverified.
265
286
266
-
#### Mitigation
287
+
#### Mitigation / Fix Applied
267
288
268
-
- Native SHAKE256 is available in all target environments (Node.js 18+, Bun)
269
-
- Fallback only triggers in edge cases
270
-
- Consider adding warning log when fallback is used
289
+
- Added `isNativeShake256Available()` helper to allow application code to detect and enforce native SHAKE256 availability.
290
+
- Added an explicit README note advising production deployments to use native SHAKE256 or a runtime that supports it.
291
+
- Fallback continues to exist for compatibility, but the above mitigations reduce the risk and make it visible to operators.
292
+
293
+
#### Recommendation
294
+
295
+
For highest assurance, consider adding a configuration flag that causes startup to fail when native SHAKE256 is unavailable.
271
296
272
297
---
273
298
@@ -370,6 +395,7 @@ Generator cache creates timing differences between cache hits and misses, potent
@@ -397,9 +423,16 @@ Generator cache creates timing differences between cache hits and misses, potent
397
423
398
424
The kMOSAIC implementation has been assessed and critical security issues have been remediated:
399
425
400
-
1.**VULN-001 (TDD Plaintext):** Now uses XOR encryption with keystream derived from the masked tensor matrix
401
-
2.**VULN-002 (EGRW Randomness):** Randomness no longer exposed; ephemeral walk vertex used instead
402
-
3.**VULN-004 (Modular Bias):** Rejection sampling now ensures uniform distribution
426
+
1.**VULN-001 (TDD Plaintext):** Now uses XOR encryption with keystream derived from the masked tensor matrix2. **VULN-002 (EGRW randomness exposure):** Now derives ciphertext endpoints from ephemeral walks and does not expose randomness
427
+
2.**VULN-004 (Modular bias):** Rejection sampling implemented in TDD sampling
428
+
3.**VULN-014 (Decapsulation oracle):** Decapsulation hardened to return implicit-reject values on malformed or tampered ciphertexts; added unit tests to verify behavior
429
+
430
+
Additional improvements:
431
+
432
+
- Added `isNativeShake256Available()` and README guidance to make SHAKE256 availability explicit for production deployments.
433
+
- Added robust unit tests for malformed/corrupted ciphertext handling: `test/kem-malformed.test.ts` (proof tampering, malformed fragments, truncated ciphertexts, publicKey mismatch).
434
+
435
+
Overall, the most critical issues have been remediated and the codebase now includes tests that guard against malformed ciphertext behavior and oracle leakage. Continuous monitoring and peer review are recommended for the remaining acknowledged limitations (timing, zeroization limits, and JS runtime concerns).2. **VULN-002 (EGRW Randomness):** Randomness no longer exposed; ephemeral walk vertex used instead 3. **VULN-004 (Modular Bias):** Rejection sampling now ensures uniform distribution
403
436
404
437
The remaining acknowledged items are primarily JavaScript runtime limitations that are well-documented in the code and do not constitute exploitable vulnerabilities in typical deployment scenarios.
0 commit comments