summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglenda <glenda@9front.local>2021-11-21 23:42:13 +0000
committerglenda <glenda@9front.local>2021-11-21 23:42:13 +0000
commite2a8d3493ab0fdc345b6513a53f30f2b4f36ed97 (patch)
treea7180c6a34f502f6315353ab994833edc87b6460
parenta27afe904d4b65520cdc5f2a13c69894a9bb02c1 (diff)
/rc/bin/rc-httpd/{rc-httpd, handlers/error}: do some minimal sanitization on $SERVER_NAME before handing it off to select-handler. this prevents malformed Host: headers from retrieving arbitrary files from the file system. (thanks, Lightning)
-rwxr-xr-xrc/bin/rc-httpd/handlers/error5
-rwxr-xr-xrc/bin/rc-httpd/rc-httpd5
2 files changed, 10 insertions, 0 deletions
diff --git a/rc/bin/rc-httpd/handlers/error b/rc/bin/rc-httpd/handlers/error
index e0608a988..fa594a9f1 100755
--- a/rc/bin/rc-httpd/handlers/error
+++ b/rc/bin/rc-httpd/handlers/error
@@ -19,6 +19,11 @@ fn do_error{
'
}
+fn 400{
+ do_error '400 Bad Request' \
+ 'The request was invalid.'
+}
+
fn 401{
do_error '401 Unauthorized' \
'The requested path '^$"location^' requires authorization.'
diff --git a/rc/bin/rc-httpd/rc-httpd b/rc/bin/rc-httpd/rc-httpd
index 3fd49fbf0..13533292a 100755
--- a/rc/bin/rc-httpd/rc-httpd
+++ b/rc/bin/rc-httpd/rc-httpd
@@ -85,6 +85,11 @@ if(~ $#SERVER_NAME 2){
SERVER_PORT=$SERVER_NAME(2)
SERVER_NAME=$SERVER_NAME(1)
}
+switch($SERVER_NAME){
+ case */* ..
+ error 400
+ exit
+}
if(~ $REQUEST_METHOD (PUT POST)){
if(! ~ $"CONTENT_LENGTH '')
trim_input | exec $rc_httpd_dir/select-handler