Skip to content

About

A small self-hosted secrets manager in Rust. Seal barrier with Shamir unseal shares, append-only encrypted store, scoped machine tokens. Third-party code limited to cryptography crates (RustCrypto, subtle, getrandom) and their dependencies.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

Repository files navigation

localsecrets

A small self-hosted secrets manager in Rust: a single-binary server and a command line client. Store a secret encrypted, fetch it from a machine, inject it into a process.

Inspired by Infisical for its addressing model and machine identities, and by OpenBao for its seal barrier and revocable tokens. It is far smaller than either, on purpose.

lsec init --threshold 2 --shares 3   # prints the unseal shares, once
lsec user create [email protected]     # asks for the root token, then a password
lsec login [email protected]
lsec use demo dev

lsec set DB_URL                      # typed or piped, never echoed
lsec run -- npm start                # the child gets the secrets in its environment

What it does

  • Secrets scoped by project and environment, read and written over a small HTTP API or the CLI.
  • A seal barrier. A master key is split into unseal shares with Shamir's scheme and never stored. A restarted server comes back sealed and can read nothing until a quorum of share holders is present.
  • Machine tokens confined to one environment, read-only, revocable, with an optional lifetime.
  • Re-splittable shares. lsec rekey rotates the root key and hands out a fresh set, rewriting the file so the old barrier stops existing. A lost share or a change of custodians is an ordinary operation, not a rebuild.
  • An audit trail of every read, write and delete, including refusals, misses, and requests for names that do not exist. Key names appear; values never do.
  • An append-only store. One file. Every change is appended and flushed; a crash leaves a partial tail that the next start discards.

Dependencies

45 entries in the lockfile, of which seven are this project's own crates. The direct third-party dependencies are all cryptographic: the RustCrypto crates aes-gcm, argon2, sha2 and zeroize, plus subtle and getrandom. The rest of the lockfile is what those pull in: more RustCrypto crates and a few small support crates such as cfg-if, libc and typenum.

localsecrets has never been audited, and no public audit covering the dependency versions it locks was found in those crates' READMEs and changelogs (checked 27 Sep 2026). An earlier aes-gcm release was reviewed by NCC Group in 2020; docs/security.md says which versions that covered and how this was checked.

The HTTP server and client, the JSON parser, the storage layer, the logger, the argument parsing and the calendar arithmetic are written on the standard library. That is a deliberate trade for a tool whose whole job is guarding credentials: a smaller supply chain is worth the extra code, while hand-written ciphers and key derivation are not, because they fail quietly on side channels.

How the keys fit together

unseal shares (t of n)  --recombine-->  master key   (memory only, never written)
master key              --AES-256-GCM-> root key     (stored wrapped)
root key                --AES-256-GCM-> project key  (stored wrapped, one per project)
project key             --AES-256-GCM-> secret value (stored as nonce + ciphertext)

Every ciphertext is bound to its slot through canonical associated data, so a stored row moved to another project, environment or key name fails to decrypt instead of revealing its value.

Build and run

cargo build --release
target/release/localsecretsd --data-dir ~/.local/share/localsecrets

The server binds loopback. Serving it to a network means putting a reverse proxy in front to terminate TLS.

Kept out by design

  • Requests that change state need content-type: application/json, which a form cannot send, so a page on another site cannot reach init or unseal without a preflight it will never get.
  • Every request must be addressed to this machine, and one carrying a browser Origin is refused: that is what DNS rebinding cannot forge.
  • Requests are bounded in size and in time, the accept queue is bounded, and the unauthenticated endpoints share a rate limit.

Read before you trust it

docs/security.md sets out what this protects against and, at more length, what it does not: an attacker with code execution on an unsealed host, a compromised client, swap and core dumps, someone who can write to the store file. It also explains why a 3-of-5 split held by one person is a passphrase with extra steps.

This is a personal project with no security guarantees and no audit. Do not use it to hold credentials whose loss you could not absorb.

Documentation

Document What it covers
docs/usage.md Running the server, every command, configuration
docs/security.md Threat model, key hierarchy, capabilities, known limits
docs/c4model.md Architecture: containers, components, data flow

Tests

cargo test --workspace     # 402 tests, no external services, a few seconds
cargo clippy --workspace --all-targets -- -D warnings

The suite covers the cryptography against published vectors (FIPS-197 for the field arithmetic, RFC 4648 for base64), the HTTP parser against the ambiguities that cause request smuggling, the store against crashes and tampering, and the whole flow end to end through the real binaries.

Several tests were written to fail against the bug they describe before the fix landed, which is the only way to know a test is worth having: the consume arithmetic in the chunked head reader, the race in recovering a poisoned lock, and the non-canonical base64 that gave every value a second spelling.

Licence

MIT.

About

A small self-hosted secrets manager in Rust. Seal barrier with Shamir unseal shares, append-only encrypted store, scoped machine tokens. Third-party code limited to cryptography crates (RustCrypto, subtle, getrandom) and their dependencies.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages