Skip to content

Sign signer state to prevent tampering#682

Merged
cdecker merged 5 commits intomainfrom
feature/signed_signer_states
Mar 13, 2026
Merged

Sign signer state to prevent tampering#682
cdecker merged 5 commits intomainfrom
feature/signed_signer_states

Conversation

@ihordiachenko
Copy link
Collaborator

This PR adds end-to-end integrity protection for persisted signer state. The signer derives a dedicated state-signing key from the root secret, signs outgoing shard updates, and verifies signatures on incoming shards. Signature repairs propagate naturally through diff/sketch sync, allowing previously unsigned entries to be upgraded over time.

Key design decisions:

  • Per-shard signatures. Signatures are attached per shard rather than to the full state blob to remain compatible with differential sync.

  • Signature policy. The default policy is soft: missing signatures are accepted and repaired during sync, while invalid signatures are rejected. The hard policy rejects both missing and invalid signatures, and off explicitly disables verification.

  • Canonical serialization. Shards are signed using canonical JSON instead of preserving raw JSON bytes. This keeps the implementation simpler while relying on a well-defined serializer.

  • Operator recovery. Recovery is implemented as a session-scoped override with audit logging.

  • Tower storage. Tower storage remains opaque. No DB schema or migration changes are required, and the protocol is unchanged except for adding a per-entry signature field.

  • Replay protection. Replay protection is intentionally deferred. There is no external monotonic counter yet, so this change protects integrity but does not prevent replay of older validly signed state.

@ihordiachenko ihordiachenko force-pushed the feature/signed_signer_states branch 2 times, most recently from 6f4a3db to e41a0b0 Compare March 10, 2026 14:09
@ihordiachenko ihordiachenko self-assigned this Mar 10, 2026
@ihordiachenko ihordiachenko requested a review from cdecker March 10, 2026 14:10
pub struct CanonicalJsonValue<'a>(pub &'a serde_json::Value);

impl Serialize for CanonicalJsonValue<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I was about to mention my concern about canonical encodings when I saw this. Great work, and thanks for going the extra mile. I like the canonical ordering for structs. One last question: whitespace being a major issue with JSON encoding, I assume that this skips any whitespace that there might be?

@cdecker
Copy link
Collaborator

cdecker commented Mar 12, 2026

Excellent work so far 👍
I'm guessing you are still working on the server-side handling of signatures, if needed at all, and then we can move ahead and merge, defaulting to Soft mode for now, and then we switch over if we don't see any breakage in a month or so.

@ihordiachenko ihordiachenko force-pushed the feature/signed_signer_states branch from e41a0b0 to a01653b Compare March 12, 2026 14:59
@ihordiachenko ihordiachenko marked this pull request as ready for review March 12, 2026 15:01
@cdecker cdecker merged commit 1d94e49 into main Mar 13, 2026
16 checks passed
@cdecker cdecker deleted the feature/signed_signer_states branch March 13, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants