Skip to content

stack-encrypt: finish adopting Vitamin C's secure Buffer for every plaintext buffer #1468

Open

Description

@coderdan

Follow-up requested in the review of #1404.

Blocked on cipherstash/vitaminc#559 landing and a compatible release. Adopt vitaminc_protected::Buffer for Stack Encrypt's growing plaintext buffers, including the frame/storage paths affected by Vitamin C's return-type changes. Buffer wipes old allocations during growth as well as on drop; a Protected<Vec<u8>> only owns the final allocation.

Before upgrading, inventory plaintext-bearing Vec writers and copies, adapt them to Buffer/ByteSink and protected access, and verify cleanup on growth, success, error and cancellation with the heap-hygiene suite. Run scalar/tree interoperability and shared Rust/Go conformance after upgrading; Python and planned TypeScript bindings must retain the same wire behavior.

Keep #1404's capped untrusted deserializer size-hint reservation and its regression test. That reader holds ciphertext bytes, and adopting a secure plaintext buffer does not make an untrusted allocation hint safe.

Also re-evaluate the scalar protected-borrow bridge against the released ProtectedRef/AsProtectedRef encoder support; the currently pinned Vitamin C 0.8 encoder does not implement Encrypt for ProtectedRef.

References: #1404 and cipherstash/vitaminc#559.

Milestone coordination

Included in milestone 4. Coordinate owned API migration (#1482, #1483), blob buffers (#1484) and lifecycle evidence (#1480). Preserve the upstream release dependency described above.

Activity

  1. coderdan commented on Nov 10, 2026

    @coderdan
    ContributorAuthor

    This is no longer blocked. cipherstash/vitaminc#559 merged on 2 November, and Vitamin C 0.9.1 was released on 6 November.

    Part of the work is done. Commit 8c4e938 (build(stack-encrypt)!: move to vitaminc 0.9) moved Stack Encrypt to the Vitamin C 0.9 crates. Since then:

    • the frame codec writes into vitaminc_protected::Buffer, not a Vec<u8>, and Buffer is re-exported as stack_encrypt::Buffer;
    • the frame readers take a ProtectedRef<'_, [u8]>, and ValueFrame implements AsProtectedRef.

    Still to do:

    • List the other places that write or copy plaintext into a plain Vec, and move them to Buffer or ByteSink.
    • Show with the heap-hygiene suite that buffers are wiped when they grow, on success, on error, and on cancellation.
    • Look at the scalar protected-borrow bridge again, now that the released encoder supports ProtectedRef.
    • Keep the capped size-hint reservation in the untrusted deserializer from feat(stack-encrypt): add owned scalar ciphertext API #1404, and its regression test.
    • Run the scalar and tree interoperability checks and the shared Rust and Go conformance after the change.
  2. changed the title [-]stack-encrypt: adopt Vitamin C secure Buffer after #559 ships[/-] [+]stack-encrypt: finish adopting Vitamin C's secure Buffer for every plaintext buffer[/+] on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions