Repository navigation
feat(broker): encrypt ToolHive credential storage - #2275
Merged
Merged
Conversation
Use the Mecatl session ID as the logical broker session key. Admit only IDs that also pass the session-affinity header rule (printable ASCII, no boundary spaces, 256 bytes), so a session that can be created can also be reached through the Converse client and connector inventory. Reject other IDs before broker-enabled host creation, fork or clear successor creation, and broker runtime attach and connector inspection. Deleting a session whose ID the broker cannot hold is a no-op, so deletion stays idempotent. Co-Authored-By: mecatl <[email protected]>
Add an immutable key ring and versioned AES-GCM envelopes with row- and field-bound associated data. Keep old keys available for reads while the active key handles new writes. Decode strictly so each envelope has one string form, and require caller associated data because it is the only binding between a ciphertext and its row. Pin compatibility with ciphertext from the reconstruction branch; storage and custody integration follow in separate commits. Co-Authored-By: mecatl <[email protected]>
Wrap ToolHive's native storage to seal upstream token and DCR secret fields while leaving row identity, expiry, indexes, and persistence semantics with ToolHive. Preserve refresh CAS by passing the exact stored ciphertext to the native compare-and-swap operation, and leave a missing row to native CAS so an empty expectation still creates it. Fail closed on device-flow confirmations, which ToolHive stores unsealed. The package is named sealedauthstorage to keep it apart from internal/adapter/credentialstore, and its doc states what is and is not protected: secret-field confidentiality, not metadata integrity against a Redis writer. Add protected Redis/key-file construction with a health check and single-owner cleanup. Cover field binding, rotation, native storage behavior, and failure paths; runtime wiring follows separately. Co-Authored-By: mecatl <[email protected]>
Stage encrypted recovery evidence only after checking the referenced ToolHive token rows and bounding retention by their earliest session expiry. Bind the recovery reference to the logical session, incarnation, owner and workload partitions, a nonzero profile digest, and providers. Gate every transition on the caller's attempt deadline, checked against Redis time; the deadline is not stored in the record. Commit, resolve, and tombstone through guarded Redis compare-and-swap transitions. Recheck custody after token refresh so expiry or a concurrent tombstone cannot authorize a stale result. A Redis writer can still replay an older ciphertext; the code documents that limit. Cover restart, concurrency, deadline, and failure paths; runtime wiring follows. Co-Authored-By: mecatl <[email protected]>
Replace Runtime's Process pointer with copied enrollment configuration, a narrow authenticated discoverer, and a publication gate bound to its owning Process. Keep ToolHive construction and discovery behind the Process while allowing standalone runtimes to remain independent. Discover protected backend capabilities outside the publication lock, then publish only while the owning process, session, grant, transaction, and attachment remain current. Inspect connectors through the same gate without changing enrollment state; shutdown blocks stale publication. This closes races the previous code left open: catalogue refresh checked state, released the lock, then assigned; completed-enrollment installation had no gate; the observe commit ignored process shutdown and context cancellation; and rollback drained before marking the process closed. Every publish path now also requires the runtime's entry for the session to be the same session object. Cover injection, enrollment, discovery, inspection, and shutdown races. Protected credential storage and custody remain unwired in this slice. Co-Authored-By: mecatl <[email protected]>
Fix gci import grouping, document exported sealedauthstorage methods, and annotate the intentional empty critical section and the not-yet-wired production storage constructor. Co-Authored-By: mecatl <[email protected]>
Merged
2 tasks
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
Verification