Files
MyAiConfiguration/shared/rules/security/references/api.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.0 KiB

API security

Apply these rules when adding or changing inbound HTTP endpoints, webhooks, request handling, or API (de)serialization.

  • 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.
  • Define safe retry and idempotency behavior for state-changing requests. Protect against replay and duplicate side effects where relevant.
  • Return only authorized fields. Do not expose stack traces, internal models, secrets, or implementation details in API responses or errors.
  • 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.