RFC: Native Encryption Support in Varlock .env files #129
Replies: 3 comments 4 replies
-
|
Thanks for this @gunta, this is something we're already thinking about as we supported encrypted vaults in |
Beta Was this translation helpful? Give feedback.
-
|
Closing this now - in favour of some discussion here: #223 |
Beta Was this translation helpful? Give feedback.
-
|
Interesting RFC. The encrypted-in-repo approach (dotenvx style) is elegant for solo devs, but I'm curious how you're thinking about the team workflow: When a team member rotates a key, they'd need to re-encrypt and commit. That's fine, but it also means everyone needs to pull before their env works again. And key distribution (how does a new team member get the decryption key?) still needs solving out-of-band. The alternative that some teams prefer: don't commit secrets at all, use a central store where secrets are fetched at runtime. KeyEnv takes this approach — no encrypted secrets in the repo, the CLI injects from the platform. Trade-off: requires network at env load time, but simplifies key rotation and onboarding. Both approaches are valid — the RFC looks like it's optimizing for "works offline with git history", which is a different priority than "easiest team operations". |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
This proposal introduces native encryption capabilities to Varlock, inspired by the dotenvx white paper and implementation. This feature would enable developers to commit encrypted secrets directly to their repositories while maintaining security through separated key management, enabling new workflows and use cases that aren't currently possible with Varlock.
Background
The encryption model
Dotenvx implements a hybrid cryptographic solution that splits secrets management into two components:
.env): Contains values encrypted with a public key, safe to commit.env.keys): Contains private keys, never committed to source controlTheir approach uses the secp256k1 elliptic curve (the same curve used by Bitcoin) with the ECIES (Elliptic Curve Integrated Encryption Scheme) algorithm for encryption/decryption.
Current Varlock Limitations
While Varlock excels at schema validation, type safety, and runtime security for environment variables, it currently lacks native encryption support. This means:
This is perfectly fine for some use cases, but a limiting factor for other useful use-cases.
Proposed Implementation
1. Core Encryption Features
Encrypted Value Format
Key File Structure
2. New Decorator:
@encryptedIntroduce a new decorator specifically for encryption:
3. CLI Commands
Encryption Commands
Integration with Existing Commands
4. Runtime Behavior
Key Resolution Strategy
VARLOCK_PRIVATE_KEYenvironment variable.env.keysfile5. Security Enhancements
Leak Prevention
Extend existing runtime patches to prevent encrypted value leaks:
Use Cases Enabled by Encryption
1. Vibe Coding & Rapid Prototyping
2. Open Source Project Templates
3. CI/CD Simplification
4. Development Environment Parity
5. Compliance & Auditing
6. Disaster Recovery
Smooth Migration Path from Dotenvx
Seamless Transition
Compatibility Features
encrypted:prefix format.env.keysfile structureDOTENV_PUBLIC_KEYnaming convention along the newVARLOCK_PUBLIC_KEYkeyMigration Benefits
Implementation Details
Dependencies
{ "dependencies": { "eciesjs": "^0.4.10" // Same as dotenvx for compatibility } }Core Modules
1. Encryption Service
2. Key Management
3. Parser Extension
Integration Points
With EnvGraph
With Optional Runtime Patches
With Type Generation
Security Considerations
Threat Model
Best Practices
.env.keysfiles.env.keysautomatically to prevent any disasterComparison with Alternatives
Development Plan
Phase 1: Core Encryption
encrypted:prefix formatPhase 2: Dotenvx Compatibility
.env.keysstructurePhase 3: Varlock Integration
@encrypteddecoratorPhase 4: Advanced Features
Testing Strategy
Unit Tests
Integration Tests
Security Tests
Documentation Requirements
User Guide
API Documentation
Examples
Possible Success Metrics
Open Questions
What does this mean?
Adding native encryption support to Varlock following the dotenvx model would:
This feature would demonstrate that Varlock "plays well with the ecosystem" while adding unique value through its schema validation, type generation, and runtime security features.
References
Beta Was this translation helpful? Give feedback.
All reactions