summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Esser2014-06-09 09:03:03 +0200
committerStefan Esser2014-06-09 09:03:03 +0200
commit134a88c1da096f787a560c43534f07b74867b9cb (patch)
treeab925ecba15c137a3b916ac65964d9b1c32f513a
parentcd70620d20aef7fa5b89065c39708186f0b590c4 (diff)
Add protection against injection attacks (like XSS/SQL/other) through HTTP User-Agent String
-rw-r--r--Changelog1
-rw-r--r--ifilter.c1
-rw-r--r--tests/filter/server_user_agent_strip_off.phpt27
-rw-r--r--tests/filter/server_user_agent_strip_on.phpt27
4 files changed, 56 insertions, 0 deletions
diff --git a/Changelog b/Changelog
index 69101e8..77235e5 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,7 @@
12014-05-xx - 0.9.36-dev 12014-05-xx - 0.9.36-dev
2 2
3 - Added better handling of non existing/non executable shell scripts 3 - Added better handling of non existing/non executable shell scripts
4 - Added protection against XSS/SQL/Other Injections through User-Agent HTTP header
4 - Added LICENSE file to make distributions happy 5 - Added LICENSE file to make distributions happy
5 6
62014-02-24 - 0.9.35 72014-02-24 - 0.9.35
diff --git a/ifilter.c b/ifilter.c
index d73106b..cd02869 100644
--- a/ifilter.c
+++ b/ifilter.c
@@ -249,6 +249,7 @@ void suhosin_register_server_variables(zval *track_vars_array TSRMLS_DC)
249 suhosin_server_strip(svars, "PHP_SELF", sizeof("PHP_SELF")); 249 suhosin_server_strip(svars, "PHP_SELF", sizeof("PHP_SELF"));
250 suhosin_server_strip(svars, "PATH_INFO", sizeof("PATH_INFO")); 250 suhosin_server_strip(svars, "PATH_INFO", sizeof("PATH_INFO"));
251 suhosin_server_strip(svars, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")); 251 suhosin_server_strip(svars, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"));
252 suhosin_server_strip(svars, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"));
252 } 253 }
253} 254}
254/* }}} */ 255/* }}} */
diff --git a/tests/filter/server_user_agent_strip_off.phpt b/tests/filter/server_user_agent_strip_off.phpt
new file mode 100644
index 0000000..36c6580
--- /dev/null
+++ b/tests/filter/server_user_agent_strip_off.phpt
@@ -0,0 +1,27 @@
1--TEST--
2Testing: suhosin.server.strip=On
3--DESCRIPTION--
4This test is not exactly what we want, but good enough due to limitations of the test framework.
5--INI--
6suhosin.log.syslog=0
7suhosin.log.sapi=0
8suhosin.log.stdout=255
9suhosin.log.script=0
10suhosin.server.strip=Off
11--SKIPIF--
12<?php include('skipif.inc'); ?>
13--ENV--
14return <<<END
15HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.0; rv:29.0) <script>alert('123');</script>Gecko/20100101 Firefox/29.0
16END;
17--COOKIE--
18--GET--
19A=B
20--POST--
21--FILE--
22<?php
23var_dump($_SERVER['HTTP_USER_AGENT']);
24?>
25--EXPECTF--
26string(95) "Mozilla/5.0 (Windows NT 6.0; rv:29.0) <script>alert('123');</script>Gecko/20100101 Firefox/29.0"
27
diff --git a/tests/filter/server_user_agent_strip_on.phpt b/tests/filter/server_user_agent_strip_on.phpt
new file mode 100644
index 0000000..73d577c
--- /dev/null
+++ b/tests/filter/server_user_agent_strip_on.phpt
@@ -0,0 +1,27 @@
1--TEST--
2Testing: suhosin.server.strip=On
3--DESCRIPTION--
4This test is not exactly what we want, but good enough due to limitations of the test framework.
5--INI--
6suhosin.log.syslog=0
7suhosin.log.sapi=0
8suhosin.log.stdout=255
9suhosin.log.script=0
10suhosin.server.strip=On
11--SKIPIF--
12<?php include('skipif.inc'); ?>
13--ENV--
14return <<<END
15HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.0; rv:29.0) <script>alert('123');</script>Gecko/20100101 Firefox/29.0
16END;
17--COOKIE--
18--GET--
19A=B
20--POST--
21--FILE--
22<?php
23var_dump($_SERVER['HTTP_USER_AGENT']);
24?>
25--EXPECTF--
26string(95) "Mozilla/5.0 (Windows NT 6.0; rv:29.0) ?script?alert(?123?);?/script?Gecko/20100101 Firefox/29.0"
27