Repository navigation
fix: guards and documentation from the 2.1.0 review, and runtime smoke tests in CI - #31
Merged
Merged
Conversation
Owner
Author
|
Review: no blocking finding. Pushed one commit on top: the runtime claim is narrowed to what CI runs (Bun, Deno, headless Chrome; Firefox and Safari are not tested), and the release is prepared as 2.1.1 (version, changelog date, SECURITY.md entry). The Bun and Deno smoke jobs are now required checks on main. |
While allowLegacy is on, an envelope above the cap is still tried once as a headerless 1.x value at 100,000 iterations before INVALID_ITERATIONS. The 2.1.0 wording said no key was derived at all, which only holds with allowLegacy: false.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes and documentation from a review of 2.1.0. One commit per finding.
Changes
1. Passwords are not Unicode-normalized: documented and pinned (docs)
A password typed in NFC (
café, precomposed) does not decrypt data written with its NFD form (e+ U+0301):DECRYPTION_FAILED. How a password becomes bytes is not changed: normalizing inside the package would change the key of every non-ASCII password already in use and would need a new envelope version.SECURITY.mdthreat model tell callers to normalize consistently before every call, e.g.password.normalize('NFC').V2_UNICODE_PASSWORDalready pinned the NFD side against frozen bytes.2. Non-string plaintext and context are refused (fix)
From untyped JavaScript,
encrypt(undefined, pw)encrypted"",encrypt({a:1}, pw)encrypted"[object Object]",encrypt(123, pw)encrypted"123";context: 42was coerced and any two objects bound to the same"[object Object]".assertPlaintextinsrc/crypto/guards.ts;assertContextnow also checks the type.encrypt()refuses a non-string plaintext;encrypt(),decrypt(),rewrap()(bothcontextandpreviousContext) andAesGcmEncryptorrefuse a non-string context. All withINVALID_ARGUMENT.undefinedstill means no context (tested).AesGcmEncryptorandSecureStorageserialize to JSON and always pass a string plaintext; their existing tests pass unchanged.3. Per-call
iterationsabove the instance'smaxIterationsis refused (fix)new AesGcmEncryptor({ maxIterations: 600_000 }).encrypt(data, pw, { iterations: 700_000 })succeeded, then the same instance refused to read it.AesGcmEncryptor.encrypt()now refuses the write withINVALID_ARGUMENT, the code and wording style of the existing constructor check, before any key derivation. Without amaxIterations, per-call counts are unchanged.4. CI proves the runtimes the README names (ci)
Smoke-test the packed tarball on Bun / Deno: builds, packs, installs the tarball into a consumer project, and runstests/runtimes/installed.mjsunder the runtime.buildjob runs the same smoke test under Node against the tarball, and loadsdist/index.mjsin headless Chrome (tests/runtimes/chromium.mjs).tests/runtimes/smoke.mjs: round-trip, mismatched context and wrong password fail withDECRYPTION_FAILED, a frozen 1.x ciphertext and a frozen context-bound 2.x ciphertext (copied fromtests/crypto/test-vectors.test.ts) still decrypt, aSecureStorageround-trip.playwright-core(new dev dependency, no transitive deps) drives the Chrome preinstalled on the runner viachannel: 'chrome'; nothing is downloaded, and files are served by request interception on a localhost origin, so no server is started.gh api:oven-sh/setup-bun@0c5077e…(v2.2.0),denoland/setup-deno@22d081f…(v2.0.5). Timeouts andpermissions: contents: readas elsewhere.5.
SECURITY.mdreview history (docs)f189a36 fix: close the gaps found by the pre-release security review), and the entry itself was written ine0c662fthe same day. Changed to November 2026.maxIterationsread cap) and for this pull request.Semver
Proposed: 2.1.1 (patch). Items 2 and 3 are guards that reject input which was silently corrupted before (a plaintext or context that lost its value, a write the encryptor could not read back); 1 and 5 are documentation; 4 is CI only. No format, key derivation, AAD or signature change.
package.jsonis not bumped.Tested
npm run verify: green locally (type-check, lint, format, 266 tests, coverage 100 % lines/functions/statements and 97.84 % branches, build, attw, publint).