This calls striptags() on the hostname to prevent any XSS over the
hostname. This should fix CVE-2021-33425 as far as I understood it.
If someone adds some Javascript into system.@system[0].hostname it would
have been directly added to the page, this prevents the problem.
This can only be exploited by someone being able to modify the uci
configuration, normally a user with such privileges could also just
modify the webpage.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
<header>
<div class="fill">
<div class="container">
- <a class="brand" href="/"><%=boardinfo.hostname or "?"%></a>
+ <a class="brand" href="/"><%=striptags(boardinfo.hostname or "?")%></a>
<ul class="nav" id="topmenu" style="display:none"></ul>
<div id="indicators" class="pull-right"></div>
</div>
<div class="container">
<span class="showSide"></span>
<a id="logo" href="<% if luci.dispatcher.context.authsession then %><%=url('admin/status/overview')%><% else %>#<% end %>"><img src="<%=media%>/brand.png" alt="OpenWrt"></a>
- <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
+ <a class="brand" href="#"><%=striptags(boardinfo.hostname or "?")%></a>
<div class="status" id="indicators">
<span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
<span class="label success" id="xhr_poll_status_on"><span class="mobile-hide"><%:Auto Refresh%></span> <%:on%></span>
<div id="menubar">
<h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
- <span class="hostname"><a href="/"><%=(boardinfo.hostname or "?")%></a></span>
+ <span class="hostname"><a href="/"><%=striptags(boardinfo.hostname or "?")%></a></span>
<span class="distversion"><%=ver.distversion%></span>
<span id="indicators"></span>
</div>
<h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
<div class="hostinfo">
- <%=(boardinfo.hostname or "?")%> | <%=ver.distversion%> |
+ <%=striptags(boardinfo.hostname or "?")%> | <%=ver.distversion%> |
<%:Load%>: <%="%.2f" % (loadinfo[1] / 65535.0)%> <%="%.2f" % (loadinfo[2] / 65535.0)%> <%="%.2f" % (loadinfo[3] / 65535.0)%>
</div>