Skip to content

Commit

Permalink
Merge pull request #253 from NoiseByNorthwest/fix/251
Browse files Browse the repository at this point in the history
Web UI: fix unconfined file access via SPX_UI_URI
  • Loading branch information
NoiseByNorthwest authored Jul 26, 2024
2 parents e0a7842 + 9eb2e58 commit f84f2b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/php_spx.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,10 @@ static void http_ui_handler_shutdown(void)
ui_uri = "/index.html";
}

if (ui_uri[0] != '/' || strstr(ui_uri, "/../") != NULL) {
goto error_404;
}

if (0 == http_ui_handler_data(SPX_G(data_dir), ui_uri)) {
goto finish;
}
Expand Down
21 changes: 21 additions & 0 deletions tests/spx_ui_uri_confinement.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
UI: URI confinement
--CGI--
--INI--
spx.http_enabled=1
spx.http_key="dev"
spx.http_ip_whitelist="127.0.0.1"
log_errors=on
--ENV--
return <<<END
REMOTE_ADDR=127.0.0.1
REQUEST_URI=/
END;
--GET--
SPX_KEY=dev&SPX_UI_URI=/js/../../../README.md
--FILE--
<?php
// noop
?>
--EXPECT--
File not found.

0 comments on commit f84f2b6

Please sign in to comment.