Bug 24412: (follow-up) prevent js injection
authorNicolas Legrand <nicolas.legrand@bulac.fr>
Thu, 5 Nov 2020 13:52:02 +0000 (14:52 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 6 Nov 2020 14:55:17 +0000 (15:55 +0100)
Some js variables are not properly escaped and can be executed if
containing javascript.

1. have some waiting reserve attached to a desk
2. change this desk name to : <script>alert("❤");</script>
3. go to user's checkout page (circulation.pl) and click on the
Hold(s) tab
4. you should see some popup with a ❤ in it.
5. apply patch and refresh page
6. now you should see the desk name printed properly in the page:
<script>alert("❤");</script>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/js/holds.js

index be94430..29a0489 100644 (file)
@@ -162,13 +162,13 @@ $(document).ready(function() {
                                     if ( oObj.waiting_here ) {
                                         data += __("Item is <strong>waiting here</strong>");
                                         if (oObj.desk_name) {
-                                            data += ", " + __("at %s").format(oObj.desk_name);
+                                            data += ", " + __("at %s").format(oObj.desk_name.escapeHtml());
                                         }
                                     } else {
                                         data += __("Item is <strong>waiting</strong>");
                                         data += " " + __("at %s").format(oObj.waiting_at);
                                         if (oObj.desk_name) {
-                                            data += ", " + __("at %s").format(oObj.desk_name);
+                                            data += ", " + __("at %s").format(oObj.desk_name.escapeHtml());
                                         }
 
                                     }