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 Injection #210

Merged
merged 5 commits into from Dec 16, 2021
Merged

Prevent CSV Injection #210

merged 5 commits into from Dec 16, 2021

Conversation

johnnyoshika
Copy link
Contributor

Background Information

I have...

  • added at least one test to verify the failure condition is fixed.
  • verified the tests are passing.

Changes

Adds preventCsvInjection option to json2csv() that left trims the following characters to prevent CSV injection:

  • Equals (=)
  • Plus (+)
  • Minus (-)
  • At (@)
  • Tab (0x09)
  • Carriage return (0x0D)

CSV Injection remediation technique: https://owasp.org/www-community/attacks/CSV_Injection

@johnnyoshika
Copy link
Contributor Author

Looks like the build failed due to indentation problems. Will fix.

@coveralls
Copy link

coveralls commented Nov 26, 2021

Coverage Status

Coverage decreased (-0.2%) to 98.039% when pulling 91ef353 on examind-ai:csv-injection into b7615ce on mrodrig:stable.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 98.039% when pulling 616cc87 on examind-ai:csv-injection into b7615ce on mrodrig:stable.

@mrodrig
Copy link
Owner

mrodrig commented Dec 16, 2021

Thanks for reporting this and for the pull request @johnnyoshika! This looks great and is an excellent option to have. Given that this provides important security protections, I think this would be a good option to have enabled by default in a future major release (eg. 4.0.0). I'll get this merged in and released out to NPM along with the latest npm audit fixes.

Thanks again!

@mrodrig mrodrig merged commit 1d7a947 into mrodrig:stable Dec 16, 2021
@johnnyoshika
Copy link
Contributor Author

@mrodrig Thank you for this great library and thank you for the merge. I would caution against enabling preventCsvInjection by default, as it changes the content of the CSV and could be an unexpected behavior of this library. I was hoping there would be a way to prevent CSV injection without impacting the content, but sadly there doesn't seem to be a way. Because of that, I think preventCsvInjection should be opt-in, but you would be the best judge of that.

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

Successfully merging this pull request may close these issues.

None yet

3 participants