Koha-clms/Koha/BackgroundJob
Tomas Cohen Arazi ca8ef54949
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: Lucas Gass <lucas@bywatersolutions.com>
2025-08-29 10:43:39 -06:00
..
BatchCancelHold.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
BatchDeleteAuthority.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
BatchDeleteBiblio.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
BatchDeleteItem.pm Bug 37115: Batch delete linked serials 2025-08-01 13:22:53 -06:00
BatchUpdateAuthority.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
BatchUpdateBiblio.pm Bug 26869: Use the default framework 2025-03-17 11:59:50 +01:00
BatchUpdateBiblioHoldsQueue.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
BatchUpdateItem.pm Bug 23010: Report on count of items not modified via batchMod 2025-06-24 16:10:20 -06:00
CreateEHoldingsFromBiblios.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ErmSushiHarvester.pm Bug 38782: Remove concat in background process 2024-12-27 15:19:07 +01:00
ImportKBARTFile.pm Bug 40579: Fix CSV formula injection vulnerabilities 2025-08-29 10:43:39 -06:00
MARCImportCommitBatch.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
MARCImportRevertBatch.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
PseudonymizeStatistic.pm Bug 39652: Rename new_from_statistic 2025-04-24 19:53:17 +02:00
StageMARCForImport.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
UpdateElasticIndex.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00