Skip to content

Commit 8c0f785

Browse files
committed
Replace mg.request_info.request_uri with the variable scriptname
The information from `mg.request_info.request_uri` depends on the URL typed by the user. This information was used without any sanitization, allowing an attacker to send crafted links containing anything, including javascript code, which could be loaded and executed in a few pages. Replacing this value with `scriptname` variable fixes the issue, since this variable contains the name of the file currently being executed. This information cannot be externally manipulated and it is safe to be used on the page. Signed-off-by: RD WebDesign <[email protected]>
1 parent da80339 commit 8c0f785

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

error403.lp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
mg.include('scripts/lua/header.lp','r')
1111
?>
1212
</head>
13-
<body class="hold-transition layout-boxed login-page page-<?=pihole.format_path(mg.request_info.request_uri)?>">
13+
<body class="hold-transition layout-boxed login-page page-<?=pihole.format_path(scriptname)?>">
1414
<div class="box login-box">
1515
<section style="padding: 15px;">
1616
<h2 class="error-headline text-danger">403</h2>

error404.lp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
mg.include('scripts/lua/header.lp','r')
1111
?>
1212
</head>
13-
<body class="hold-transition layout-boxed login-page page-<?=pihole.format_path(mg.request_info.request_uri)?>">
13+
<body class="hold-transition layout-boxed login-page page-<?=pihole.format_path(scriptname)?>">
1414
<div class="box login-box">
1515
<section style="padding: 15px;">
1616
<h2 class="error-headline text-yellow">404</h2>

login.lp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
mg.include('scripts/lua/header.lp','r')
1111
?>
1212
</head>
13-
<body class="hold-transition layout-boxed login-page page-<?=pihole.format_path(mg.request_info.request_uri)?>" data-apiurl="<?=pihole.api_url()?>" data-webhome="<?=webhome?>">
13+
<body class="hold-transition layout-boxed login-page page-<?=pihole.format_path(scriptname)?>" data-apiurl="<?=pihole.api_url()?>" data-webhome="<?=webhome?>">
1414
<div class="box login-box" id="login-box">
1515
<section style="padding: 15px;">
1616
<div class="login-logo">

scripts/lua/header_authenticated.lp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mg.include('header.lp','r')
2424
<script src="<?=pihole.fileversion('vendor/waitMe-js/modernized-waitme-min.js')?>"></script>
2525
<script src="<?=pihole.fileversion('scripts/js/logout.js')?>"></script>
2626
</head>
27-
<body class="<?=theme.name?> hold-transition sidebar-mini <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in page-<?=pihole.format_path(mg.request_info.request_uri)?>" data-apiurl="<?=pihole.api_url()?>" data-webhome="<?=webhome?>">
27+
<body class="<?=theme.name?> hold-transition sidebar-mini <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in page-<?=pihole.format_path(scriptname)?>" data-apiurl="<?=pihole.api_url()?>" data-webhome="<?=webhome?>">
2828
<noscript>
2929
<!-- JS Warning -->
3030
<div>

0 commit comments

Comments
 (0)