security: enforce E2EE/TEE conversation integrity client-side#24
Open
thistehneisen wants to merge 1 commit into
Open
security: enforce E2EE/TEE conversation integrity client-side#24thistehneisen wants to merge 1 commit into
thistehneisen wants to merge 1 commit into
Conversation
verifySignature() returned verified:true for any 64-hex signedText without checking the hash committed to the response, and streamChat() displayed/trusted E2EE responses without ever verifying the enclave signature (fetchTeeSignature/verifySignature were dead code) while the isHexEncrypted gate let plaintext through under the "decrypted end-to-end" banner. A malicious or compromised server could therefore present forged content as attested. - e2ee.ts: replace the hash short-circuit with real sha256(content) verification, constant-time compared (single hash and request:response pair). Re-encoded UTF-16 -> UTF-8 so the change is reviewable by diff/SAST tooling. - chat.ts: in E2EE mode reject non-ciphertext chunks, buffer decrypted content instead of streaming it unverified, and verify the TEE response signature against the attested signing address before any content is shown or the banner is printed. Does not yet add client-side Intel PCK / NVIDIA NRAS quote verification; see SECURITY_PR.md for the tracked follow-up.
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
The E2EE / "TEE-attested" conversation guarantee was not enforced on the client. A malicious or compromised server could present attacker-authored content under the
🔐 Response decrypted end-to-endbanner:verifySignature()returnedverified: truefor any 64-hexsignedTextwithout checking the hash committed to the response (signature-bypass).streamChat()displayed/trusted E2EE responses without ever fetching or verifying the enclave signature (fetchTeeSignature/verifySignaturewere dead code).isHexEncrypted()gate allowed a plaintext chunk to be shown verbatim while the CLI still asserted it was decrypted end-to-end.This maps to conversation/chat encryption and privacy-control integrity.
Changes
src/lib/e2ee.ts: replace the hash short-circuit with realsha256(expectedContent)verification, constant-time compared (single-hash andrequest:responsepair forms). Re-encoded UTF-16 → UTF-8 so the change is reviewable bygit diff/ SAST (the file previously showed as binary).src/commands/chat.ts: in E2EE mode, reject non-ciphertext chunks, buffer decrypted content instead of streaming it unverified, and verify the TEE response signature against the attested signing address before any content is displayed or the banner is printed.Known limitation / follow-up
This closes the integrity gap and the signature-bypass. It does not yet add client-side Intel PCK / NVIDIA NRAS quote-signature verification — the policy still trusts the server-reported
server_verification.tdx.validand the server-supplied signing key, so a malicious server can still substitute its own attested key (confidentiality). Tracked inSECURITY_PR.md; recommended as separate, larger work.Test plan
npm run buildpasses