References: CVE-2026-16527
Description: pmproxy: fix missing -Q and -S authentication flags (CWE-306)
 The pmproxy -Q (require client certificate) and -S (require
 authenticated clients) flags existed as case blocks in the option
 parser but were absent from the short_options string and the longopts
 table, making them permanently unreachable.  An unauthenticated HTTP
 client could access all REST API endpoints including /store and /derive.
 .
 Fix:
 - Add Q and S to short_options so pmgetopt_r() delivers them
 - Add --certreqd and --reqauth entries to the longopts table
 - Document both flags in the pmproxy(1) man page
 - Add qa/2100 verifying the flags are accepted and that -S correctly
   rejects unauthenticated REST API requests with HTTP 403
 .
 Note: -S enforcement in the REST API path already exists in http.c and
 webapi.c.  -Q (CERT_REQD) enforcement is only implemented for the
 legacy PCP wire protocol path, not the REST API; this is a pre-existing
 limitation to be addressed separately.
 .
 Reported-by: Francisco Alisson Bezerra, TIM Security Red Team
 Reported-by: Lucas Gabriel Alves, TIM Security Red Team
 Reported-by: Massimiliano Brolli, TIM Security Red Team
 .
 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
 .
Author: Nathan Scott <nathans@redhat.com>
Origin: upstream, https://github.com/performancecopilot/pcp/commit/d96ba5a716eeff7840138eb08fbab0d11a57f641 https://github.com/performancecopilot/pcp/commit/81a9efe96db6f7764a1a1646b64eb85de5cdaf77 https://github.com/performancecopilot/pcp/commit/4121ae06f54ab2089adf7270197c774d60dd03c8
Last-Update: 2026-07-25
 Backport-Note:
 Backported to PCP 6.3.8 (applies unchanged). The logger-servlet authentication
  (logger.c, pmproxy.conf) and man page are absent in 6.3.8 and dropped; the core
  -Q/-S flag enablement and REST CERT_REQD enforcement are carried.


--- a/src/pmproxy/src/pmproxy.c
+++ b/src/pmproxy/src/pmproxy.c
@@ -82,7 +82,9 @@
     PMAPI_OPTIONS_HEADER("Connection options"),
     { "interface", 1, 'i', "ADDR", "accept connections on this IP address" },
     { "port", 1, 'p', "PORT", "accept connections on this port" },
+    { "certreqd", 0, 'Q', 0, "require client certificate authentication" },
     { "socket", 1, 's', "PATH", "Unix domain socket file [default $PCP_RUN_DIR/pmproxy.socket]" },
+    { "reqauth", 0, 'S', 0, "require all client connections to be authenticated" },
     { "keyport", 1, 'r', "PORT", "Connect to key server on this TCP/IP port (implies --timeseries)" },
     { "keyhost", 1, 'h', "HOST", "Connect to key server on this host name (implies --timeseries)" },
     { "redisport", 1, 'r', "PORT", "Backwards-compatibility option, do not use" },
@@ -95,7 +97,7 @@
 };
 
 static pmOptions opts = {
-    .short_options = "Ac:dD:Ffh:i:l:L:p:r:s:tT:U:x:?",
+    .short_options = "Ac:dD:Ffh:i:l:L:p:Qr:s:StT:U:x:?",
     .long_options = longopts,
 };
 
--- a/src/pmproxy/src/http.c
+++ b/src/pmproxy/src/http.c
@@ -1091,6 +1091,20 @@
 	}
     }
 
+    /* client certificate required for all servlets */
+    if (__pmServerHasFeature(PM_SERVER_FEATURE_CERT_REQD)) {
+#ifdef HAVE_OPENSSL
+	if (!client->stream.secure ||
+	    !client->secure.ssl ||
+	    SSL_get_peer_certificate(client->secure.ssl) == NULL) {
+	    client->u.http.parser.status_code = HTTP_STATUS_FORBIDDEN;
+	}
+#else
+	/* no TLS support compiled in, reject all connections */
+	client->u.http.parser.status_code = HTTP_STATUS_FORBIDDEN;
+#endif
+    }
+
     return sts;
 }
 
