Skip to main content
Orion Env stores your secrets encrypted inside the repository. That is convenient, and it also means every encrypted value is public to anyone who can read the repo, forever. Git history does not forget. Until now each value was encrypted with X25519 and XSalsa20-Poly1305 (NaCl box). That is still secure against today’s computers, but X25519 is an elliptic-curve scheme, and a large enough quantum computer running Shor’s algorithm breaks it. An attacker doesn’t need that computer today: they can copy the ciphertexts now and decrypt them later (“harvest now, decrypt later”). For files that live in source control, that is exactly the threat model. Starting with @orion-js/env@4.5.1, new env files use hybrid post-quantum encryption.

How values are encrypted

Each value is encrypted with a fresh X-Wing key encapsulation. X-Wing combines ML-KEM-768 (the NIST-standardized post-quantum KEM, FIPS 203) with X25519. The resulting 32-byte shared secret is used as an AES-256-GCM key.
Being hybrid, a value stays protected as long as either ML-KEM or X25519 is unbroken. If a flaw is ever found in the newer lattice-based scheme, you still have the classical security you had before. AES-GCM authenticates every value, so a tampered ciphertext fails to decrypt instead of returning garbage. The implementation uses @noble/post-quantum, an audited, dependency-free JavaScript library. It is bundled into the package, so @orion-js/env works the same from require() and import on Node.js 22, 24 and 26 and on Bun.

What changes in the file

Post-quantum files have version: '2.0', and keys and values are prefixed with pq1::
The secret key is still short (pq1: followed by 32 bytes in base64), so it fits in ORION_ENV_SECRET_KEY or a secret manager exactly like before. Encrypted values are bigger: about 1.5 KB each, because every value carries its own ML-KEM ciphertext.

Migrating an existing file

Old files keep working: Orion Env still reads version: '1.0' files with their old secret key. To upgrade one, run:
migrate decrypts every value with the current key, generates a new post-quantum keypair, re-encrypts everything, and checks that every value decrypts back to the original before it writes the file. It then prints the new secret key.
The old secret key cannot decrypt the migrated file, so deploy the migrated file and the new ORION_ENV_SECRET_KEY together. That includes keys stored inside a secret manager through readFromSecret. If you use the wrong kind of key, the error tells you which one it expected:
Running migrate on a file that is already post-quantum rotates its keypair, which is also the recommended way to rotate keys from now on. A migration does not erase history. Old ciphertexts remain in git, encrypted with the old key. If someone may already have collected them, rotate the underlying credentials (database passwords, API keys) as well, not only the encryption.

Summary

  • orion-env init creates post-quantum files.
  • orion-env add keeps working on both kinds of files, and warns when the file is still legacy.
  • orion-env migrate upgrades legacy files and rotates keys on post-quantum ones.
  • Applications don’t need code changes: env and loadEnv() read both formats.
See the Env guide for the complete reference.