This guide covers security best practices for using SecureFlow to protect your sensitive data.
- Encryption Overview
- Password Security
- File Management
- CI/CD Security
- Best Practices
- Security Checklist
SecureFlow uses industry-standard encryption:
- Algorithm: AES-256-CBC (Advanced Encryption Standard, 256-bit key, Cipher Block Chaining mode)
- Key Derivation: PBKDF2 (Password-Based Key Derivation Function 2)
- Compatibility: OpenSSL-compatible format
- Salt: 8 random bytes per encrypted file
- Format: Salted__ header + salt + encrypted data
-
Encryption Process:
Password → PBKDF2 → Key + IV → AES-256-CBC → Encrypted File -
File Format:
[Salted__][8-byte salt][encrypted data] -
Key Derivation:
- Uses PBKDF2 with SHA-256
- Derives 48 bytes: 32 for key, 16 for IV
- Salt is randomly generated per file
SecureFlow is compatible with OpenSSL commands:
Encrypt with OpenSSL:
openssl enc -aes-256-cbc -salt -pbkdf2 -in file.txt -out file.txt.encrypted -k "password"Decrypt with SecureFlow:
secureflow decrypt --password "password"And vice versa - files encrypted with SecureFlow can be decrypted with OpenSSL.
Minimum Requirements:
- At least 16 characters
- Mix of uppercase and lowercase letters
- Include numbers
- Include special characters
Good Password Example:
T7$kL9@mP2!qR5#nW8
Bad Password Examples:
password123 # Too simple
MyP@ssw0rd # Common pattern
project2024 # Too short, predictable
Use a password manager or generator:
# Generate strong password on Linux/macOS
openssl rand -base64 24
# Generate with special characters
< /dev/urandom tr -dc 'A-Za-z0-9!@#$%^&*' | head -c 24 ; echo✅ DO:
- Use a password manager (1Password, LastPass, Bitwarden)
- Store in CI/CD platform's secret management
- Share via secure channels (encrypted messaging)
- Keep separate passwords for different projects
- Document password hints in
report.txt
❌ DON'T:
- Commit passwords to version control
- Share passwords via email or Slack
- Write passwords in plain text files
- Reuse passwords across projects
- Store passwords in browser history
When to Rotate:
- Every 3-6 months (recommended)
- When team member leaves
- After suspected compromise
- Before major releases
How to Rotate:
- Generate new password
- Re-encrypt all files with new password:
secureflow encrypt --password "new_password" - Update password in CI/CD secrets
- Commit new encrypted files
- Notify team of password change
- Update password manager
Always add plaintext secrets to .gitignore:
# Environment files
.env
.env.*
!.env.example
# Mobile app secrets
android/app/keystore.jks
android/key.properties
android/service-account.json
ios/Runner/GoogleService-Info.plist
# SSL certificates
*.key
*.pem
*.p12
# Database credentials
config/database.yml
config/secrets.yml
# Test decryption directory
test_dec_keys/✅ DO:
- Commit encrypted files to version control
- Commit
secureflow.yamlconfiguration - Commit
report.txtfor reference - Use descriptive encrypted filenames
- Review encryption reports regularly
❌ DON'T:
- Commit plaintext secrets
- Delete encrypted files accidentally
- Modify encrypted files manually
- Share encrypted files without config
Recommended structure:
your-project/
├── .gitignore # Ignore plaintext secrets
├── secureflow.yaml # Config (commit this)
├── enc_keys/ # Encrypted files (commit this)
│ ├── .env.prod.encrypted
│ ├── keystore.jks.encrypted
│ └── report.txt # Report (commit this)
├── test_dec_keys/ # Test directory (don't commit)
│ └── .env.prod
├── .env.prod # Plaintext (don't commit)
└── android/
└── app/
└── keystore.jks # Plaintext (don't commit)
On Linux/macOS:
# Encrypted files (can be readable)
chmod 644 enc_keys/*.encrypted
# Decrypted sensitive files (restrict access)
chmod 600 .env.prod
chmod 600 android/app/keystore.jks
# Directories
chmod 755 enc_keys
chmod 700 test_dec_keysOn Windows: Use File Explorer → Properties → Security to restrict access to decrypted files.
Platform-Specific Best Practices:
- Use Repository secrets for passwords
- Use Environment secrets for deployment-specific passwords
- Enable branch protection for production branches
- Use required reviewers for sensitive workflows
- Enable CODEOWNERS for workflow files
- Use masked variables to hide values in logs
- Use protected variables for production branches only
- Set environment-specific variables
- Limit variable scope to specific branches/tags
- Use file variables for multi-line secrets
- Use secured variables to mask in logs
- Limit variables to specific branches
- Use deployment variables for environment-specific secrets
- Enable required approvals for production deploys
- Use Credentials store for passwords
- Scope credentials to specific jobs/folders
- Enable Mask Passwords plugin
- Use Role-Based Access Control (RBAC)
- Audit credential access regularly
Secure Pipeline Design:
# Example: Secure GitHub Actions workflow
name: Secure Deploy
on:
push:
branches: [main]
permissions:
contents: read # Minimal permissions
jobs:
decrypt:
runs-on: ubuntu-latest
environment: production # Requires manual approval
steps:
- uses: actions/checkout@v3
- name: Decrypt
run: |
secureflow decrypt --password "${{ secrets.PROD_PASSWORD }}" --non-interactive
- name: Upload artifacts with short expiry
uses: actions/upload-artifact@v3
with:
name: secrets
path: .env.production
retention-days: 1 # Short retention
deploy:
needs: decrypt
runs-on: ubuntu-latest
steps:
- name: Download secrets
uses: actions/download-artifact@v3
- name: Deploy
run: ./deploy.sh
- name: Clean up
if: always()
run: rm -f .env.productionKey Security Practices:
- Use minimal permissions
- Require manual approval for production
- Short artifact retention
- Clean up secrets after use
- Use specific branch triggers
What to Monitor:
- Secret access in CI/CD platform
- Pipeline execution history
- Failed decryption attempts
- Unauthorized config changes
- Encrypted file modifications
Audit Checklist:
- Review who has access to secrets
- Check pipeline logs for anomalies
- Verify encrypted files haven't been tampered with
- Ensure
.gitignoreis properly configured - Review recent commits for accidentally committed secrets
Don't rely solely on encryption:
- Use VPN for sensitive operations
- Enable 2FA on all accounts
- Use network segmentation
- Implement least privilege access
- Regular security audits
Use different passwords for different environments:
# Development
secureflow encrypt --config secureflow.dev.yaml --password "$DEV_PASSWORD"
# Staging
secureflow encrypt --config secureflow.staging.yaml --password "$STAGING_PASSWORD"
# Production
secureflow encrypt --config secureflow.prod.yaml --password "$PROD_PASSWORD"Only encrypt what's necessary:
# Good: Only encrypt secrets
files:
- input: .env.production
- input: android/app/keystore.jks
# Avoid: Don't encrypt public configs
files:
- input: .env.production
- input: config/public_api.json # Not necessaryMonthly checklist:
- Review who has access to passwords
- Check for exposed secrets in logs
- Verify
.gitignoreis complete - Test decryption process
- Review encryption reports
Quarterly checklist:
- Rotate passwords
- Re-encrypt all files
- Update team access
- Review pipeline security
- Audit secret usage
If password is compromised:
-
Immediate Actions:
# Generate new password NEW_PASS=$(openssl rand -base64 24) # Re-encrypt immediately secureflow encrypt --password "$NEW_PASS" # Update CI/CD secrets # Update team password manager
-
Investigate:
- Review access logs
- Check for unauthorized deployments
- Examine recent commits
- Interview team members
-
Communicate:
- Notify affected team members
- Document the incident
- Update security procedures
- Consider external notification if required
If plaintext secrets are committed:
-
Immediate Actions:
# Remove from git history (use with caution) git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch path/to/secret.env' \ --prune-empty --tag-name-filter cat -- --all # Force push (coordinate with team) git push origin --force --all
-
Rotate All Secrets:
- Change all passwords
- Regenerate API keys
- Update database credentials
- Re-issue certificates
-
Use Tools to Prevent Future Incidents:
# Install git-secrets git secrets --install git secrets --register-aws # Or use gitleaks gitleaks detect --verbose
Train team members on:
- How to use SecureFlow properly
- Never committing plaintext secrets
- Recognizing security threats
- Proper password management
- Incident response procedures
Regular verification:
# Test encryption
secureflow test --password "$PASSWORD" --non-interactive
# Verify files can be decrypted
secureflow decrypt --password "$PASSWORD" --non-interactive
# Check encrypted file integrity
ls -lh enc_keys/
cat enc_keys/report.txtBackup important files:
# Backup encrypted files
tar -czf secureflow-backup-$(date +%Y%m%d).tar.gz enc_keys/ secureflow.yaml
# Store in secure location
# - Encrypted cloud storage
# - Secure file server
# - Password-protected archiveWhat to backup:
- Encrypted files (
enc_keys/) - Configuration (
secureflow.yaml) - Encryption reports (
report.txt) - Password hints (in secure location)
- Generate strong password (16+ characters)
- Store password in password manager
- Configure
.gitignorefor plaintext secrets - Test encryption/decryption locally
- Set appropriate file permissions
- Document password hint in report
- Verify no plaintext secrets in git history
- Check
.gitignoreis working - Confirm encrypted files are in place
- Review
report.txtfor accuracy - Test decryption process
- Store password as secret in CI/CD platform
- Test decryption in pipeline
- Verify password is masked in logs
- Set short artifact retention
- Enable branch protection
- Require approval for production deploys
- Rotate passwords quarterly
- Review access permissions monthly
- Audit pipeline logs regularly
- Keep SecureFlow updated
- Test disaster recovery procedures
- Train new team members
- Verify encryption password is correct
- Test decryption process
- Check all required files are encrypted
- Review CI/CD pipeline security
- Confirm rollback procedure
- Document emergency contacts
- Use strong encryption (AES-256 ✅)
- Maintain data processing records
- Implement access controls
- Enable audit logging
- Have data breach response plan
- Encrypt data at rest (✅)
- Implement access controls (✅)
- Maintain audit trails
- Regular security assessments
- Business associate agreements
- Encryption of sensitive data (✅)
- Access control policies (✅)
- Change management
- Monitoring and logging
- Incident response
- Strong cryptography (AES-256 ✅)
- Key management procedures
- Access control measures
- Logging and monitoring
- Regular security testing
- git-secrets: Prevent committing secrets
- gitleaks: Detect secrets in git repos
- truffleHog: Find secrets in git history
- detect-secrets: Prevent secrets in commits
- Configuration Guide - Configuration best practices
- CI/CD Usage Guide - Secure CI/CD integration
- Troubleshooting - Security-related issues