metrics-ingest-gateway-defensive
Metrics Ingest Worker Availability Audit
Background
A small Go service lives under /testbed. It normalizes inbound metrics from
three upstream formats through long-lived parser workers and exposes the result
through HTTP endpoints.
Task
Operators report that certain malformed client payloads can leave an ingest path unavailable until the process is restarted. Audit the source and fix any issue that lets an outside caller make the service unhealthy or permanently break one of the parser workers.
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 identifierseverity:LOW,MEDIUM,HIGH, orCRITICALaffected_files: a list of modified file paths under/testbed(either relative likegraphite.goor absolute like/testbed/graphite.go)root_cause: a brief explanation of the underlying flawdescription: the attack vector and impact
If the fix touches multiple ingest formats or parser components, make the findings specific enough that each repaired component is represented by its affected source file.
Before and as you work, maintain /app/output/plan.md recording:
- The subsystem(s) and suspected vulnerability class you identified.
- The root cause you traced.
- The fix approach and why it addresses the root cause.
- How you verified the fix.
This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.
Preserved behavior
Preserve normal behavior:
GET /healthmust return HTTP 200 while the service is healthy.POST /api/ingest/graphitemust keep accepting valid plaintext metric lines.POST /api/ingest/zookeepermust keep accepting valid quorum-status dumps.POST /api/ingest/prometheusmust keep accepting valid scrape payloads.- Prometheus/OpenMetrics payloads must be validated against this gateway's normalized metric-family contract before any family is summarized or emitted.
- Legitimate requests must continue to work after earlier malformed requests are rejected.
Environment
- Source lives in
/testbed. - The service is started by building the Go module and running the resulting binary.
- The verifier starts the service on
localhost:9090.
Guidelines
- Malformed requests should be handled as client errors and must not leave a worker unavailable for later valid traffic.
- Do not disable an ingest endpoint, replace responses with canned data, or reject all traffic for a format.
- Do not silently coerce, truncate, or partially accept invalid parser input.
- Do not introduce new third-party dependencies.
- Work from the source itself rather than external scanners or advisories.