Bug 42800: Fix XSS in shelf list in the ERM module

const logged_in_user_lists = [% To.json(logged_in_user.virtualshelves.unblessed) | $raw %];

If you have a script tag in a list name the UI will be broken, and there
is potentially a XSS vulnerability

Test plan:
Create a new list with name="<script>alert("booh!");</script>"
Go to /cgi-bin/koha/erm/eholdings/local/titles/import
or any ERM views
=> Without this patch the UI is broken
=> With this patch applied it's not and the table is correctly populated
with the lists

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
This commit is contained in:
Jonathan Druart 2026-06-09 11:19:35 +02:00 committed by Wainui Witika-Park
parent 133ca5e4a5
commit cabee467b8
No known key found for this signature in database
GPG Key ID: 2D0A6AB5DAF1B78D
2 changed files with 12 additions and 6 deletions

View File

@ -41,7 +41,15 @@
const max_allowed_packet = [% To.json(max_allowed_packet) | $raw %];
const logged_in_user_lists = [% To.json(logged_in_user.virtualshelves.unblessed) | $raw %];
let logged_in_user_lists = [];
[% FOR shelf IN logged_in_user.virtualshelves %]
logged_in_user_lists.push(
{
id: "[% shelf.shelfnumber | html %]",
name: "[% shelf.shelfname | html %]",
}
);
[% END %]
const logged_in_user = [% To.json(logged_in_user.unblessed) | $raw %];
</script>

View File

@ -89,14 +89,12 @@ export default {
columns: [
{
title: __("Name"),
data: "shelfname",
data: "name",
searchable: true,
orderable: true,
width: "100%",
render: function (data, type, row, meta) {
return (
row.shelfname + " (#" + row.shelfnumber + ")"
);
return row.name + " (#" + row.id + ")";
},
},
{
@ -114,7 +112,7 @@ export default {
$.each($(this).find("td .actions"), function (index, e) {
let tr = $(this).parent().parent();
let list_id = api.row(tr).data().shelfnumber;
let list_id = api.row(tr).data().id;
let importButton = createVNode(
"a",
{