Koha-clms/Koha/BackgroundJob
Tomas Cohen Arazi 443c067d30
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: Jesse Maseto <jesse@bywatersolutions.com>
2025-08-28 12:02:40 -04:00
..
BatchCancelHold.pm Bug 30943: Simplify background jobs code using helpers 2023-03-13 15:52:19 -03:00
BatchDeleteAuthority.pm Bug 30943: Simplify background jobs code using helpers 2023-03-13 15:52:19 -03:00
BatchDeleteBiblio.pm Bug 27893: Optionally skip biblio with open orders in batch delete 2024-04-19 18:06:32 +02:00
BatchDeleteItem.pm Bug 30943: Simplify background jobs code using helpers 2023-03-13 15:52:19 -03:00
BatchUpdateAuthority.pm Bug 30943: Simplify background jobs code using helpers 2023-03-13 15:52:19 -03:00
BatchUpdateBiblio.pm Bug 30943: Simplify background jobs code using helpers 2023-03-13 15:52:19 -03:00
BatchUpdateBiblioHoldsQueue.pm Bug 35979: (follow-up) Add check in ->enqueue 2024-04-26 08:52:54 +02:00
BatchUpdateItem.pm Bug 35843: Correct invalid exception 2024-01-26 15:13:47 +01:00
CreateEHoldingsFromBiblios.pm Bug 34789: Update usage throughout Koha modules and Vue components 2023-09-18 12:06:18 -03:00
ErmSushiHarvester.pm Revert "Bug 38782: Remove concat in background process" 2025-05-21 13:43:54 +12:00
ImportKBARTFile.pm Bug 40579: Fix CSV formula injection vulnerabilities 2025-08-28 12:02:40 -04:00
MARCImportCommitBatch.pm Bug 35438: Remove skip_intermediate_commit parameter 2024-01-16 12:06:08 +01:00
MARCImportRevertBatch.pm Bug 32394: Restore long tasks queue 2022-12-14 14:32:27 -03:00
PseudonymizeStatistic.pm Bug 35277: (QA follow-up) POD corrections 2024-01-16 12:06:07 +01:00
StageMARCForImport.pm Bug 37403: Wrong progress quantity in job details 2024-11-19 15:43:39 +00:00
UpdateElasticIndex.pm Bug 33576: (QA follow-up) Polish comment, typo 2023-05-09 10:58:06 -03:00