Koha-clms/Koha/ERM
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
..
Agreement Bug 32030: Add users to licenses - Preparation 2022-11-08 09:44:47 -03:00
EHoldings Bug 37577: Add additional fields for ERM packages 2024-11-08 16:09:19 +01:00
EUsage Bug 40579: Fix CSV formula injection vulnerabilities 2025-09-02 16:34:19 +01:00
Providers Bug 38177: Do not use stash to retrieve parameters 2024-10-23 19:14:51 +02:00
Agreement.pm Bug 37576: Add additional fields for ERM agreements 2024-11-08 16:09:17 +01:00
Agreements.pm Bug 37576: Add additional fields for ERM agreements 2024-11-08 16:09:17 +01:00
Document.pm Bug 36627: Fix typo "embeded" 2025-03-19 23:57:21 +01:00
Documents.pm Bug 32030: Max document file size - server-side validation 2022-11-08 09:44:45 -03:00
License.pm Bug 35287: Preparation: AdditionalFields License Mixin 2024-10-24 13:38:18 +02:00
Licenses.pm Bug 35287: (Follow-up 37389): ExtendedAttributes 2024-10-24 13:38:21 +02:00
UserRole.pm Bug 32030: Add users to licenses - Preparation 2022-11-08 09:44:47 -03:00
UserRoles.pm Bug 32030: Add users to licenses - Preparation 2022-11-08 09:44:47 -03:00