Skip to content

Commit f718bc3

Browse files
committed
* test/modules/core: Adds regression test for CGI env var override
Submitted by: Giannis Christodoulou <io.xristod gmail.com> Github: closes #589 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1930794 13f79535-47bb-0310-9956-ffa450edef68
1 parent befb523 commit f718bc3

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import json
5+
6+
print("Content-Type: application/json")
7+
print()
8+
9+
data = {
10+
"REQUEST_METHOD": os.getenv("REQUEST_METHOD", ""),
11+
"QUERY_STRING": os.getenv("QUERY_STRING", ""),
12+
}
13+
14+
print(json.dumps(data, indent=2))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
3+
from pyhttpd.conf import HttpdConf
4+
5+
class TestCGIEnvVars:
6+
7+
@pytest.fixture(autouse=True, scope='class')
8+
def _class_scope(self, env):
9+
conf = HttpdConf(env, extras={
10+
'base': f"""
11+
<Directory "{env.gen_dir}">
12+
AllowOverride None
13+
Options +ExecCGI
14+
</Directory>
15+
SetEnv REQUEST-METHOD OVERRIDDEN
16+
SetEnv QUERY.STRING OVERRIDDEN
17+
""",
18+
})
19+
conf.add_vhost_cgi()
20+
conf.install()
21+
assert env.apache_restart() == 0
22+
23+
def test_cgi_003_01(self, env):
24+
"""
25+
CVE-2025-65082:
26+
Configuration-defined env vars must not override
27+
server-calculated CGI env vars.
28+
"""
29+
url = env.mkurl("http", "cgi", "/env_parameters.py?x=123")
30+
r = env.curl_get(url)
31+
assert r.response["status"] == 200
32+
assert r.response["json"]["REQUEST_METHOD"] == "GET"
33+
assert r.response["json"]["QUERY_STRING"] == "x=123"

0 commit comments

Comments
 (0)