Skip to content

jco: host hardening — internals coupling, signature-key extractability, JWK exposure, scalar validation #28

Description

@lann
  • jco internals coupling. webcrypto.js throws bare { tag: ... } literals throughout and sniffs three stream shapes in collectByteStream (jco-impl/webcrypto.js:580-615); both depend on undocumented jco conventions. Isolate behind small helpers and note the jco version they were validated against. (The same convention-sniffing appears in examples/jco-demo/src/run.mjs:15-22.) (Migrated from TODO.md.)
  • README overclaims platform enforcement of extractability. README.md:27-28 says "extractable: false keys refuse export-key (on the jco host the platform CryptoKey itself enforces this)". True for HMAC/AES keys — false for signature keys: Ed25519/ECDSA private keys are deliberately imported/generated platform-extractable (jco-impl/webcrypto.js:845, 855, 909-915, 958-963) so the public half and export can be derived, and the WIT gate is a JS-level boolean (webcrypto.js:763-777). Defensible design, weaker guarantee than documented. Fix the README; document the actual guarantee in the file.
  • JWK d-string exposure. SigningKey.exportKey materializes the private scalar as a JWK d string plus atob (webcrypto.js:773-788) — immortal, unscrubable JS strings holding key material. Document the exposure; consider alternatives.
  • ECDSA scalar-range validation is delegated and untested. importEcdsaSigningKey wraps the raw scalar in hand-rolled PKCS#8 and trusts the platform to reject zero/out-of-range scalars (webcrypto.js:893-924); the Rust implementations reject definitively via SigningKey::from_slice. No conformance probe pins the out-of-range case on a jco target (the signing-guest runs only under wasmtime).

First item migrated from TODO.md; the rest from the 2026-07 whole-repo review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions