Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent CSV and XLS injection in Writers #429

Open
timwentzell opened this issue Jan 6, 2021 · 1 comment
Open

Prevent CSV and XLS injection in Writers #429

timwentzell opened this issue Jan 6, 2021 · 1 comment

Comments

@timwentzell
Copy link

timwentzell commented Jan 6, 2021

Feature Request

The export functionality of this bundle allows users to download data in a .csv or .xls file suitable for handling in spreadsheet applications like Microsoft Excel and OpenOffice Calc. The resulting spreadsheet's cells often contain input from untrusted sources such as survey responses, transaction details, and user-supplied content. This is inherently risky, because any cells starting with certain special characters will be interpreted by the spreadsheet software as formulas which can be used to execute payloads. These payloads can compromise a user's system by downloading and running malware as well as giving command line access to a compromised system.

If exported data cells were to contain payloads such as =cmd|' /C calc'!A0 in a CSV or XLS file generated by the this bundle, this payload becomes embedded within that file and will attempt to run upon being opened (mainly on Windows systems). The payload in this example will open the Windows calculator should a user open the file and accept two prompts (unfortunately many users would do this without questioning it).

See https://owasp.org/www-community/attacks/CSV_Injection for more.

Attempting to sanitize data for this specific purpose upon input would be cumbersome as it may come from various input sources. I suggest doing a simple regex filter within the Writer methods for both file formats. I currently have this implemented in another project that is using sonata-project/exporter:^1.11 by overriding the write(array $data) method in each Writer class - however in sonata-project/exporter:^2.0 these Writer classes are now marked as final - so I figure the best solution is to propose this as a security feature update to the Sonata Exporter bundle so we can all benefit from it.

timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
timwentzell pushed a commit to timwentzell/exporter that referenced this issue Jan 6, 2021
@github-actions
Copy link

github-actions bot commented Jul 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants