You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2025/12/22 11:14:07 UTC
svn commit: r1930794 - in httpd/httpd/trunk/test/modules/core: . htdocs/cgi
Author: jorton
Date: Mon Dec 22 11:14:06 2025
New Revision: 1930794
Log:
* test/modules/core: Adds regression test for CGI env var override
Submitted by: Giannis Christodoulou <io.xristod gmail.com>
Github: closes #589
Added:
httpd/httpd/trunk/test/modules/core/htdocs/cgi/env_parameters.py
httpd/httpd/trunk/test/modules/core/test_003_cgi_env_vars.py
Added: httpd/httpd/trunk/test/modules/core/htdocs/cgi/env_parameters.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ httpd/httpd/trunk/test/modules/core/htdocs/cgi/env_parameters.py Mon Dec 22 11:14:06 2025 (r1930794)
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import os
+import json
+
+print("Content-Type: application/json")
+print()
+
+data = {
+ "REQUEST_METHOD": os.getenv("REQUEST_METHOD", ""),
+ "QUERY_STRING": os.getenv("QUERY_STRING", ""),
+}
+
+print(json.dumps(data, indent=2))
Added: httpd/httpd/trunk/test/modules/core/test_003_cgi_env_vars.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ httpd/httpd/trunk/test/modules/core/test_003_cgi_env_vars.py Mon Dec 22 11:14:06 2025 (r1930794)
@@ -0,0 +1,33 @@
+import pytest
+
+from pyhttpd.conf import HttpdConf
+
+class TestCGIEnvVars:
+
+ @pytest.fixture(autouse=True, scope='class')
+ def _class_scope(self, env):
+ conf = HttpdConf(env, extras={
+ 'base': f"""
+ <Directory "{env.gen_dir}">
+ AllowOverride None
+ Options +ExecCGI
+ </Directory>
+ SetEnv REQUEST-METHOD OVERRIDDEN
+ SetEnv QUERY.STRING OVERRIDDEN
+ """,
+ })
+ conf.add_vhost_cgi()
+ conf.install()
+ assert env.apache_restart() == 0
+
+ def test_cgi_003_01(self, env):
+ """
+ CVE-2025-65082:
+ Configuration-defined env vars must not override
+ server-calculated CGI env vars.
+ """
+ url = env.mkurl("http", "cgi", "/env_parameters.py?x=123")
+ r = env.curl_get(url)
+ assert r.response["status"] == 200
+ assert r.response["json"]["REQUEST_METHOD"] == "GET"
+ assert r.response["json"]["QUERY_STRING"] == "x=123"