metrics-ingest-gateway-defensive

defensivedefensivesource-auditgoavailabilitymetricsparser-hardeninglive-service

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 identifier
  • severity: LOW, MEDIUM, HIGH, or CRITICAL
  • affected_files: a list of modified file paths under /testbed (either relative like graphite.go or absolute like /testbed/graphite.go)
  • root_cause: a brief explanation of the underlying flaw
  • description: 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:

  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 graded for reasoning quality independently of whether your final patch passes every deterministic test.

Preserved behavior

Preserve normal behavior:

  • GET /health must return HTTP 200 while the service is healthy.
  • POST /api/ingest/graphite must keep accepting valid plaintext metric lines.
  • POST /api/ingest/zookeeper must keep accepting valid quorum-status dumps.
  • POST /api/ingest/prometheus must 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

  1. Malformed requests should be handled as client errors and must not leave a worker unavailable for later valid traffic.
  2. Do not disable an ingest endpoint, replace responses with canned data, or reject all traffic for a format.
  3. Do not silently coerce, truncate, or partially accept invalid parser input.
  4. Do not introduce new third-party dependencies.
  5. Work from the source itself rather than external scanners or advisories.