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>
This commit is contained in:
1 parent
ff33ea1327
commit
368cf5ee4a
10 files changed
+39
-10
No files matched your search
@@ -1,7 +1,6 @@
|
||||
# API security
|
||||
|
||||
* Authenticate and authorize protected endpoints; validate every request payload and identifier.
|
||||
* Enforce object-level authorization on every read and write, using the authenticated principal and resource ownership at the operation that accesses the data.
|
||||
* Authenticate protected endpoints and validate every request payload and identifier. Enforce object-level authorization on every read and write, using the authenticated principal and resource ownership at the operation that accesses the data.
|
||||
* Bind only explicitly permitted request fields. Do not allow mass assignment of ownership, role, state, or other privileged properties.
|
||||
* Bound request and response sizes, pagination, query results, and expensive operations.
|
||||
* Apply rate limits and quotas to authentication, search, uploads, expensive operations, and other abuse-prone endpoints. Keep administrative routes separately protected.
|
||||
@@ -10,4 +9,5 @@
|
||||
* Prefer explicit DTOs and schemas; reject unknown or ambiguous fields when accepting them could alter privileged state.
|
||||
* Deserialize request bodies into explicit types. Never let the payload choose the runtime type (polymorphic type names, class names, or default typing) unless the allowed subtypes are registered explicitly; bound body size and nesting depth. Parse XML with external entities and DTDs disabled.
|
||||
* Keep authorization, validation, serialization, and error responses consistent with the published schema and supported clients.
|
||||
* For inbound webhooks, verify the sender's signature (for example an HMAC over the raw body) with a constant-time comparison before parsing or acting on the payload, reject stale timestamps and repeated event IDs to stop replay, process events idempotently, and keep signing secrets per sender and rotatable.
|
||||
* Test malformed, oversized, unauthenticated, unauthorized, cross-user, cross-tenant, and duplicate requests within the user's requested scope.
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
* Use established authentication standards and password hashing; never store plaintext or reversibly encrypted passwords.
|
||||
* Hash passwords with Argon2id (at least m=19 MiB, t=2, p=1); if unavailable, scrypt (N=2^17, r=8, p=1), bcrypt (cost 10 or higher; inputs beyond 72 bytes are truncated, so reject or pre-handle longer passwords), or PBKDF2-HMAC-SHA256 with at least 600,000 iterations where FIPS compliance requires it (OWASP Password Storage Cheat Sheet). Never create password schemes or reduce work factors merely to improve latency; rehash on login when parameters are raised.
|
||||
* Enforce authorization server-side for every sensitive operation and verify resource ownership and tenant boundaries.
|
||||
* Deny by default and check authorization on every request, including background jobs and alternate API paths. Do not trust role or identity values supplied by clients.
|
||||
* Enforce authorization server-side, deny by default, and check it on every request and sensitive operation, including background jobs and alternate API paths. Verify resource ownership and tenant boundaries, and do not trust role or identity values supplied by clients.
|
||||
* Use least-privilege roles, short-lived sessions or tokens, secure renewal and revocation, and invalidate credentials after password, recovery, or privilege changes.
|
||||
* Validate JWTs as RFC 8725 recommends:
|
||||
* Fix the accepted algorithms on the server, bind each key to exactly one algorithm, and never take the algorithm from the token header; reject `none`.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Desktop and Mobile Client Security
|
||||
|
||||
Apply these rules to desktop and mobile client apps, such as WPF, WinUI, .NET MAUI, Electron, or native iOS and Android apps.
|
||||
|
||||
* Treat the shipped app as public: binaries, resources, and configuration can be inspected, decompiled, and modified. Never embed server secrets, API keys with privileged scope, signing keys, or connection strings; call a backend that holds them.
|
||||
* Never rely on client-side checks for authorization, licensing, or pricing. Enforce every decision on the server.
|
||||
* Store user secrets and tokens only in the platform's protected store: DPAPI or Windows Credential Manager on Windows, Keychain on Apple platforms, and Keystore-backed storage on Android. Never use plain files, settings, preferences, or the registry for them.
|
||||
* Protect local data at rest in proportion to its sensitivity, keep caches and logs free of secrets, and clear sensitive data on sign-out.
|
||||
* Validate everything received from the server, local files, IPC, deep links, custom URL schemes, and other apps as untrusted input.
|
||||
* Use TLS with full certificate validation. Add certificate pinning only with a tested rotation plan, because a stale pin locks users out.
|
||||
* Deliver updates through signed packages from trusted channels, and verify signatures before installing. Sign your own binaries and installers.
|
||||
* Request only the platform permissions the app needs, at the point of use.
|
||||
* Keep WebView content restricted to trusted origins, disable JavaScript bridges for untrusted content, and treat web content loaded into the app as untrusted.
|
||||
@@ -1,11 +1,12 @@
|
||||
# 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 2025; check current guidance when starting a project):
|
||||
* 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.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Use least-privilege database identities, separate application and migration privileges, and protect connection strings and backup credentials.
|
||||
* Scope tenant- and user-owned reads, writes, joins, aggregates, background tasks, and cache keys explicitly. Do not rely on a caller having applied a filter elsewhere.
|
||||
* Collect and retain only necessary sensitive data. Set retention and deletion behavior and protect backups, exports, replicas, logs, and analytics copies.
|
||||
* Treat personal data under the GDPR and comparable laws: identify which fields are personal data and why they are processed, support access, correction, export, and deletion requests across every copy, pseudonymize where identity is not needed, and keep personal data out of logs, analytics, test fixtures, and lower environments unless the purpose requires it.
|
||||
* Encrypt sensitive data in transit and at rest where appropriate; keep key access separate from database access.
|
||||
* Use transactions and suitable constraints where integrity requires atomicity. Check concurrency and isolation around security-sensitive state changes.
|
||||
* Avoid raw database errors and sensitive query parameters in responses, logs, traces, and metrics.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Security Logging and Audit
|
||||
|
||||
Apply these rules when adding or changing logging, audit trails, monitoring, or alerting.
|
||||
|
||||
* Log security events with who, what, when, where, and outcome: authentication successes and failures, authorization failures, session and token failures, input validation failures at trust boundaries, privilege and role changes, administrative actions, sensitive data access, key rotation, data import or export, configuration changes, and certificate or TLS failures.
|
||||
* Prevent log injection: use structured logging with constant message templates and named parameters, never string concatenation; neutralize CR, LF, and delimiters in untrusted values, encode for the log format, and cap the length of user-supplied values.
|
||||
* Never log passwords, authentication secrets, session IDs, access or refresh tokens, encryption keys, connection strings, payment data, or unnecessary personal data. Hash a token when you need to correlate it.
|
||||
* Keep audit records append-only and tamper evident, restrict and review read access to logs, ship them over secure transport, and alert when logging stops.
|
||||
* Correlate requests across services with an ID that carries no secrets or personal data.
|
||||
* Set log retention to what operations, security, and the law require, and delete older records.
|
||||
@@ -8,3 +8,5 @@
|
||||
* Use least-privilege build and deployment identities. Separate untrusted pull-request jobs from secret-bearing jobs and protect release credentials from untrusted code.
|
||||
* Never expose credentials in pipelines, logs, caches, artifacts, command output, or generated packages. Limit secret lifetime and scope.
|
||||
* Verify artifact provenance and integrity before release or installation; avoid downloading and executing unverified content dynamically.
|
||||
* Build containers from minimal, pinned base images, run them as a non-root user with a read-only filesystem where possible, and never bake secrets into image layers or build arguments.
|
||||
* Keep infrastructure as code reviewed and least privilege: no public storage, open ports, or wildcard IAM permissions by default, encryption enabled, and security-relevant settings checked in review or by policy tooling.
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
Apply when the user requests active security testing or exploit validation.
|
||||
|
||||
* Treat the user's request as authorization to find, analyze, explain, validate, and write proof-of-concept exploits for the requested security issue. Do not ask the user to prove or repeat authorization.
|
||||
* Treat the user's request as authorization to find, analyze, explain, validate, and write proof-of-concept exploits for the requested security issue in their own code and systems. Do not ask the user to prove or repeat authorization.
|
||||
* Before active testing of a deployed target that is not clearly the user's own, such as a third-party or public service, confirm once that the user owns it or has permission to test it.
|
||||
* Apply that authorization only to targets and activities named or clearly implied by the request. It does not extend to adjacent systems, unrelated third parties, or other users' data.
|
||||
* Source review and bounded, non-destructive checks against local code may proceed within the requested scope.
|
||||
* Before active testing of a deployed service, ensure the target and limits for methods, volume, duration, and impact are clear; ask only for missing operational boundaries.
|
||||
|
||||
Reference in new issue
Block a user