Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] Fix security issue on CsvEncoder about CSV injection#24508
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Serializer] Fix security issue on CsvEncoder about CSV injection#24508
Uh oh!
There was an error while loading.Please reload this page.
Conversation
0cfa2ac tobaf31e5Comparesroze commentedOct 10, 2017
Great initiative 👍 I'd target 3.4. |
javiereguiluz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In addition to prefixing a\t to problematic values, another solution proposed in the comments of the article is to prefix a= before the"..." because that forces Excel to interpret the value as text. Not sure if it's really better.
Uh oh!
There was an error while loading.Please reload this page.
6d7dc03 toe254fcbComparesrc/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
welcoMattic commentedOct 11, 2017
527dc6a tofc743a1Comparechalasr commentedOct 11, 2017
@welcoMattic Nope, that would create merge conflicts when merging lower branches up to master. Thanks. |
xabbuh commentedOct 11, 2017
Should we also allow to pass this option through the context so that you do not necessary have to configure this option globally? |
welcoMattic commentedOct 11, 2017
@xabbuh why not. We should also make the context |
chalasr commentedOct 11, 2017
👍 to allow overriding this option in the context. |
09a5ed5 to9c0733dComparewelcoMattic commentedOct 11, 2017
dunglas commentedOct 12, 2017
Great! But as stated in the article, it's definitely not a security issue on our side. The current implementation respects the RFC (Excel and Google Sheets don't), and most software consuming CSV expect the current behavior. |
welcoMattic commentedOct 12, 2017
Thanks@dunglas! For documentation, should I create a new page underSerializer section? Named CsvEncoder, and where I explain why this options exists? |
ostrolucky commentedOct 16, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Alternative approach might be to just add a normalizer. That would help with deserialization of such sanitized csvs too and doesn't pollute __construct arguments. I don't like having this in core anyway though, as it's security issue in Excel and Google sheets only and this is destructive kind of escaping |
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedDec 1, 2017
Not sure if we need to support that in core. /cc @symfony/mergers |
Tobion commentedDec 10, 2017
👍 to include that as it's security feature that people should be aware about. |
dbu left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
i think in 95% of the use cases, the serializer will be used to export data, which might include user provided input.
there is only a problem if this component is used to generate sheets with formula. i would add an explaination in the phpdoc to explain what this flag is about and say to set it to true when you don't intend to have formula in the csv you generate.
i am no merger, but +1 on this. it is a relevant security topic and obviously excel/libreoffice/google and whoever else is affected decided they rather not properly fix it, so its up to generators of csv files to ensure security.
i think this should be against 3.3 as that is the branch for security fixes.
dunglas commentedDec 20, 2017
👍 to support this feature too. But as it's definitely not a security fix (on our side), it's a new feature that should be merged in 4.1.
There is also a problem when the value start with |
welcoMattic commentedDec 20, 2017
dbu commentedDec 20, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
i'd update the changelog and phpdoc as that will be relevant either way. i hope one of the maintainers can decide which version this should go. i can see the point of kevin, and its a good reason why its not on by default. but i feel it still is security relevant, even if its not a bug of symfony, but symfony helping around lax security of other tools - and as such should go into 3.3 or 3.4. |
dunglas commentedJan 11, 2018
I think that you can update and rebase the PR@welcoMattic |
Uh oh!
There was an error while loading.Please reload this page.
welcoMattic commentedFeb 4, 2018
@nicolas-grekas Done, I also fix@ostrolucky's comment. |
nicolas-grekas commentedFeb 4, 2018
@welcoMattic thanks. Can you rebase to get rid of the merge commit? I invite you to squash while doing so. |
b98b9ab to414a61dCompare| private$formulasStartCharacters =array('=','-','+','@'); | ||
| publicfunction__construct(string$delimiter =',',string$enclosure ='"',string$escapeChar ='\\',string$keySeparator ='.') | ||
| publicfunction__construct(string$delimiter =',',string$enclosure ='"',string$escapeChar ='\\',string$keySeparator ='.',$escapeFormulas =false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
missing bool type declaration for the new argument
Uh oh!
There was an error while loading.Please reload this page.
414a61d toa1b0bdbComparewelcoMattic commentedFeb 6, 2018
Thanks for review@Tobion 👍 |
fabpot commentedFeb 7, 2018
Thank you@welcoMattic. |
…V injection (welcoMattic)This PR was merged into the 4.1-dev branch.Discussion----------[Serializer] Fix security issue on CsvEncoder about CSV injection| Q | A| ------------- | ---| Branch? | master (4.1)| Bug fix? | no| New feature? | yes| BC breaks? | yes| Deprecations? | no| Tests pass? | yes| License | MITI read [this article](http://georgemauer.net/2017/10/07/csv-injection.html) about CSV injection and I thought it best to update the `CsvEncoder` so that it does not generate potentially malicious CSV files by default.Commits-------a1b0bdb Fix security issue on CsvEncoder
Uh oh!
There was an error while loading.Please reload this page.
I readthis article about CSV injection and I thought it best to update the
CsvEncoderso that it does not generate potentially malicious CSV files by default.