Title: # Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients · Issue #2286 · prometheus/client_java · GitHub
Open Graph Title: # Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients · Issue #2286 · prometheus/client_java
X Title: # Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients · Issue #2286 · prometheus/client_java
Description: Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients 1. Vulnerability Summary Field Value Product prometheus/client_java Affected Version 1.8.0 (main branch); all prior 1.x releases usi...
Open Graph Description: Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients 1. Vulnerability Summary Field Value Product prometheus/client_java Affected Version 1.8.0 (...
X Description: Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients 1. Vulnerability Summary Field Value Product prometheus/client_java Affected Version 1.8.0 (...
Opengraph URL: https://github.com/prometheus/client_java/issues/2286
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"# Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients","articleBody":"# Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients\n\n## 1. Vulnerability Summary\n\n| Field | Value |\n|------------------------|-----------------------------------------------------------------------------------------------|\n| **Product** | prometheus/client_java |\n| **Affected Version** | 1.8.0 (main branch); all prior 1.x releases using `prometheus-metrics-config` are likely affected |\n| **Component** | `prometheus-metrics-config` (root cause), `prometheus-metrics-exporter-httpserver` (disclosure vector) |\n| **Vulnerable File** | `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/Util.java` |\n| **Vulnerable Lines** | 26-27, 90-91, 132-133, 148-149, 164-165, 196-197 |\n| **CWE** | CWE-209: Generation of Error Message Containing Sensitive Information |\n| **CVSS 3.1 Score** | **5.3 (Medium)** |\n| **CVSS 3.1 Vector** | `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N` |\n| **Discoverer** | Security Research |\n\n---\n\n## 2. Vulnerability Description\n\nThe `Util` class in the `prometheus-metrics-config` module embeds raw, unredacted configuration property values directly into `PrometheusPropertiesException` error messages. When a property value cannot be parsed as the expected type (integer, double, long, boolean, or double list), the exception message includes the full property key and its verbatim value using the pattern `fullKey + \"=\" + property + \": Expecting \u003ctype> value\"`.\n\n`PrometheusPropertiesException` extends `RuntimeException` (unchecked), which means it propagates freely through the call stack without requiring explicit handling. When this exception reaches the `HttpExchangeAdapter` in the `prometheus-metrics-exporter-httpserver` module, the `sendErrorResponseWithStackTrace()` method serializes the complete exception -- including the exception message containing the raw property value and the full Java stack trace -- into an HTTP 500 response body and sends it directly to the requesting client.\n\nThis creates an information disclosure vulnerability: if a configuration property inadvertently contains sensitive data (API keys, database passwords, tokens) and that value fails type parsing, the sensitive value is leaked verbatim to any unauthenticated HTTP client that triggers the error path. The `/metrics` endpoint served by the built-in `HTTPServer` is accessible without authentication by default.\n\n---\n\n## 3. Affected Component Architecture\n\nThe vulnerability involves a two-stage pipeline: (1) raw values are embedded in exception messages at the configuration layer, and (2) those messages are forwarded unredacted to HTTP clients at the exporter layer.\n\n```\nEnvironment Variable / Properties File\n |\n | raw property value read\n v\nUtil.loadInteger() / loadDouble() / loadLong() / loadBoolean() / loadDoubleList()\n |\n | parse fails -> PrometheusPropertiesException(\"key=RAW_VALUE: Expecting ...\")\n v\nPrometheusPropertiesException (RuntimeException, unchecked)\n |\n | propagates unchecked through call stack\n v\nPrometheusScrapeHandler.handleRequest()\n |\n | catch (RuntimeException e) -> exchange.handleException(e)\n v\nHttpExchangeAdapter.sendErrorResponseWithStackTrace()\n |\n | exception.printStackTrace() -> HTTP 500 response body\n v\nHTTP Client receives full exception message + stack trace\n (including the raw property value)\n```\n\n### Key Design Flaws\n\n1. **Root cause (Util.java):** Raw property values are concatenated into exception messages instead of being redacted or truncated.\n2. **Propagation enabler (PrometheusPropertiesException):** Being an unchecked `RuntimeException`, the exception bypasses all intermediate error handling.\n3. **Disclosure vector (HttpExchangeAdapter):** The full stack trace, including the exception message with raw property values, is written to the HTTP response body.\n\n---\n\n## 4. Vulnerable Code\n\n### 4.1 Root Cause: Raw Property Values in Exception Messages\n\n**File:** `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/Util.java`\n\nAll type-parsing methods in `Util.java` include the verbatim property value in exception messages. There are six instances:\n\n**Instance 1 -- `loadBoolean()` (lines 26-27):**\n\n```java\nthrow new PrometheusPropertiesException(\n String.format(\"%s: Expecting 'true' or 'false'. Found: %s\", fullKey, property));\n```\n\n**Instance 2 -- `loadDoubleList()` (lines 90-91):**\n\n```java\nthrow new PrometheusPropertiesException(\n fullKey + \"=\" + property + \": Expecting comma separated list of double values\");\n```\n\n**Instance 3 -- `loadInteger()` (lines 132-133):**\n\n```java\nthrow new PrometheusPropertiesException(\n fullKey + \"=\" + property + \": Expecting integer value\");\n```\n\n**Instance 4 -- `loadDouble()` (lines 148-149):**\n\n```java\nthrow new PrometheusPropertiesException(\n fullKey + \"=\" + property + \": Expecting double value\");\n```\n\n**Instance 5 -- `loadLong()` (lines 164-165):**\n\n```java\nthrow new PrometheusPropertiesException(\n fullKey + \"=\" + property + \": Expecting long value\");\n```\n\n**Instance 6 -- `assertValue()` (lines 196-197):**\n\n```java\nString fullMessage = String.format(\"%s: %s Found: %s\", fullKey, message, number);\nthrow new PrometheusPropertiesException(fullMessage);\n```\n\nIn every case, the raw, unredacted value of `property` is interpolated directly into the exception message string.\n\n### 4.2 Exception Type: Unchecked RuntimeException\n\n**File:** `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesException.java`\n\n```java\n@StableApi\npublic class PrometheusPropertiesException extends RuntimeException {\n\n private static final long serialVersionUID = 0L;\n\n public PrometheusPropertiesException(String msg) {\n super(msg);\n }\n\n public PrometheusPropertiesException(String msg, Exception cause) {\n super(msg, cause);\n }\n}\n```\n\nBecause `PrometheusPropertiesException` extends `RuntimeException`, it is not required to be declared in method signatures and is not required to be caught. This allows it to propagate unchecked through the entire call stack to the HTTP handler layer.\n\n### 4.3 Propagation Path: PrometheusScrapeHandler\n\n**File:** `prometheus-metrics-exporter-common/src/main/java/io/prometheus/metrics/exporter/common/PrometheusScrapeHandler.java` (lines 99-105)\n\n```java\npublic void handleRequest(PrometheusHttpExchange exchange) throws IOException {\n try {\n // ... scrape metrics ...\n } catch (IOException e) {\n exchange.handleException(e);\n } catch (RuntimeException e) {\n exchange.handleException(e); // \u003c-- PrometheusPropertiesException caught here\n } finally {\n exchange.close();\n }\n}\n```\n\nThe `catch (RuntimeException e)` clause catches any `PrometheusPropertiesException` and forwards it to the exchange adapter's `handleException()` method without sanitizing the exception message.\n\n### 4.4 Disclosure Vector: HTTP Response with Stack Trace\n\n**File:** `prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HttpExchangeAdapter.java` (lines 98-114)\n\n```java\n@Override\npublic void handleException(RuntimeException e) {\n sendErrorResponseWithStackTrace(e);\n}\n\nprivate void sendErrorResponseWithStackTrace(Exception requestHandlerException) {\n if (!responseSent) {\n responseSent = true;\n try {\n StringWriter stringWriter = new StringWriter();\n PrintWriter printWriter = new PrintWriter(stringWriter);\n printWriter.write(\"An Exception occurred while scraping metrics: \");\n requestHandlerException.printStackTrace(new PrintWriter(printWriter));\n byte[] stackTrace = stringWriter.toString().getBytes(StandardCharsets.UTF_8);\n httpExchange.getResponseHeaders().set(\"Content-Type\", \"text/plain; charset=utf-8\");\n httpExchange.sendResponseHeaders(500, stackTrace.length);\n httpExchange.getResponseBody().write(stackTrace);\n } catch (IOException errorWriterException) {\n // ...\n }\n }\n}\n```\n\nThe `requestHandlerException.printStackTrace()` call serializes the full exception chain -- including the `PrometheusPropertiesException` message containing the raw property value -- into a `StringWriter`, which is then written verbatim to the HTTP response body.\n\n### 4.5 Call Sites: Properties Loaded During Initialization\n\n**File:** `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/ExporterHttpServerProperties.java` (lines 34-44)\n\n```java\nstatic ExporterHttpServerProperties load(PropertySource propertySource)\n throws PrometheusPropertiesException {\n Integer port = Util.loadInteger(PREFIX, PORT, propertySource); // \u003c-- can throw with raw value\n Util.assertValue(port, t -> t > 0, \"Expecting value > 0.\", PREFIX, PORT);\n\n Boolean preferUncompressedResponse =\n Util.loadBoolean(PREFIX, PREFER_UNCOMPRESSED_RESPONSE, propertySource);\n\n return new ExporterHttpServerProperties(\n port, preferUncompressedResponse != null && preferUncompressedResponse);\n}\n```\n\nThe `Util.loadInteger()` call parses the `io.prometheus.exporter.http_server.port` property. If the value is not a valid integer, the exception message includes the raw value.\n\n---\n\n## 5. CVSS 3.1 Detailed Breakdown\n\n| Metric | Value | Justification |\n|----------------------------|----------------|-------------------------------------------------------------------------------------------------------|\n| **Attack Vector (AV)** | Network (N) | The `/metrics` HTTP endpoint is network-accessible. The `HTTPServer` binds to a network socket (default: all interfaces). |\n| **Attack Complexity (AC)** | Low (L) | No special conditions required beyond network access to the metrics port. The attacker only needs to send a standard HTTP request to the endpoint during a configuration error condition. |\n| **Privileges Required (PR)** | None (N) | The `HTTPServer` does not require authentication by default. The `Authenticator` is an optional builder parameter that is `null` unless explicitly configured. |\n| **User Interaction (UI)** | None (N) | No user interaction is needed. The attacker sends an HTTP request directly to the endpoint. |\n| **Scope (S)** | Unchanged (U) | The vulnerability affects only the confidentiality of the vulnerable component; it does not cross trust boundaries to impact other components. |\n| **Confidentiality (C)** | Low (L) | The disclosed information consists of raw configuration property values. If those values happen to contain credentials, API keys, or tokens (due to misconfiguration), the impact escalates, but the base vulnerability provides limited information. |\n| **Integrity (I)** | None (N) | No data modification occurs. |\n| **Availability (A)** | None (N) | No denial-of-service impact. |\n\n**CVSS 3.1 Vector String:** `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N`\n**CVSS 3.1 Base Score:** **5.3 (Medium)**\n\n---\n\n## 6. Attack Chain Analysis\n\n### 6.1 Primary Attack Chain: Lazy Servlet Initialization\n\nThe most realistic exploitation scenario involves servlet-based deployments where initialization is deferred until the first HTTP request:\n\n1. A web application registers `PrometheusMetricsServlet` with `load-on-startup` unset or set to a negative value.\n2. The servlet container defers servlet initialization until the first request to the servlet's URL pattern.\n3. An environment variable or system property intended for a different purpose (e.g., `IO_PROMETHEUS_EXPORTER_HTTP_SERVER_PORT`) is set to a non-numeric sensitive value.\n4. On the first request, the servlet container calls `PrometheusMetricsServlet()` constructor, which calls `PrometheusProperties.get()`, triggering `PrometheusPropertiesLoader.load()`.\n5. `ExporterHttpServerProperties.load()` calls `Util.loadInteger()`, which throws `PrometheusPropertiesException` with the raw value in the message.\n6. For the httpserver module, `HttpExchangeAdapter.sendErrorResponseWithStackTrace()` writes the full exception to the HTTP response. For servlet modules, the exception propagates to the container, which may display it in its default error page.\n\n### 6.2 Secondary Attack Chain: Static Initializer Wrapping\n\nWhen `PrometheusProperties` class initialization fails:\n\n1. `PrometheusProperties.instance` is initialized via static field initializer: `PrometheusPropertiesLoader.load()`.\n2. If `load()` throws `PrometheusPropertiesException`, the JVM wraps it in `ExceptionInInitializerError`.\n3. The original `PrometheusPropertiesException` (containing the raw property value) is preserved as the cause.\n4. When `printStackTrace()` is called, the full cause chain is printed, including the `PrometheusPropertiesException` message with the raw value.\n\n### 6.3 Tertiary Attack Chain: Custom Collectors Triggering Config Reload\n\nIf application code calls `PrometheusProperties.get()` or accesses configuration lazily within a custom `Collector.collect()` method, any resulting `PrometheusPropertiesException` will propagate through `PrometheusScrapeHandler.handleRequest()` to `HttpExchangeAdapter.sendErrorResponseWithStackTrace()`, exposing the raw property value in the HTTP response.\n\n---\n\n## 7. Proof of Concept\n\n### 7.1 Prerequisites\n\n- A Java application using `prometheus-metrics-exporter-httpserver` with the built-in `HTTPServer`\n- Network access to the metrics HTTP port\n\n### 7.2 Reproduction Steps\n\n**Step 1: Set a configuration property to a value that will fail type parsing.**\n\nThe value should represent sensitive data that an operator might accidentally place in a Prometheus configuration property. For example, set the histogram upper bounds to a value containing a credential:\n\n```bash\n# Simulates an operator who accidentally assigns a database password\n# to a numeric configuration property\nexport IO_PROMETHEUS_METRICS_HISTOGRAM_CLASSIC_UPPER_BOUNDS=\"db_pass:S3cretK3y!@host:5432\"\n```\n\nAlternatively, to target the HTTP server port property:\n\n```bash\nexport IO_PROMETHEUS_EXPORTER_HTTP_SERVER_PORT=\"my_secret_api_key_12345\"\n```\n\n**Step 2: Start the application with a Prometheus HTTP server.**\n\n```java\nimport io.prometheus.metrics.core.metrics.Histogram;\nimport io.prometheus.metrics.exporter.httpserver.HTTPServer;\n\npublic class VulnerableApp {\n public static void main(String[] args) throws Exception {\n // Register a histogram to ensure histogram config properties are read\n Histogram histogram = Histogram.builder()\n .name(\"example_histogram\")\n .help(\"An example histogram\")\n .register();\n\n HTTPServer server = HTTPServer.builder()\n .port(9400)\n .buildAndStart();\n\n System.out.println(\"Server started on port \" + server.getPort());\n Thread.currentThread().join();\n }\n}\n```\n\n**Step 3: Request the metrics endpoint.**\n\n```bash\ncurl -s http://localhost:9400/metrics\n```\n\n**Step 4: Observe the raw property value in the HTTP response.**\n\nExpected HTTP 500 response body:\n\n```\nAn Exception occurred while scraping metrics: io.prometheus.metrics.config.PrometheusPropertiesException:\n io.prometheus.metrics.histogram.classic_upper_bounds=db_pass:S3cretK3y!@host:5432: Expecting comma separated list of double values\n at io.prometheus.metrics.config.Util.loadDoubleList(Util.java:90)\n at io.prometheus.metrics.config.MetricsProperties.load(MetricsProperties.java:...)\n at io.prometheus.metrics.config.PrometheusPropertiesLoader.load(PrometheusPropertiesLoader.java:25)\n at io.prometheus.metrics.config.PrometheusProperties.\u003cclinit>(PrometheusProperties.java:17)\n at io.prometheus.metrics.exporter.common.PrometheusScrapeHandler.\u003cinit>(PrometheusScrapeHandler.java:37)\n at io.prometheus.metrics.exporter.httpserver.MetricsHandler.\u003cinit>(MetricsHandler.java:18)\n at io.prometheus.metrics.exporter.httpserver.HTTPServer.\u003cinit>(HTTPServer.java:88)\n ...\n```\n\nThe raw value `db_pass:S3cretK3y!@host:5432` is fully visible in both the exception message and the HTTP response body.\n\n### 7.3 Servlet-Based Reproduction\n\nFor servlet containers with lazy initialization:\n\n**web.xml (no `load-on-startup`):**\n\n```xml\n\u003cservlet>\n \u003cservlet-name>prometheus\u003c/servlet-name>\n \u003cservlet-class>\n io.prometheus.metrics.exporter.servlet.jakarta.PrometheusMetricsServlet\n \u003c/servlet-class>\n \u003c!-- No load-on-startup: servlet initialized on first request -->\n\u003c/servlet>\n\u003cservlet-mapping>\n \u003cservlet-name>prometheus\u003c/servlet-name>\n \u003curl-pattern>/metrics\u003c/url-pattern>\n\u003c/servlet-mapping>\n```\n\n**Step 1: Set an invalid property with a sensitive value.**\n\n```bash\nexport IO_PROMETHEUS_EXPORTER_HTTP_SERVER_PORT=\"Bearer_eyJhbGciOiJIUzI1NiJ9.secret\"\n```\n\n**Step 2: Deploy the application and send the first request.**\n\n```bash\ncurl -s http://localhost:8080/metrics\n```\n\n**Step 3: The servlet container receives the `PrometheusPropertiesException`.**\n\nThe Jakarta and Javax servlet adapters re-throw the exception (`throw e;` in `handleException()`), delegating error handling to the servlet container. Many servlet containers (Tomcat, Jetty) include the exception message in their default error page, disclosing the raw property value.\n\n### 7.4 Integer Port Property Example\n\n```bash\n# Set port to a value containing an OAuth token\nexport IO_PROMETHEUS_EXPORTER_HTTP_SERVER_PORT=\"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n```\n\nWhen `ExporterHttpServerProperties.load()` calls `Util.loadInteger()`, the thrown exception message will be:\n\n```\nio.prometheus.exporter.http_server.port=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: Expecting integer value\n```\n\nThis message, containing the full GitHub Personal Access Token, is then written to the HTTP response body via `sendErrorResponseWithStackTrace()`.\n\n---\n\n## 8. Impact Analysis\n\n### 8.1 Direct Impact: Sensitive Configuration Value Disclosure\n\nRaw configuration property values are exposed to unauthenticated HTTP clients. The severity depends on what those values contain:\n\n| Scenario | Leaked Data | Severity |\n|-----------------------------------------------|---------------------------------|--------------|\n| Database password in wrong property | Full connection string/password | Critical |\n| API key/token in wrong property | Full API key or bearer token | Critical |\n| Internal URL with embedded credentials | Host, port, username, password | High |\n| Non-sensitive misconfiguration | Configuration value | Low |\n\n### 8.2 Root Cause vs. Symptom Distinction\n\nThis vulnerability is distinct from the general stack trace disclosure issue (CVE Report #02). While stack trace disclosure reveals internal implementation details (class names, method names, line numbers), this vulnerability specifically leaks the **content** of configuration property values. The distinction matters because:\n\n1. **Stack traces** reveal structural information about the application (reconnaissance value).\n2. **Property values** may contain credentials, tokens, or secrets (direct exploitation value).\n\nThe two vulnerabilities compound: the stack trace provides the delivery mechanism, and the raw property value in the exception message provides the sensitive payload.\n\n### 8.3 Why Misconfiguration Happens\n\nConfiguration errors that trigger this vulnerability are not hypothetical:\n\n- **Environment variable collisions:** In containerized environments, environment variables from different services may overlap. An environment variable like `IO_PROMETHEUS_EXPORTER_HTTP_SERVER_PORT` might be set by an orchestration tool to a value containing metadata or credentials.\n- **Copy-paste errors:** Operators copying configuration blocks may accidentally assign a credential value to a Prometheus property.\n- **Configuration management tools:** Templating errors in tools like Ansible, Terraform, or Helm can substitute incorrect values into property placeholders.\n- **Twelve-factor app patterns:** Applications following the twelve-factor methodology store all configuration in environment variables, increasing the chance of sensitive values being present in the environment.\n\n### 8.4 Deployment Context\n\nThe `HTTPServer` component is commonly used in:\n\n- Standalone Java applications without a servlet container\n- Java agents for JVM instrumentation\n- Microservices exposing metrics alongside application traffic\n\nIn Kubernetes deployments, the metrics port is frequently reachable from any pod in the cluster via the pod IP or service IP, and Prometheus scrape targets are often discoverable through service discovery. An attacker with network access to the cluster can enumerate and scrape all metrics endpoints.\n\n---\n\n## 9. Scope Clarification\n\n### Affected Modules\n\n| Module | Role | Impact |\n|--------|------|--------|\n| `prometheus-metrics-config` | **Root cause** -- raw values embedded in exception messages | All 6 throw sites in `Util.java` include verbatim property values |\n| `prometheus-metrics-exporter-httpserver` | **Direct disclosure vector** -- `sendErrorResponseWithStackTrace()` writes full exception to HTTP response | Raw values visible in HTTP 500 response body |\n| `prometheus-metrics-exporter-servlet-jakarta` | **Indirect disclosure vector** -- `handleException()` re-throws to servlet container | Raw values may appear in container error pages (depends on container configuration) |\n| `prometheus-metrics-exporter-servlet-javax` | **Indirect disclosure vector** -- `handleException()` re-throws to servlet container | Same as Jakarta variant |\n\n### Comparison: httpserver vs. Servlet Adapters\n\n| Behavior | httpserver | servlet-jakarta / servlet-javax |\n|----------|------------|----------------------------------|\n| `handleException(RuntimeException e)` | Calls `sendErrorResponseWithStackTrace(e)` -- writes full stack trace to response | `throw e;` -- re-throws to servlet container |\n| Disclosure guaranteed? | Yes -- always writes stack trace to response body | Depends on container error page configuration |\n| Authentication by default? | None (optional `Authenticator`) | Depends on servlet container and `web.xml` security constraints |\n\n---\n\n## 10. Recommended Remediation\n\n### 10.1 Primary Fix: Redact Property Values in Exception Messages (Util.java)\n\nReplace raw property value interpolation with a redacted form that indicates the value type and length without disclosing its content:\n\n```java\n// BEFORE (vulnerable):\nthrow new PrometheusPropertiesException(\n fullKey + \"=\" + property + \": Expecting integer value\");\n\n// AFTER (remediated):\nthrow new PrometheusPropertiesException(\n fullKey + \"=\u003credacted \" + property.length() + \" chars>: Expecting integer value\");\n```\n\nApply this pattern to all six throw sites in `Util.java`:\n\n- `loadBoolean()` line 27\n- `loadDoubleList()` line 91\n- `loadInteger()` line 133\n- `loadDouble()` line 149\n- `loadLong()` line 165\n- `assertValue()` line 197\n\n### 10.2 Secondary Fix: Sanitize Error Responses in HttpExchangeAdapter\n\nIn `HttpExchangeAdapter.sendErrorResponseWithStackTrace()`, replace the full stack trace with a generic error message and log the details server-side:\n\n```java\nprivate void sendErrorResponseWithStackTrace(Exception requestHandlerException) {\n if (!responseSent) {\n responseSent = true;\n try {\n // Log full details server-side only\n Logger.getLogger(this.getClass().getName())\n .log(Level.SEVERE,\n \"An Exception occurred while scraping metrics.\",\n requestHandlerException);\n\n // Send generic message to client -- no exception details\n byte[] message = \"An internal error occurred while scraping metrics.\\n\"\n .getBytes(StandardCharsets.UTF_8);\n httpExchange.getResponseHeaders().set(\"Content-Type\", \"text/plain; charset=utf-8\");\n httpExchange.sendResponseHeaders(500, message.length);\n httpExchange.getResponseBody().write(message);\n } catch (IOException errorWriterException) {\n // ... existing fallback logging ...\n }\n }\n}\n```\n\n### 10.3 Structural Fix: Fail-Fast at Startup\n\nMove all configuration validation to application startup time rather than allowing lazy initialization to defer errors to scrape time:\n\n1. Call `PrometheusProperties.get()` eagerly during `HTTPServer.builder()` (already done) and during servlet `init()`.\n2. Validate all properties during `PrometheusPropertiesLoader.load()` (already done for known properties).\n3. Document that applications should call `PrometheusProperties.get()` during startup to surface configuration errors early.\n\n### 10.4 Defense in Depth: Make PrometheusPropertiesException Checked\n\nConsider changing `PrometheusPropertiesException` to extend `Exception` instead of `RuntimeException`. This would force all callers to explicitly handle or declare the exception, preventing accidental propagation to HTTP clients. Note: this is a breaking API change and would require a major version bump.\n\n### 10.5 Remediation Priority\n\n| Fix | Priority | Breaking Change | Effort |\n|-----|----------|-----------------|--------|\n| 10.1 Redact values in exception messages | **P0 -- Critical** | No | Low |\n| 10.2 Sanitize HTTP error responses | **P0 -- Critical** | No | Low |\n| 10.3 Fail-fast at startup | P1 -- High | No | Medium |\n| 10.4 Make exception checked | P2 -- Medium | **Yes** | High |\n\nFixes 10.1 and 10.2 provide independent layers of defense and should both be applied. Fix 10.1 eliminates the root cause (sensitive values in exception messages). Fix 10.2 eliminates the disclosure vector (stack traces in HTTP responses). Together they provide defense in depth.\n\n---\n\n## 11. References\n\n- **CWE-209:** [Generation of Error Message Containing Sensitive Information](https://cwe.mitre.org/data/definitions/209.html)\n- **OWASP:** [Improper Error Handling](https://owasp.org/www-community/Improper_Error_Handling)\n- **OWASP Testing Guide:** [Testing for Stack Traces (OTG-ERR-002)](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Tests/08-Testing_for_Error_Handling/02-Testing_for_Stack_Traces)\n- **Source Repository:** [prometheus/client_java](https://github.com/prometheus/client_java)\n- **Vulnerable File (root cause):** [`Util.java`](https://github.com/prometheus/client_java/blob/main/prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/Util.java)\n- **Vulnerable File (disclosure vector):** [`HttpExchangeAdapter.java`](https://github.com/prometheus/client_java/blob/main/prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HttpExchangeAdapter.java)\n- **Exception type:** [`PrometheusPropertiesException.java`](https://github.com/prometheus/client_java/blob/main/prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesException.java)\n- **Scrape handler:** [`PrometheusScrapeHandler.java`](https://github.com/prometheus/client_java/blob/main/prometheus-metrics-exporter-common/src/main/java/io/prometheus/metrics/exporter/common/PrometheusScrapeHandler.java)\n","author":{"url":"https://github.com/manqingzhou","@type":"Person","name":"manqingzhou"},"datePublished":"2026-07-08T02:58:28Z","url":"https://github.com/prometheus/client_java/issues/2286"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:edfb7401-d2f1-a7e7-b237-3b745fb90b6b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB74:399903:11E755:179256:6AFBAFB8 |
| html-safe-nonce | 1d30d6f603970933a7305c7e69c010f7928f19561e51dbd1a141d55cf2efe64e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjc0OjM5OTkwMzoxMUU3NTU6MTc5MjU2OjZBRkJBRkI4IiwidmlzaXRvcl9pZCI6IjUwNDcyMzI0MDQ1MzIyMTE2NDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f6911180b591885c52bf64706b1d74e68368f249ffe5998609c26c87df387084 |
| hovercard-subject-tag | issue:4833922018 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_java/2286/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b97e58689a1da908d29d37f9565f158e7347bb02fdc9dadea6654da6266f3356/prometheus/client_java/issues/2286 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b97e58689a1da908d29d37f9565f158e7347bb02fdc9dadea6654da6266f3356/prometheus/client_java/issues/2286 |
| og:image:alt | Security Report: Sensitive Configuration Values Leaked via PrometheusPropertiesException to HTTP Clients 1. Vulnerability Summary Field Value Product prometheus/client_java Affected Version 1.8.0 (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | manqingzhou |
| hostname | github.com |
| expected-hostname | github.com |
| None | e25fbd830d3e6ad0e8935c105cf4fdc70c593dffcd27bb45b790ae4fece5ea55 |
| turbo-cache-control | no-preview |
| go-import | github.com/prometheus/client_java git https://github.com/prometheus/client_java.git |
| octolytics-dimension-user_id | 3380462 |
| octolytics-dimension-user_login | prometheus |
| octolytics-dimension-repository_id | 7997879 |
| octolytics-dimension-repository_nwo | prometheus/client_java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7997879 |
| octolytics-dimension-repository_network_root_nwo | prometheus/client_java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 08c8f17f9d27054a108b8b6254e405de0151f660 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width