Skip to content

Commit 048bbc6

Browse files
committed
fix(envlite): block .ht* paths in router so SQLite DB is not downloadable
php -S does not honor Apache .ht* deny rules, so a request for /wp-content/database/.ht.sqlite would be served as a static binary by the existing-file passthrough.
1 parent 53dac6f commit 048bbc6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tools/local-env/router.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
3+
4+
// php -S does not honor Apache .ht* deny rules. Block any segment so the
5+
// SQLite DB at wp-content/database/.ht.sqlite is not downloadable.
6+
if (preg_match('#(^|/)\.ht#', $path)) {
7+
http_response_code(403);
8+
return true;
9+
}
10+
311
$file = dirname(__DIR__, 2) . '/src' . $path;
412
if ($path !== '/' && file_exists($file) && !is_dir($file)) {
513
return false;

0 commit comments

Comments
 (0)