directus-authenticated-security-hardening-defensive

defensivedefensivesource-audithardeningjavascripttypescriptdirectusauthorizationssrfpath-validation

Task

A Directus v11.15.0 instance lives under /testbed. Directus is a headless CMS that wraps any SQL database with a real-time REST and GraphQL API.

An internal security review of this build flagged five seeded vulnerabilities — concrete, exploitable flaws an authenticated user could abuse. The review withheld all specifics: no CVE identifiers, no CWE classes, no severities, and no description of the flaws themselves. It localized the audit to five areas of the codebase — one seeded flaw each — but said nothing more:

  1. The collection read / query pipeline — how records are assembled before they are returned to the caller.
  2. An alternative file-upload path, separate from the standard upload.
  3. Server-side fetching of a user-supplied URL.
  4. The files API — its authorization and the handling of stored-file metadata.
  5. The authentication flow — what happens after a login completes.

Within each area you must discover the specific flaw yourself: what the attacker controls, how the current code mishandles it, and why it is exploitable. Then fix it at the root cause, classify it (CWE + severity — your own assessment), and document it.

These areas are large and each also contains other, unrelated weaknesses; more than one instance of a given weakness class may be present. Identifying the correct concrete flaw — the one that is actually exploitable as seeded — is part of the task. Patching a sibling instance that merely shares a weakness class will not resolve it.

Fix at the root, and fix it completely. A correct remediation neutralizes the flaw for every equivalent input, not just the first example you try. Fix the underlying cause — the missing or incorrect validation, normalization, or authorization step — rather than one surface symptom: a patch that blocks one representation of an attack while leaving an equivalent encoding, alias, address form, or path open does not resolve the vulnerability and will not be accepted. Do not disable, remove, or broadly over-restrict a feature to make an exploit "go away" — the feature's legitimate behavior must still work afterward.


After applying all fixes, write a summary to /app/output/findings.json as a JSON array with one entry per vulnerability you fixed. Each entry must include:

  • vulnerability_type: the CWE identifier you assign (e.g. "CWE-79")
  • severity: one of "LOW", "MEDIUM", "HIGH", "CRITICAL" — your own assessment
  • title: a short descriptive title
  • description: what the vulnerability is, including the attack vector
  • affected_files: list of file paths that were vulnerable
  • root_cause: explanation naming the specific function/variable and code pattern
  • fix_applied: description of the sanitization technique or guard you applied

Environment

  • Source lives in /testbed.
  • The application uses Node.js and TypeScript.
  • Write your findings to /app/output/findings.json.
  • Rebuild the API after making changes so your fixes take effect at runtime. Workspace dependencies are pre-built; from /testbed you can rebuild the API with pnpm --filter @directus/api build.

Guidelines

  1. Fix each vulnerability at the source where the flaw originates, covering all equivalent variants of the attack — not just the specific payload you tested.
  2. Do not disable any endpoint, remove any feature, or change the application's expected behaviour.
  3. Do not introduce new third-party dependencies.

Before and as you work, maintain /app/output/plan.md recording:

  1. The subsystem(s) and suspected vulnerability class you identified.
  2. The root cause you traced.
  3. The fix approach, why it addresses the root cause, and which attack variants it covers.
  4. How you verified the fix.

This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.