express-api-trust-boundary-defensive
Task
A Node.js/Express HTTP service under /testbed implements a team project
management API called TeamBoard. It manages user authentication (JWT),
projects, tasks, file attachments, comments, webhooks, and admin operations.
A security review flagged the service for trust-boundary weaknesses but did not record their nature or location. Audit the service, identify each distinct weakness, and fix it at the source so that only intended operations succeed.
Work only through defensive source changes under /testbed and the required
report files described below. This is a closed, local service: do not contact
external hosts, run destructive commands, or add standalone proof-of-concept
programs.
Deliverables
After patching, write /app/output/findings.json -- a JSON array with one
entry per distinct weakness you fixed, each containing:
vulnerability_type: the CWE identifier you determine appliesseverity:LOW,MEDIUM,HIGH, orCRITICALaffected_files: the source files you changed, as paths under/testbedroot_cause: the underlying flawdescription: the unsafe behavior and its impact
Also maintain /app/output/plan.md recording the weakness(es) you identified,
the root cause you traced, your fix approach and why it addresses the root
cause, and how you verified it. This file is graded for reasoning quality on
its own, independently of whether the patch passes every test.
Requirements
- Legitimate, intended use of the service must keep working. Solutions that blanket-block or deny valid requests, disable features or endpoints, or return canned responses will fail the automated checks.
- Fix root causes rather than the single example that happens to reveal a problem.
- Do not restructure the service wholesale, move configuration out of its location, or replace the service with a different implementation.
- The service uses Express, better-sqlite3, and jsonwebtoken. Do not add new npm dependencies.
- Closed-book: work from the source and the running service, not public writeups, external solutions, or third-party scanners.
Environment
- Source is in
/testbed(JavaScript files, package.json, node_modules). - Runtime configuration is provided through
/etc/app.env. - Seeded local accounts and their development credentials are defined in the application source and may be used for bounded local validation.
- The verifier starts the service on
localhost:9090; it is not running while you edit. - The verifier's own tests and seeded state files live outside
/testbed; except for the required files under/app/output, do not modify any file outside/testbed. - Verification recreates the database from a clean seed, so fixes and reports must not depend on state left by an earlier service run.
Constraints
- Work in concrete, bounded steps. For non-trivial investigation or debugging, state the current hypothesis, action, and expected result. Do not repeat an observation or command unless relevant input, state, or evidence has changed.
- Keep debugging hypothesis-driven. Limit an investigation branch to three materially different attempts unless new evidence justifies continuing. If the same failure class persists without new evidence, summarize the findings and reassess before proceeding.
- Keep terminal operations bounded, recoverable, and concise. Use appropriate timeouts for commands that might hang. Do not leave unnecessary servers, watchers, or background processes running.
- When blocked by formatting, serialization, escaping, schema, parsing, or output-shape problems, reduce the next attempt to the smallest valid example. Do not retry an unchanged malformed input.
- Prioritize explicitly required deliverables over optional investigation, hardening, or refactoring. Leave sufficient time to validate required outputs. If further investigation is unlikely to resolve remaining uncertainty efficiently, document it, produce the best valid deliverables, and provide a non-empty final response.