Files
MyAiConfiguration/shared/rules/security/references/crypto.md
T
Julian LechnerandClaude Opus 5.5 368cf5ee4a docs(security): add logging and client app rules, close coverage gaps
New focused rules: security logging and audit (events to log, log
injection, what never to log, tamper-evident audit trails) and desktop
and mobile client apps (shipped code is public, platform secret stores,
pinning with rotation, signed updates, WebView limits).

Existing rules gain inbound webhook verification in api, GDPR handling
of personal data in data, container and infrastructure-as-code
hardening in supply-chain, and post-quantum key establishment with
ML-KEM (FIPS 203) in a hybrid construction in crypto. Security testing
of a third-party or public target now needs one confirmation of
ownership or permission. Duplicate authorization bullets in auth and
api are merged, and webhook routing distinguishes inbound from outbound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:03:44 +01:00

15 lines
2.1 KiB
Markdown

# Cryptography and secrets security
* 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.