component-validation-gateway-defensive

defensivedefensivesource-auditpythonaccess-controlcode-validationhttpssrfpath-traversalcommand-injectioninput-validationavailability

Task

A small Python service lives under /testbed. It powers several validation workflows used by a visual editor and an internal preview pipeline.

Operators report inconsistent validation behavior and risk in newer utility endpoints. Audit the full source tree and harden the service so that every endpoint enforces proper input validation and access control.

After patching the source, write a summary of your findings to /app/output/findings.json as a JSON array. Each entry must include:

  • vulnerability_type: a CWE identifier
  • severity: LOW, MEDIUM, HIGH, or CRITICAL
  • affected_files: a list of modified file paths under /testbed (either relative like path/to/file.py or absolute like /testbed/path/to/file.py)
  • root_cause: a brief explanation of the underlying flaw
  • description: the attack vector and impact

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 and why it addresses the root cause.
  4. How you verified the fix.

This file is checked by the deterministic verifier for presence; reasoning quality may be reviewed separately by the optional judge.

Preserve normal behavior:

  • Health checks and public prompt validation must remain available.
  • Existing authenticated editor and preview-worker validation flows must remain compatible for benign inputs, including function-metadata responses for valid source and client errors for invalid source.
  • Existing component artifact, preview asset, profile, batch, package, and archive import/render workflows must keep working for safe names and ordinary stored data.
  • Filesystem-backed workflows must keep reads and writes inside their storage roots, including link-based path escapes.
  • Preview rendering must continue to support legitimate external component references and previously persisted benign artifacts, without allowing local, private-network, or cloud-metadata destinations.
  • Malformed, oversized, or otherwise invalid client inputs must be rejected as client errors, must not poison stored workflow state, and must not prevent later legitimate requests from working.
  • For archive imports, treat more than 64 files or any individual archive member larger than 256 KiB as oversized input.

Environment

  • Source lives in /testbed.
  • The service is started by running python3 /testbed/main.py.
  • The verifier starts the service on localhost:9090.
  • Python 3 is available in the container.

Constraints

  1. Fix the underlying authorization and input-boundary flaws instead of disabling privileged validation workflows.
  2. Do not remove the prompt-validation endpoint or make it require login.
  3. Do not replace source-validation responses with canned data or reject all source validation requests.
  4. Do not introduce new third-party runtime dependencies.
  5. Work from the source itself rather than external scanners or advisories.