Secure Storage
Secure Storage
Entra Token CLI uses platform-specific secure storage mechanisms to protect sensitive authentication data. Understanding how secrets are stored helps you make informed security decisions.
Platform Security Overview
| Platform | Mechanism | Security Level | Notes |
|---|---|---|---|
| Windows | DPAPI | 🔒 Strong | User-account encryption |
| macOS | Keychain | 🔒 Strong | System-level encryption |
| Linux | XOR Obfuscation | ⚠️ Weak | Not secure for production |
What Gets Stored
Profile Configuration (Plaintext)
Location: ~/.entratool/profiles.json
Stored in plaintext:
- Profile name
- Client ID
- Tenant ID
- Scope
- Authority URL
- OAuth2 flow preference
Example:
| |
Secrets (Encrypted)
What’s encrypted:
- Client secrets
- Certificate passwords
- Private key data
Storage location:
- Windows: DPAPI-encrypted data
- macOS: Keychain access
- Linux: XOR-obfuscated file
Windows Security (DPAPI)
How It Works
Data Protection API (DPAPI):
- Built into Windows
- Uses user account credentials to encrypt data
- Data is automatically tied to user profile
Security Properties:
- ✅ Strong encryption (AES-256)
- ✅ Automatic key management
- ✅ Per-user encryption
- ✅ OS-level protection
Storage Location
Encrypted data is stored in user-specific Windows data stores. The exact location is managed by Windows.
Access Control
- Only the same user account on the same machine can decrypt
- Administrator accounts cannot decrypt another user’s DPAPI data
- Backing up and restoring requires user profile migration
Security Considerations
✅ Safe for:
- Development workstations
- Single-user systems
- Corporate managed devices
⚠️ Be aware:
- Data is tied to user profile
- Lost password = lost data (unless backed up properly)
- Malware running under your account can access
macOS Security (Keychain)
How It Works
macOS Keychain:
- System-level secure storage
- Encrypted with user’s login password
- Managed by macOS Security framework
Security Properties:
- ✅ Strong encryption (AES-256)
- ✅ Integration with Touch ID / Face ID
- ✅ Per-item access control
- ✅ Audit logging
Storage Location
| |
Note: Keychain is encrypted; you cannot read it directly.
Viewing Secrets
Open Keychain Access app:
- Launch:
/Applications/Utilities/Keychain Access.app - Search for:
entratool - Double-click item → “Show password”
- Authenticate with your login password
Screenshot:
Access Control
- Requires user authentication to access
- Can be protected by Touch ID
- Can set per-item access policies
Exporting Keychain
You can export secrets for backup:
| |
⚠️ Warning: Exported files contain unencrypted secrets. Protect them carefully.
Security Considerations
✅ Safe for:
- Development workstations
- Personal Macs
- Production automation (with proper access controls)
⚠️ Be aware:
- Malware with keychain access can extract secrets
- User password compromise = keychain compromise
- Backup keychain securely
Linux Security (XOR Obfuscation)
⚠️ Security Warning
Linux storage is NOT secure for production use.
Secrets are obfuscated using XOR encoding, which provides no real security. Anyone with access to the file can easily reverse the obfuscation.
How It Works
XOR Obfuscation:
- Simple XOR cipher with fixed key
- Not encryption — just encoding
- Prevents casual viewing in text editors
Security Properties:
- ❌ No real protection
- ❌ Easily reversible
- ❌ Fixed obfuscation key in source code
Storage Location
| |
Warning: This file contains your secrets in an easily decodable format.
Why XOR?
Linux lacks a universal, secure secret storage mechanism:
- Keyring services vary by distribution (GNOME Keyring, KWallet, etc.)
- Not always available on servers or minimal installs
- Inconsistent APIs across distributions
XOR obfuscation is a lowest common denominator approach that works everywhere but provides minimal security.
Linux Alternatives
1. Environment Variables
Store secrets in environment variables:
| |
Profile without stored secret:
| |
The tool will read from AZURE_CLIENT_SECRET if available.
2. Azure Key Vault
Store secrets in Azure Key Vault and retrieve at runtime:
| |
3. HashiCorp Vault
| |
4. Certificate Authentication
Use certificates instead of secrets (more secure):
| |
Certificates can be stored with restricted file permissions:
| |
5. Managed Identity (Azure VMs)
On Azure VMs, use Managed Identity (no secrets needed):
| |
Security Recommendations
For production Linux workloads:
- Use certificate authentication instead of client secrets
- Store certificates with strict file permissions (600)
- Use external secret managers (Azure Key Vault, Vault)
- Use Managed Identity on Azure VMs
- Rotate secrets frequently
- Monitor secret access
DO NOT rely on ~/.entratool/secrets.dat for production security.
Certificate Storage
How Certificates Are Stored
Certificates are not stored by the tool. You provide the certificate path:
| |
Certificate Security
Security depends on:
- File permissions on certificate file
- Password protection of PFX/PKCS12 file
- Storage location security
Best Practices
1. Restrict File Permissions
| |
2. Password-Protect Certificates
Always use password-protected PFX files:
| |
3. Store in Secure Locations
macOS:
| |
Windows:
| |
Linux:
| |
4. Use Certificate Stores
Windows Certificate Store:
| |
macOS Keychain:
| |
Secret Lifecycle
1. Secret Creation
Client Secret:
| |
Certificate:
| |
2. Secret Usage
When generating tokens:
- Profile is read from
profiles.json - Secrets are decrypted from secure storage
- Used for authentication
- Never written to logs or disk unencrypted
3. Secret Rotation
Update secrets regularly:
| |
4. Secret Deletion
When deleting a profile:
| |
Security Audit
Checking What’s Stored
List Profiles
| |
View Profile Details
| |
Check Keychain (macOS)
| |
DPAPI Inventory (Windows)
Use specialized tools like dpapick to audit DPAPI-protected data.
Best Practices
✅ Development
- Use platform secure storage (DPAPI on Windows, Keychain on macOS)
- Separate profiles for dev/test/prod
- Short-lived secrets
- Regular rotation
✅ Production
Windows/macOS:
- Platform secure storage is acceptable
- Certificates preferred over secrets
- Regular audits
Linux:
- ⚠️ Do not use built-in storage
- Use external secret manager (Key Vault, Vault)
- Or use certificate authentication with restricted file permissions
- Or use Managed Identity
✅ CI/CD
- Store secrets in CI/CD secret manager (GitHub Secrets, Azure Pipelines)
- Inject at runtime
- Never commit secrets to git
- Use short-lived tokens
❌ Never
- ❌ Commit
profiles.jsonto git - ❌ Share secrets via email/Slack
- ❌ Store secrets in plaintext files
- ❌ Use the same secret across environments
- ❌ Trust Linux XOR storage for production
Troubleshooting
“Access to secure storage denied”
Windows:
- User profile may be corrupted
- Try running as the correct user
macOS:
- Keychain may be locked
- Open Keychain Access and unlock
“Cannot decrypt secret”
Cause: Secret was encrypted on different machine or user account
Fix:
- Delete profile:
entratool config delete -p myprofile - Recreate profile:
entratool config create - Re-enter secret
Migrating Secrets
Secrets are tied to user accounts and machines. To migrate:
Export profile configuration (plaintext):
1cat ~/.entratool/profiles.jsonOn new machine, recreate profile:
1 2entratool config create # Re-enter all secrets
Note: Secrets cannot be exported/imported directly due to encryption.