fix: security and infra fixes (#36, #37, #43, #44)#49
Merged
Conversation
Both importKey calls in ecdh.js (private key PKCS#8 and public key raw) used extractable: true with no corresponding exportKey call anywhere in the codebase. Setting extractable to false prevents key material from being exported via the Web Crypto API, reducing attack surface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#36) The importEcdhPub function in encryption.js was importing external peer public keys with extractable: true, making it the most attacker-exposed ECDH importKey in the codebase. Changed to extractable: false. Broadened test 3/4 in test-security-hardening.js from a variable-specific pattern to a generic P-521 namedCurve pattern that catches ALL ECDH importKey calls regardless of which source file they originate from. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Closes #43 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Closes #44 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Four independent fixes from code review of PR #34, bundled together because they're small and share the "security and infra hardening" theme.
importKeycalls now useextractable: false(both insrc/js/worker/ecdh.jsandsrc/js/worker/encryption.js). NoexportKeycalls exist in the codebase; this is pure defense-in-depth against key exfiltration via Web Crypto.download_abnow passes filenames through a newsanitizeFilename()helper that strips path separators (/,\), null bytes, and truncates to 255 chars..dockerignoreexcluding.git/,.worktrees/,docs/,app/tests/to shrink build context and avoid busting thejs-buildlayer cache on unrelated edits.FROM alpine→FROM alpine:3in the fonts stage of the Dockerfile (other stages were already pinned).Tests added
app/tests/test-security-hardening.js— asserts ECDHextractable: false,sanitizeFilenamepresence and behavior in built output (9 assertions)app/tests/test-infra.js— asserts.dockerignoreexists and excludes required paths, asserts Dockerfile pins alpine (7 assertions)Full suite: 148/148 passing after
node scripts/build.js.Test plan
node scripts/build.js && node --test app/tests/test-*.js— all 148 passapp/index.htmlfrom pre-refactor commits)alpine:3Closes #36
Closes #37
Closes #43
Closes #44