API / backend service: class M checklist
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
This page continues API / backend service. Read the main page first. This part holds the audit checklist items for class M.
Audit checklist
+ If it has users, personal data or API keys (M)
- One package manager, lockfile committed
- What: Exactly one package manager is used and enforced; the lockfile is committed; installs are done from the lockfile (for example
--frozen-lockfile). - How to check: Look for a lockfile in the repository and a rule that forbids other managers; check the CI and Docker install commands.
- Evidence: Lockfile path; install command lines.
- What: Exactly one package manager is used and enforced; the lockfile is committed; installs are done from the lockfile (for example
- Authentication uses a mature library or service
- What: Login is built with a well-known library or hosted service; no home-made cryptography; passwords are hashed with a current algorithm.
- How to check: Find the login code; check the password hashing function (for example Argon2id, scrypt, bcrypt); search for hand-written crypto.
- Evidence: Library name and version; hashing configuration.
- All input is validated on the server with a schema
- What: Every request body, query and parameter is checked on the server against a schema; the client check is only a convenience.
- How to check: For each endpoint find the schema or validator; send invalid, oversized and unexpected fields and see the response.
- Evidence: Validator files per endpoint; test cases for invalid input.
- Permissions are checked on the server
- What: Every action checks who the user is and what they may do on the server; a hidden button is not security.
- How to check: Call each protected endpoint without a session and with the wrong user; read the permission checks in the handlers.
- Evidence: Test names for unauthenticated and wrong-user requests; code lines of the checks.
- Errors use one consistent format
- What: Errors follow one structure (for example Problem Details, RFC 9457) with stable codes and no internal details.
- How to check: Trigger several error types and compare responses.
- Evidence: Sample error bodies.
- An OpenAPI description exists and matches the code
- What: A machine-readable description of the API is kept in the repository and checked against the real responses.
- How to check: Find the spec; run a contract test or validator.
- Evidence: Spec file; validation log.
- Endpoints and versions are inventoried
- What: A current list of all endpoints, versions and environments exists; old versions are retired on a schedule.
- How to check: Compare the list with the actual routes.
- Evidence: Inventory document or generated spec.
- Logs contain no personal data or secrets
- What: Logs do not record passwords, tokens, keys or personal data; if needed they are masked.
- How to check: Read the logging setup; trigger a login and a form and inspect the log lines; search for e-mail and token patterns.
- Evidence: Sample log lines after a test run showing masking.
- External API keys stay on the server
- What: Third-party API keys (including LLM keys) are kept on the server and never shipped to the browser or app.
- How to check: Search the client bundle and app package for key-like strings; check that client calls go to your own server.
- Evidence: Search result with zero keys in the client build.
- Every external call has a time limit
- What: Database queries, storage, e-mail, notifications, AI calls and external processes all have an upper time limit.
- How to check: Search for HTTP client and process calls without a timeout setting.
- Evidence: Configuration or code lines with timeouts.
- Personal data fields are documented
- What: For every personal data field the purpose, retention time and legal basis (KVKK, GDPR) are written down.
- How to check: List the database columns and form fields with personal data; find the matching entries in the data note.
- Evidence: Data note listing each field with purpose, period and basis.
- Automatic backups with a tested restore
- What: The database is backed up automatically, retention is written down, and a restore has actually been tried.
- How to check: Find the backup job and its schedule; find the record of the last restore test.
- Evidence: Backup schedule, retention setting and dated restore-test record.
- Critical flows have automated tests and a local check
- What: Login, saving data, payment (if any) and permission checks have automated tests; one local command runs the checks before pushing.
- How to check: List the test files; run the check command; look for a git hook that runs it.
- Evidence: Test names and a passing run log.
- Secret scanning runs before push and in CI
- What: A scanner (for example gitleaks or secretlint) runs before code is pushed and in CI.
- How to check: Find the hook or CI step that runs the scanner.
- Evidence: Hook file or CI step; latest clean run.
- One command starts everything locally
- What: The project starts locally with one command (for example
docker compose up) including database and object storage; the same image runs in every environment and only settings differ. - How to check: Read the compose file and Dockerfile; run the command on a clean checkout.
- Evidence: Compose file path; successful start log.
- What: The project starts locally with one command (for example
- PostgreSQL by default, through an ORM or query builder
- What: The default database is PostgreSQL (another choice has a written reason); queries go through an ORM or query builder; raw SQL lives in one module; connection settings come from configuration.
- How to check: Read the database config and decision notes; search for raw SQL.
- Evidence: Decision note; list of raw SQL locations.
Sources
- OWASP API Security Top 10 – 2023 — OWASP
- REST Security Cheat Sheet — OWASP Cheat Sheet Series
- Authorization Cheat Sheet — OWASP Cheat Sheet Series
- Insecure Direct Object Reference Prevention Cheat Sheet — OWASP Cheat Sheet Series
- Mass Assignment Cheat Sheet — OWASP Cheat Sheet Series
- Server Side Request Forgery Prevention Cheat Sheet — OWASP Cheat Sheet Series
- RFC 9457: Problem Details for HTTP APIs — IETF
- RFC 6585: Additional HTTP Status Codes — IETF
- Retry-After header — MDN Web Docs
- Idempotent (glossary) — MDN Web Docs
- The Idempotency-Key HTTP Header Field (Internet-Draft) — IETF
- REL05-BP03 Control and limit retry calls — AWS
- Well-Architected: make mutating operations idempotent — AWS
- PostgreSQL: EXPLAIN — PostgreSQL Global Development Group
- The Twelve-Factor App: III. Config — 12factor.net
- Pro Build Guide v1.2: compiled team practices — Pro Build Guide