|
| 1 | +# Security Policy |
| 2 | + |
| 3 | +## Supported Versions |
| 4 | + |
| 5 | +We release security updates for the following versions: |
| 6 | + |
| 7 | +| Version | Supported | |
| 8 | +| ------- | ------------------ | |
| 9 | +| 1.2.x | :white_check_mark: | |
| 10 | +| 1.1.x | :white_check_mark: | |
| 11 | +| 1.0.x | :x: | |
| 12 | +| < 1.0 | :x: | |
| 13 | + |
| 14 | +## Reporting a Vulnerability |
| 15 | + |
| 16 | +**Please do not report security vulnerabilities through public GitHub issues.** |
| 17 | + |
| 18 | +If you discover a security vulnerability in tmpltool, please report it by emailing the maintainers. You can find the contact information in the repository. |
| 19 | + |
| 20 | +### What to Include |
| 21 | + |
| 22 | +Please include the following information in your report: |
| 23 | + |
| 24 | +- **Description** of the vulnerability |
| 25 | +- **Steps to reproduce** the issue |
| 26 | +- **Potential impact** of the vulnerability |
| 27 | +- **Suggested fix** (if you have one) |
| 28 | +- **Your contact information** for follow-up |
| 29 | + |
| 30 | +### Response Timeline |
| 31 | + |
| 32 | +- **Initial Response:** We aim to respond to security reports within 48 hours |
| 33 | +- **Confirmation:** We will confirm the vulnerability within 5 business days |
| 34 | +- **Fix Timeline:** We will work on a fix and aim to release a patch within 14 days for critical vulnerabilities |
| 35 | +- **Disclosure:** We will coordinate with you on the disclosure timeline |
| 36 | + |
| 37 | +## Security Best Practices for tmpltool |
| 38 | + |
| 39 | +When using tmpltool, please follow these security best practices: |
| 40 | + |
| 41 | +### 1. Trust Mode (`--trust`) |
| 42 | + |
| 43 | +**⚠️ WARNING:** Only use `--trust` mode with templates you completely trust. |
| 44 | + |
| 45 | +```bash |
| 46 | +# ✗ DANGEROUS - Don't use --trust with untrusted templates |
| 47 | +tmpltool --trust untrusted_template.tmpl |
| 48 | + |
| 49 | +# ✓ SAFE - Use without --trust for untrusted templates |
| 50 | +tmpltool untrusted_template.tmpl |
| 51 | +``` |
| 52 | + |
| 53 | +**Why?** Trust mode disables security restrictions: |
| 54 | +- Can read any file on the system (e.g., `/etc/passwd`, SSH keys) |
| 55 | +- Can access parent directories (`../`) |
| 56 | +- Can read sensitive configuration files |
| 57 | + |
| 58 | +**Only use `--trust` when:** |
| 59 | +- You wrote the template yourself |
| 60 | +- You've reviewed and audited the template |
| 61 | +- You trust the template source completely |
| 62 | +- You need to access system files intentionally |
| 63 | + |
| 64 | +### 2. Template Security |
| 65 | + |
| 66 | +**Avoid processing untrusted templates without review:** |
| 67 | + |
| 68 | +```bash |
| 69 | +# ✗ DANGEROUS - Don't process templates from untrusted sources |
| 70 | +curl https://untrusted-site.com/template.tmpl | tmpltool |
| 71 | + |
| 72 | +# ✓ SAFE - Review templates before using them |
| 73 | +curl https://trusted-site.com/template.tmpl -o template.tmpl |
| 74 | +# Review the template |
| 75 | +cat template.tmpl |
| 76 | +# Then use it |
| 77 | +tmpltool template.tmpl |
| 78 | +``` |
| 79 | + |
| 80 | +**What to check in templates:** |
| 81 | +- File system access attempts |
| 82 | +- Unexpected environment variable usage |
| 83 | +- Suspicious patterns or obfuscation |
| 84 | + |
| 85 | +### 3. Environment Variables |
| 86 | + |
| 87 | +**Be careful with sensitive environment variables:** |
| 88 | + |
| 89 | +```bash |
| 90 | +# ✗ DANGEROUS - Don't expose secrets in environment |
| 91 | +export DATABASE_PASSWORD="secret123" |
| 92 | +tmpltool template.tmpl # Template could leak this |
| 93 | + |
| 94 | +# ✓ BETTER - Use secure secret management |
| 95 | +# Load secrets only when needed and clear them after use |
| 96 | +``` |
| 97 | + |
| 98 | +**Best practices:** |
| 99 | +- Don't put secrets in environment variables if possible |
| 100 | +- Use dedicated secret management tools |
| 101 | +- Clear sensitive env vars after use |
| 102 | +- Review templates for `filter_env(pattern="*")` which could expose all env vars |
| 103 | + |
| 104 | +### 4. Filesystem Access |
| 105 | + |
| 106 | +**Default security (without `--trust`):** |
| 107 | +- ✓ Only relative paths allowed |
| 108 | +- ✓ No access to parent directories (`..`) |
| 109 | +- ✓ No absolute paths (`/etc/passwd`) |
| 110 | +- ✓ Restricted to current working directory |
| 111 | + |
| 112 | +**With `--trust` mode:** |
| 113 | +- ⚠️ Full filesystem access |
| 114 | +- ⚠️ Can read any file the user can access |
| 115 | +- ⚠️ No restrictions |
| 116 | + |
| 117 | +### 5. Docker Security |
| 118 | + |
| 119 | +When using Docker: |
| 120 | + |
| 121 | +```bash |
| 122 | +# ✓ SAFE - Mount only necessary directories |
| 123 | +docker run --rm -v $(pwd):/workspace -w /workspace tmpltool template.tmpl |
| 124 | + |
| 125 | +# ✗ DANGEROUS - Don't mount entire filesystem |
| 126 | +docker run --rm -v /:/host tmpltool template.tmpl |
| 127 | +``` |
| 128 | + |
| 129 | +## Known Security Considerations |
| 130 | + |
| 131 | +### 1. Template Injection |
| 132 | + |
| 133 | +tmpltool uses the Tera template engine. While Tera is designed to be safe, be aware that: |
| 134 | +- Templates have access to environment variables via `get_env()` |
| 135 | +- Templates can read files via filesystem functions |
| 136 | +- Trust mode disables all security restrictions |
| 137 | + |
| 138 | +### 2. Filesystem Access |
| 139 | + |
| 140 | +Filesystem functions enforce security by default: |
| 141 | +- `read_file()` - Restricted to relative paths |
| 142 | +- `file_exists()` - Restricted to relative paths |
| 143 | +- `list_dir()` - Restricted to relative paths |
| 144 | +- `glob()` - Restricted to current directory |
| 145 | + |
| 146 | +Use `--trust` only when necessary and with caution. |
| 147 | + |
| 148 | +### 3. Environment Variable Exposure |
| 149 | + |
| 150 | +Functions like `filter_env(pattern="*")` can expose all environment variables. Review templates carefully to ensure they don't leak sensitive information. |
| 151 | + |
| 152 | +## Security Updates |
| 153 | + |
| 154 | +Security updates will be: |
| 155 | +1. Developed privately |
| 156 | +2. Tested thoroughly |
| 157 | +3. Released as patch versions (e.g., 1.2.1) |
| 158 | +4. Announced in release notes with `[SECURITY]` tag |
| 159 | +5. Added to this SECURITY.md file |
| 160 | + |
| 161 | +## Security Hall of Fame |
| 162 | + |
| 163 | +We'd like to thank the following people for responsibly disclosing security issues: |
| 164 | + |
| 165 | +<!-- Names will be added here as vulnerabilities are reported and fixed --> |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +**Remember:** Security is everyone's responsibility. If you see something, say something! |
0 commit comments