Skip to content

stack-encrypt: no opt-in type authenticates a collection's order and length — add Positioned<Vec<T>> #1570

Open

Description

@coderdan

Background

Stack Encrypt (packages/stack-encrypt) is the Rust engine that every CipherStash language SDK runs on. It can encrypt a collection, such as a Vec<T>, as one batch (#1501). Each element is sealed separately and stored separately.

By design, the default collection does not authenticate its order or its length. A database returns rows in any order, and a query may return only some of them. Decision record ADR-0010 (packages/stack-encrypt/docs/adr/0010-what-a-stored-value-authenticates.md) records this. It also says stricter authentication will be opt-in, through named types. This issue is that opt-in type.

Problem

Some callers store a sequence whose order matters, such as the steps of a workflow. With the default collection, someone with write access to the database can swap, drop, or add an element. Each element still opens, so the program cannot detect the change. No opt-in type exists today.

Proposal

The plan item is Authenticate the order and length of a collection, in the Stack Encrypt API plan merged in pull request #1365.

  1. Add a wrapper type, Positioned<Vec<T>>. It seals each element under its position and the collection's length.
  2. On opening, check both. A swapped, dropped, or added element fails to open.
  3. Add the same form to the dynamic interface, so the Go SDK can declare it.
  4. Leave the default collection unchanged.

This is a new stored form beside the existing one. It does not change any stored value.

Acceptance

  • A test shows that swapping two elements fails to open, in Rust and in Go.
  • A test shows that dropping an element fails to open, in Rust and in Go.
  • A test shows that adding an element fails to open, in Rust and in Go.
  • The failure is an authentication error, not a shape error.
  • A default collection's stored bytes do not change.
  • The conformance corpus covers the new form.

Relationship to other work

Plans: the Stack Encrypt API plan.

Activity

  1. self-assigned this
    on Nov 8, 2026
  2. added
    enhancementNew feature or request
    rustPull requests that update Rust code
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

SDKenhancementNew feature or requestrustPull requests that update Rust code

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions