-
Notifications
You must be signed in to change notification settings - Fork 2k
JS: js/reflected-xss through file names #142
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8b0a65e
JS: add support for `fs-extra` in `NodeJSFileSystemAccess`
6ce0c42
JS: introduce `fsModuleMember`
4d2fdba
JS: introduce concept: `FileNameSource`
50103e9
JS: improve js/reflected-xss: use file names as sources
9e3fa0e
JS: change notes for file names as a source for js/reflected-xss
db51ddd
JS: address review comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Improvements to JavaScript analysis | ||
|
|
||
| ## General improvements | ||
|
|
||
| * Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following features: | ||
| - file system access, for example through [fs-extra](https://github.com/jprichardson/node-fs-extra) | ||
|
|
||
| ## New queries | ||
|
|
||
| | **Query** | **Tags** | **Purpose** | | ||
| |-----------------------------|-----------|--------------------------------------------------------------------| | ||
| | *@name of query (Query ID)* | *Tags* |*Aim of the new query and whether it is enabled by default or not* | | ||
|
|
||
| ## Changes to existing queries | ||
|
|
||
| | **Query** | **Expected impact** | **Change** | | ||
| |--------------------------------|----------------------------|----------------------------------------------| | ||
| | Reflected cross-site scripting | More true-positive results | This rule now treats file names as a source. | | ||
|
|
||
|
|
||
| ## Changes to QL libraries | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
javascript/ql/test/query-tests/Security/CWE-079/xss-through-filenames.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| var http = require('http'); | ||
| var fs = require('fs'); | ||
|
|
||
| var express = require('express'); | ||
|
|
||
| express().get('/', function(req, res) { | ||
| fs.readdir("/myDir", function (error, files1) { | ||
| res.send(files1); // NOT OK | ||
| }); | ||
| }); | ||
|
|
||
| /** | ||
| * The essence of a real world vulnerability. | ||
| */ | ||
| http.createServer(function (req, res) { | ||
|
|
||
| function format(files2) { | ||
| var files3 = []; | ||
| files2.sort(sort).forEach(function (file) { | ||
| files3.push('<li>' + file + '</li>'); | ||
| }); | ||
| return files3.join(''); | ||
| } | ||
|
|
||
| fs.readdir("/myDir", function (error, files1) { | ||
| res.write(files1); // NOT OK | ||
|
|
||
| var dirs = []; | ||
| var files2 = []; | ||
| files1.forEach(function (file) { | ||
| files2.push(file); | ||
| }); | ||
| res.write(files2); // NOT OK | ||
|
|
||
| var files3 = format(files2); | ||
|
|
||
| res.write(files3); // NOT OK | ||
|
|
||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would the FP you found go away if
realpathbecame a taint step instead of a source?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.
Yes, I believe so, but I still think it should remain a source.
If we later find that
readdirorrealpathcause many FPs as sources, we can downgrade them to taint steps.