Koha-clms/Koha/ERM/EUsage
Tomas Cohen Arazi 8b494a3789
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>
2025-08-26 21:05:14 +02:00
..
CounterFile.pm Bug 40579: Fix CSV formula injection vulnerabilities 2025-08-26 21:05:14 +02:00
CounterFiles.pm
…
CounterLog.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
CounterLogs.pm
…
DefaultUsageReport.pm
…
DefaultUsageReports.pm
…
MonthlyUsage.pm
…
MonthlyUsages.pm
…
SushiCounter.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
UsageDataProvider.pm Bug 39823: Identify error messages based on code 2025-06-17 21:43:00 +02:00
UsageDataProviders.pm
…
UsageDatabase.pm
…
UsageDatabases.pm
…
UsageItem.pm
…
UsageItems.pm
…
UsagePlatform.pm
…
UsagePlatforms.pm
…
UsageTitle.pm
…
UsageTitles.pm
…
YearlyUsage.pm
…
YearlyUsages.pm
…