RFC: Native Encryption Support in Varlock .env files #129
gunta
started this conversation in
New Features
Replies: 1 comment 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.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
@encrypted
Introduce a new decorator specifically for encryption:
3. CLI Commands
Encryption Commands
Integration with Existing Commands
4. Runtime Behavior
Key Resolution Strategy
VARLOCK_PRIVATE_KEY
environment variable.env.keys
file5. 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.keys
file structureDOTENV_PUBLIC_KEY
naming convention along the newVARLOCK_PUBLIC_KEY
keyMigration Benefits
Implementation Details
Dependencies
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.keys
files.env.keys
automatically to prevent any disasterComparison with Alternatives
Development Plan
Phase 1: Core Encryption
encrypted:
prefix formatPhase 2: Dotenvx Compatibility
.env.keys
structurePhase 3: Varlock Integration
@encrypted
decoratorPhase 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