Koha-clms/Koha/ERM/EUsage
Tomas Cohen Arazi 51d7c30247
Bug 40579: Fix CSV formula injection vulnerabilities
This patch addresses CSV formula injection vulnerabilities by ensuring
all Text::CSV instances use formula protection.

Changes made:
* Add formula => 'empty' to all Text::CSV constructors in:
  - Koha::Patrons::Import
  - Koha::BackgroundJob::ImportKBARTFile
  - Koha::ERM::EUsage::CounterFile

The 'empty' formula mode causes potentially dangerous formulas (starting
with =, +, -, @) to be treated as empty strings rather than executed,
preventing CSV injection attacks while maintaining data integrity.

Security impact:
* Prevents execution of malicious formulas in CSV imports
* Protects against data exfiltration via CSV formula injection
* Maintains backward compatibility for legitimate CSV data

To test:
1. Apply the previous patch (author test)
2. Run:
   $ ktd --shell
  k$ prove xt/author/Text_CSV_Various.t
=> FAIL: Should show 3 files without formula protection
3. Apply this patch
4. Repeat 2
=> SUCCESS: All tests should now pass
5. Try importing CSV with formula content (=cmd|"/c calc",test,data)
=> SUCCESS: Formula content is rejected/emptied, not executed
6. Import normal CSV data
=> SUCCESS: Normal data imports correctly
7. Sign off :-D

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
2025-09-02 16:34:19 +01:00
..
CounterFile.pm Bug 40579: Fix CSV formula injection vulnerabilities 2025-09-02 16:34:19 +01:00
CounterFiles.pm
…
CounterLog.pm Bug 36627: (QA follow-up): Rename borrowernumber -> patron_id 2025-03-19 23:57:22 +01:00
CounterLogs.pm
…
DefaultUsageReport.pm
…
DefaultUsageReports.pm
…
MonthlyUsage.pm
…
MonthlyUsages.pm
…
SushiCounter.pm Bug 33339: (Follow up) Fix more cases of formula=empty 2024-11-14 10:46:31 +01:00
UsageDataProvider.pm Bug 39823: Identify error messages based on code 2025-06-19 09:39:14 +02:00
UsageDataProviders.pm
…
UsageDatabase.pm
…
UsageDatabases.pm
…
UsageItem.pm
…
UsageItems.pm
…
UsagePlatform.pm
…
UsagePlatforms.pm
…
UsageTitle.pm
…
UsageTitles.pm
…
YearlyUsage.pm
…
YearlyUsages.pm
…