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

CSV Injection Vulnerability #5465

Closed
muffyhub opened this issue Oct 24, 2020 · 7 comments
Closed

CSV Injection Vulnerability #5465

muffyhub opened this issue Oct 24, 2020 · 7 comments

Comments

@muffyhub
Copy link

muffyhub commented Oct 24, 2020

Vulnerability Name: CSV Injection/ Formula Injection
Severity: High
Description: CSV Injection (aka Excel Macro Injection or Formula Injection) exists in List Event Types feature in ChurchCRM v4.2.0 via Name field that is mistreated while exporting to a CSV file.
Impact: Arbitrary formulas can be injected into CSV files which can lead to remote code execution at the client or data leakage via maliciously injected hyper-links.
Version Affected: 4.2.0
Payload Used: =10+20+cmd|' /C calc'!A0
Vulnerable URL: master/EventNames.php
Vulnerable Parameters: Name
Steps to Reproduce:

  1. Login to the application, goto 'Events' module and then "List Event Types"
  2. Edit any event and inject the payload =10+20+cmd|' /C calc'!A0 in the 'Name' field
  3. Now goto 'List Event types' module and click CSV to download the CSV file
  4. Open the CSV file, allow all popups and our payload is executed (calculator is opened).
    2020-10-24 10_28_13-
    2020-10-24 10_28_50-ChurchCRM Edit Event Types (4) csv - Excel

Note: Incase the payload does not execute, then enable 'External Content' and 'Macro' settings in Excel. Goto Excel > File > Options > Trust Center > Trust Center Settings > Macro/External Content.
References:
https://nvd.nist.gov/vuln/detail/CVE-2019-12134
http://cwe.mitre.org/data/definitions/1236.html

@DawoudIO
Copy link
Contributor

DawoudIO commented Oct 24, 2020

Just to confirm, this is not an issue with our CSV import but if a row had bad data the exported CVS has an issue. We use https://datatables.net/ if you have a chance, maybe you can help see if they have fixed that.

@muffyhub
Copy link
Author

@DawoudIO I think the problem lies in the export feature. It would be nice to have an option in download csv to escape strings that begin with "+","-","@", or "=" by prepending "\t".
For any cell that begins with one of the formula triggering characters =, -, +, or @, you should directly prefix it with a tab character.

@MrClever
Copy link
Collaborator

I'm not seeing how this is a particularly useful bug report. Anyone can create a CSV file with any arbitrary text in it using any text editor or text generation tool. How using ChurchCRM to generate a CSV with questionable content is a "bug" leaves me perplexed. For example, this logic implies the bash echo command has this same "bug" too:

echo -e "Header 1, Header 2, Header 3\n1,=10+20+cmd|' /C calc'!A0,Foo bar\n2,Hello world,Text text" > test.csv

If there was a method to use unauthenticated access to ChurchCRM that allowed insertion of arbitrary data values AND generate a CSV AND somehow send that somewhere then maybe I'd consider this a flaw in ChurchCRM. Maybe I'm missing something?

@muffyhub
Copy link
Author

muffyhub commented Oct 29, 2020

I understand that this vulnerability would be much impactful if any unauthenticated user would be able to inject the payload resulting into code execution on the internal user's system. However this could also be impactful, if any internal user of the application enters the payload which results into impacting all the other user of the application. Here the payload is entered on ChurchCRM application leaving the application at fault to generate a file which can execute malicious commands on the user's system. A user may embed Dynamic Data Exchange (DDE) formulas to perform code execution, download a backdoor, open a malicious website etc.
The legitimate user may download the file because of following reasons:

  1. The user trusts the site that the content is coming from.
  2. The user assumes that it is only a csv file and that it won't contain functions or macro's and won't care about any warnings from Excel about potential malicious functionality in the file.

https://owasp.org/www-community/attacks/CSV_Injection#:~:text=CSV%20Injection%2C%20also%20known%20as,the%20software%20as%20a%20formula.
https://payatu.com/csv-injection-basic-to-exploit

@MrClever
Copy link
Collaborator

Feel free to create a PR.

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Dec 24, 2023
Copy link
Contributor

github-actions bot commented Jan 8, 2024

This issue was closed because it has been stalled for 15 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants