-
-
Notifications
You must be signed in to change notification settings - Fork 699
new requirement for Formula Injection #1469
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
Comments
Nope, we don't have separate requirement for that. But we should have one :) |
(edited)
Formula Injection may work also in xls, xlsx, odf, Google Spreadsheet etc. CWE-1236: Improper Neutralization of Formula Elements in a CSV File |
2 linked problems that probably need to be solved together because the mitigation for formula injection requires the mitigation for CSV injection to also be applied in order to be effective. Suggest single new requirement |
Hi @RafaelGreen1, are you able to suggest a requirement wording for this new requirement? @set-reminder 3 weeks @tghosth to revisit |
⏰ Reminder
|
@elarlang, following your comment in the pull request, I submitted a commit to fix the reference label in 1.5.4. For your convenience, I put here the suggested wording: Verify that the application protects against CSV injection in generated (or exported) spreadsheet documents (such as csv, xls, xlsx, odf, Google Spreadsheet etc). Ensure that no cells begin with any of the following characters: ['=', '+', '-', '@', '\t', 'r']. Also, take care of the field separator (e.g., ‘,’, or ‘;’) and quotes (e.g., ', or "). | ✓ | ✓ | ✓ | 1236 |
Thanks, |
Yes, in general it would be nice to do that way - then there is readable discussion in related issue and arguments, why some change was made to the document. Discussion over PR's are hard to follow. But take it as note for the smoother life in the future :) Let's try to finalize the requirement text now and/or wait feedback from others. |
First part - csv injection:
Second part - formula injection
I left out Last part - what is it
|
@elarlang Here is the new suggestion (based on your comments): Verify that the application protects against CSV/Formula injection in generated spreadsheet documents
|
This proposal is a bit long. I use previously mentioned pieces and put this one as target to brainstorm and develop (language and grammar checks included) further: Verify that the application protects against CSV injection in generated spreadsheet documents (such as csv, xls, xlsx, odf) and verify that cell values are not executed as formula except intended by the application, e. g. values starting with special characters such as '=', '+', '-', '@' are properly escaped. |
LGTM |
ping @tghosth |
Sorry for the delay in response. I think the modifications below should provide the best protection. Note that \r will be covered by the RFC4180 escaping so I don't include it on the list of special characters. It also won't be a problem in non CSV formats. I do however include \00 as IIRC that character seems to be ignored meaning if \00 is the first character and = is the second character then it will still be evaluated as a formula...
@elarlang @RafaelGreen1 what do you think? |
I think requirement text should be understandable without opening any external resource, including RFC. This is the reason why have avoided references to external resources so far (I can see that we have now 14.5.6 added). Another problem with RFC - if there comes new version and obsoletes or updates referred RFC, then ASVS requirement is pointing to outdated version. On the other hand, RFC's are useful reading and we should think, if and how to cover them in ASVS in general. |
@elarlang problem is that the escaping rules for CSVs are too complicated to reproduce in full. Also seems unlikely that this RFC will significantly change in the near future. I think we have to accept that people are going to have to refer to external resources in order to actually apply fixes. As such, I stand by my wording above (reproduced below). Any other thoughts @elarlang / @jmanico?
|
Tried to find shorter version, ended up with longer one, but idea is:
Note - exporting files (from previous proposal) to generating content - the problem is when application generates certain content with certain formating rules, is the content exported to files, saved to database, served as inline content - does not matter. Should we also have matching requirement when an application imports csv, xlx, etc content to sanitize it and do not execute any formulas? |
@elarlang I hope you don't mind but I think your proposal which is basically one long sentence is a little hard to read. What do you think about:
I am not sure I am aware of specific attacks on import. |
@jmanico what do you think about this requirement:
|
Well done Josh and others, I like it. |
@RafaelGreen1 do you want to create a new pull request based on this?
|
"CSV/Formula" - |
Ok so let's change to:
|
Is that ok @elarlang? |
I'm ok with that. "Follow" and "Escape" sound like commands to the reader not "Verify that application follows" and "Verify that application escapes" |
Linking - wording got updated via #2811 |
Hi,
In V5.3 Output Encoding and Injection Prevention I would have expected to see something about formula injection.
For example, when a server of summer camps website genrates xlsx file with students' attendace data, last name of one the students could be something like "=HYPERLINK(url, student's last name)" or "=cmd|' /C...".
There are explanations about this attack here: CSV_Injection.
Does it appear elsewhere in the standard?
Thanks,
Rafael,
Edit: Thanks to Haim Mitrany who informed me about this vulnerability.
The text was updated successfully, but these errors were encountered: