Skip to content

Commit 4f1a822

Browse files
committed
fix(migration): authenticate 0x03 framing and harden staged-file lifecycle
Address Greptile review feedback on the chunked export format: - Authenticate 0x03 framing so the stream cannot be reordered, replayed, or truncated. Each chunk IV is now derived from (base IV, index) on the decrypt side instead of being read from the file, and each chunk's GCM AAD binds the fixed header plus the chunk index into the tag. After the final chunk, the stream verifies the file is exhausted, so a lowered total length (authenticated-prefix attack) is rejected. - Apply the 8 MiB chunk cap while the length is still a Long so exports between 2 and 4 GiB no longer wrap to a zero chunk size and divide by zero. - Reject a zero chunk size for non-empty plaintext. - Delete the staged bundle file on every readMigrationBundle failure path (wrong password, password-required, decrypt/manifest decode) so repeated failed attempts do not leak full bundle copies or a plaintext ZIP. - Track the in-flight preview job and guard the install with a sequence counter so a slow, superseded preview cannot overwrite the newer preview's staged file or UI state; the replaced staged file is deleted. - Add regression tests for framing tamper, ciphertext tamper, trailing data, negative total length, zero-chunk header, and a multi-chunk round trip.
1 parent f87f9e1 commit 4f1a822

4 files changed

Lines changed: 414 additions & 147 deletions

File tree

0 commit comments

Comments
 (0)