Koha-clms/reports
Sanjar Tulkinov Anvar o'g'li 074e0b7261
Bug 42736: Prevent SQL injection in reports/cat_issues_top.pl
The "Most-circulated items" report built its SQL by concatenating the
Criteria and Filter request parameters directly into the query, with no
bind placeholders and no whitelist on the Criteria identifier. An
authenticated staff user with the reports permission could inject
arbitrary SQL and read any data reachable by the Koha database user.

This validates the Criteria parameter against a fixed allow-list of the
report's own column options (matching reports/cat_issues_top.tt) so it
is safe to use as a SQL identifier, and binds every Filter value with a
placeholder in both the column-header query and the main calculation
query. The Limit parameter is validated as a plain integer.

This mirrors the fix already applied to the sibling
reports/bor_issues_top.pl (bug 42369).

Test plan:
0. Apply the patch
1. koha-plack --restart kohadev
2. Go to Reports > Most-circulated items (reports/cat_issues_top.pl)
3. Run the report with various Criteria and Filter values, confirm the
   output is correct and no errors appear
4. Before the patch, a Filter value or the Criteria containing SQL (a
   single quote followed by a subquery) broke out of the query. After
   the patch, confirm such input is treated as a literal value: you get
   normal output or an empty result, with no SQL error, no delay, and no
   data leak

Signed-off-by: Sanjar Tulkinov Anvar o'g'li <sanjarbiy11@gmail.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Aleisha Amohia <aleisha@catalyst.net.nz>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-08-26 09:23:29 +00:00
..
acquisitions_stats.pl Bug 42360: Move separator validation to C4::Context::csv_delimiter 2026-07-13 15:46:31 +00:00
bor_issues_top.pl Bug 42369: Use C4::Context::csv_delimiter for delimiter validation 2026-07-13 15:46:37 +00:00
borrowers_out.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
borrowers_stats.pl Bug 40287: Fix untranslatable strings in more statistics wizards 2025-12-17 13:24:31 -07:00
cash_register_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
cat_issues_top.pl Bug 42736: Prevent SQL injection in reports/cat_issues_top.pl 2026-08-26 09:23:29 +00:00
catalog_by_itemtype.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
catalogue_out.pl Bug 42803: Only perform the lookups when !$filter is true 2026-06-19 15:39:00 +00:00
catalogue_stats.pl Bug 42363: Use C4::Context::csv_delimiter for delimiter validation 2026-07-13 15:46:33 +00:00
dictionary.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
guided_reports.pl Bug 16631: Bring back template. Fix test syntax. 2026-07-28 14:32:27 +00:00
issues_avg_stats.pl Bug 42368: Use C4::Context::csv_delimiter for delimiter validation 2026-07-13 15:46:35 +00:00
issues_stats.pl Bug 42735: Fix SQL injection 2026-07-13 15:46:38 +00:00
itemslost.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
orders_by_fund.pl Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
reports-home.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
reserves_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
serials_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00