Security Practices¶
Security is paramount when handling sensitive credentials like Unseal Keys and TLS certificates. Follow these guidelines strictly.
1. File Permissions¶
When creating files, use the most restrictive permissions possible.
| File Type | Octal | Meaning |
|---|---|---|
| Secrets / Keys | 0600 |
Read/Write by Owner ONLY |
| Config / Public | 0644 |
Read All, Write Owner |
| Directories | 0755 |
Execute/Read All, Write Owner |
2. Cryptography¶
Randomness¶
Always use crypto/rand for security-sensitive operations (tokens, keys, passwords).
Certificates¶
Do not implement custom certificate logic. Use the internal/pki package, which defaults to safe algorithms (ECDSA P-256 or RSA 2048+).
3. No Shelling Out¶
Forbidden
Controllers and internal packages MUST NOT execute external binaries (kubectl, helm, bao, vault).
Shelling out introduces injection vulnerabilities, dependency requirements, and performance overhead.
4. Input Validation¶
Validate all user input from Custom Resources before using it.
5. Secrets Handling¶
No Logging¶
Do Not Log Secrets
NEVER log the content of secrets, tokens, or unseal keys.
Be careful with fmt.Sprintf("%v", obj), which might print struct fields.
Memory Scrubbing¶
Minimize the exposure window of sensitive data in memory.