themes: Call striptags() on hostname to prevent XSS
authorHauke Mehrtens <hauke@hauke-m.de>
Tue, 8 Jun 2021 23:28:44 +0000 (01:28 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Wed, 9 Jun 2021 19:07:45 +0000 (21:07 +0200)
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>
(cherry picked from commit 5cbd79d7e31c0f0feaea2770bf102bbae7831e3c)

themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm
themes/luci-theme-material/luasrc/view/themes/material/header.htm
themes/luci-theme-openwrt/luasrc/view/themes/openwrt.org/header.htm

index 5e3687935b9170b42ef8b2edb2565acb28ca6544..99ffc210748fb872aab2976938db795f880e9446 100644 (file)
@@ -41,7 +41,7 @@
                <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>
index 5abfb481b66c142f818857ef94f2b1d85db5f808..d6e50c40cd73a4136c44130ab6d02256c2e00f09 100644 (file)
                <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>
index fafd86f35e483b8f5faae6f49d99e26bba90afef..77c86596fcae65efe0eaac2be1e8b38ea5ac2270 100644 (file)
@@ -50,7 +50,7 @@
 <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>