Skip to content

Commit

Permalink
Merge pull request #3819 from craigmayhew/landing-page-security
Browse files Browse the repository at this point in the history
Fixed potential security issue with $landPage receiving variables
  • Loading branch information
PromoFaux committed Oct 30, 2020
2 parents 3e79e0b + 95a28ae commit 89d94ac
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions advanced/index.php
Expand Up @@ -55,7 +55,16 @@ function setHeader($type = "x") {
// Redirect to Web Interface
exit(header("Location: /admin"));
} elseif (filter_var($serverName, FILTER_VALIDATE_IP) || in_array($serverName, $authorizedHosts)) {
// Set Splash Page output
// When directly browsing via IP or authorized hostname
// Render splash/landing page based off presence of $landPage file
// Unset variables so as to not be included in $landPage or $splashPage
unset($serverName, $svPasswd, $svEmail, $authorizedHosts, $validExtTypes, $currentUrlExt, $viewPort);
// If $landPage file is present
if (is_file(getcwd()."/$landPage")) {
include $landPage;
exit();
}
// If $landPage file was not present, Set Splash Page output
$splashPage = "
<!doctype html>
<html lang='en'>
Expand All @@ -74,15 +83,7 @@ function setHeader($type = "x") {
</body>
</html>
";

// Set splash/landing page based off presence of $landPage
$renderPage = is_file(getcwd()."/$landPage") ? include $landPage : "$splashPage";

// Unset variables so as to not be included in $landPage
unset($serverName, $svPasswd, $svEmail, $authorizedHosts, $validExtTypes, $currentUrlExt, $viewPort);

// Render splash/landing page when directly browsing via IP or authorized hostname
exit($renderPage);
exit($splashPage);
} elseif ($currentUrlExt === "js") {
// Serve Pi-hole JavaScript for blocked domains requesting JS
exit(setHeader("js").'var x = "Pi-hole: A black hole for Internet advertisements."');
Expand Down

0 comments on commit 89d94ac

Please sign in to comment.