Files
MyAiConfiguration/shared/rules/security/references/crypto.md
T
Julian Lechner c3e22eb902
CI / CI configuration security checks (push) Successful in 6s
CI / Python tests and compilation (push) Failing after 12s
CI / QMD unit tests (push) Skipped
CI / Capabilities and shell quality (push) Successful in 1m50s
CI / Build and inspect generated packages (push) Skipped
CI / Bash integration and installation guards (push) Skipped
CI / Installed client configuration smoke tests (push) Skipped
CI / PowerShell tests on Ubuntu (push) Failing after 7m24s
corrections
2026-11-19 10:30:43 +01:00

2.2 KiB

Cryptography and secrets security

Apply these rules when using cryptography or handling secrets, keys, or credentials.

  • Never implement custom cryptographic primitives. Never use MD5 or SHA-1 for security purposes, DES, 3DES, RC4, ECB mode, or unauthenticated CBC.
  • Use maintained platform cryptography with authenticated encryption, secure randomness, and verified signatures and certificates. Minimum choices (as of OWASP and NIST guidance in 2026; check current guidance when starting a project):
    • Symmetric encryption: AES-256-GCM with a unique 96-bit nonce per key and message, never reused, or ChaCha20-Poly1305.
    • Hashing and MACs: SHA-256 or stronger; HMAC-SHA-256 or stronger.
    • Signatures and key exchange: Ed25519, ECDSA or ECDH with P-256 or stronger, or RSA with at least 2048 bits (3072 for keys that must stay secure beyond 2030), with RSA-OAEP or RSA-PSS padding.
    • Transport: TLS 1.2 or newer, TLS 1.3 preferred; never disable certificate or hostname validation.
    • Post-quantum: RSA and elliptic-curve public-key cryptography are not quantum resistant. For data or keys that must stay confidential for many years, plan key establishment with ML-KEM (FIPS 203) in a hybrid construction with a classical algorithm where the platform supports it, and keep algorithms replaceable through configuration and key rotation.
  • Keep key generation, storage, access, rotation, revocation, and backup separate from application data where practical. Restrict each key to its intended purpose.
  • Treat tokens, private keys, connection strings, and credentials as secrets; keep them out of source, URLs, command lines, logs, fixtures, and error messages. Keep server-side credentials out of frontend code; browser handling of user session tokens follows the web security rule.
  • Use environment-appropriate secret storage, separate environments, and rotate compromised or overexposed credentials. Do not silently fall back to a weaker key or algorithm when configuration is missing.
  • Compare secret-derived values with established constant-time APIs when the comparison is security-sensitive.
  • Do not log plaintext or retain decrypted sensitive data longer than required. Apply secure disposal only where the runtime and data type provide meaningful guarantees.