Repository navigation
Description
CSV formula injection in list CSV exports
A Self-Service portal user can give a ticket a title that, once a technician exports the ticket list to CSV and opens it in a spreadsheet application, runs as a formula on that technician's workstation.
| Severity | 2.0 — Low (CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N) — confirmed by PoC |
| Attacker | any account (Self-Service) |
| Exploitation | moderate — the victim must export, open, accept the warnings |
| Prerequisites | spreadsheet evaluating CSV formulas; real impact limited by its protections |
| Components | CSV export of lists, history, planning, HL API (CSV) |
Affected versions
| Branch | Version | Affected | Verification |
|---|---|---|---|
| 10.0/bugfixes | 10.0.x | yes | Theoretical |
| 11.0/bugfixes | 11.0.x | yes | Theoretical |
| 12.0/bugfixes | 12.0.x | yes | Tested |
| main | x-dev | yes | Theoretical |
⚠️ Verification status — "Tested" means the PoC was actually
run on this branch, result observed. "Theoretical" means the
conclusion comes from reading the code only: it has not been proven and
may be wrong. Do not treat a Theoretical line as an established fact
before running the PoC.
12.0 tested on the current 12.0 code: the title cell comes out as "=CONCATENATE(""POC-CSV-INJECTION-"",2+5)". 11.0 and main: same export code (binder only, no formula escaping); 10.0: Search::csv_clean() only handles double quotes, CsvResponse (League\Csv) without EscapeFormula.
Summary
A Self-Service user can give a ticket a title that, once a technician exports the ticket list to CSV and opens the file in a spreadsheet application, runs as a formula on the technician's workstation. Any value an attacker can write into a field shown in a CSV export (ticket title, asset name, followup, own display name…) is emitted unchanged when it starts with =, +, - or @; the code then runs in the operator's spreadsheet application (Excel, LibreOffice), not in GLPI.
Details
Mechanism
Spreadsheet applications treat a CSV cell starting with =, +, - or @ as a formula. GLPI never neutralises these leading characters when generating CSV text.
- Search exports install
SpreadsheetValueBinder(added in 11.0.7, commit 823ca49), which only changes the PhpSpreadsheet cell type from formula to string. That protects XLSX/ODS, where the type is stored in the file, but CSV is plain text: the writer outputs the raw=…value. Glpi\Csv\CsvResponse(history, planning, impact, printer logs, graph exports) binds values with PhpSpreadsheet's default binder, so a value starting with=is a formula that the CSV writer evaluates on the server before writing. A formula whose result is itself a formula string (="=HYPERLINK(…)") produces a live formula in the CSV, and+,-,@are passed through as is.- The HL API CSV formatter (
Accept: text/csv) quotes values but does not neutralise them either.
Entry points
src/Glpi/Search/Output/Spreadsheet.php:78— binder only, no CSV escapingsrc/Glpi/Search/Output/Csv.php:43— PhpSpreadsheet CSV writer of search exportssrc/Glpi/Csv/CsvResponse.php:59— default binder, formulas evaluated then writtensrc/Glpi/Api/HL/Middleware/ResultFormatterMiddleware.php:69—formatCSV(), quoting onlyfront/report.dynamic.php(display_type=3) — list export used by the PoC
Scope
- Same defect on every CSV producer: search exports (all itemtypes,
report.dynamic.phpand the HL API report export),CsvResponsecallers (front/log/export.php,front/planningcsv.php,front/impactcsv.php,front/printerlogcsv.php,front/graph.send.php) and the HL APIAccept: text/csvformatter. - XLSX/ODS search exports are not affected: the binder stores the value as a string cell.
- Server-side evaluation in
CsvResponsewas checked:WEBSERVICE()is blocked by PhpSpreadsheet's empty domain whitelist, so no SSRF; it only enables the second-order payload above. - Real impact depends on the client: modern Excel disables DDE by default and warns on external links; LibreOffice asks whether to evaluate formulas on CSV import. A
=HYPERLINK()that sends other cells of the export to an attacker URL on click remains the realistic case.
Remediation leads
- Root fix, one helper for all CSV producers: add a
DataExporthelper that prefixes with'any string whose first character is=,+,-,@, tab or CR, and call it inSearch\Output\Csv(per cell, CSV only),CsvResponse::output()(and set every cell as an explicit string so nothing is evaluated server side) andResultFormatterMiddleware::formatCSV(). Risk: negative numbers and phone numbers (+33…) exported as text; limit the prefix to non-numeric strings. - 10.0:
Search::csv_clean()andGlpi\Csv\CsvResponse(League\Csv) need the same prefix; League\Csv offersEscapeFormulaas a formatter. - Quick workaround: none on the GLPI side; operators can export to XLSX/ODS, which are unaffected.
Proof of concept
The attacker is a Self-Service account (lowest stock profile) on the root entity; the victim is a Technician who exports the ticket list. prepare.php --apply only creates these two accounts. poc.sh logs in as the attacker, opens a ticket titled =CONCATENATE("POC-CSV-INJECTION-",2+5) and a control ticket, logs in as the technician, exports the ticket list to CSV and checks that the title cell starts with =. Opening that file in Excel or LibreOffice (formula evaluation on) shows POC-CSV-INJECTION-7. --revert purges both accounts and the PoC tickets.
Commands
docker compose exec -T app php .security/poc/prepare.php --apply
ATTACKER=poc_csvinj_attacker OPERATOR=poc_csvinj_operator POC_PASSWORD='Poc-Test99!' BASE_URL=http://localhost:8072 ./.security/poc/poc.sh
docker compose exec -T app php .security/poc/prepare.php --revert
Attachments
Impact
CSV injection (CWE-1236). Any authenticated user who can write a value shown in an exported list, including Self-Service users, can plant it. The victim is the operator (technician, administrator) who exports the list and opens it in a spreadsheet application; GLPI itself is not compromised. Consequences range from misleading content and phishing links to leaking other rows of the export via =HYPERLINK() after a click; command execution through DDE requires a client where DDE is enabled, which is not the default in current Excel. Exploitation needs the victim to export, open the file and accept the application's warnings.
Affected products
- Ecosystem: Other — Package name: glpi
- Affected versions: >= 10.0.0, < 11.0.0
- Ecosystem: Other — Package name: glpi
- Affected versions: >= 11.0.0, < 12.0.0
- Ecosystem: Other — Package name: glpi
- Affected versions: >= 12.0.0
Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
2.0 — Low
Weaknesses
CWE-1236: Improper Neutralization of Formula Elements in a CSV File
Reported by @DuckStewie.
Activity