Skip to content

Commit 086c473

Browse files
author
Esben Sparre Andreasen
committed
JS: sharpen js/http-to-file-access
1 parent f3de75a commit 086c473

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

change-notes/1.23/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
| Client-side cross-site scripting (`js/xss`) | More results | More potential vulnerabilities involving functions that manipulate DOM attributes are now recognized. |
2323
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving functions that manipulate DOM event handler attributes are now recognized. |
2424
| Incorrect suffix check (`js/incorrect-suffix-check`) | Fewer false-positive results | The query recognizes valid checks in more cases.
25+
| Network data written to file (`js/http-to-file-access`) | Fewer false-positive results | This query has been renamed to better match its intended purpose, and now only considers network data untrusted. |
2526
| Prototype pollution (`js/prototype-pollution`) | More results | The query now highlights vulnerable uses of jQuery and Angular, and the results are shown on LGTM by default. |
2627
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now treats responses from servers as untrusted. |
2728

javascript/ql/src/Security/CWE-912/HttpToFileAccess.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name User-controlled data written to file
3-
* @description Writing user-controlled data directly to the file system allows arbitrary file upload and might indicate a backdoor.
2+
* @name Network data written to file
3+
* @description Writing network data directly to the file system allows arbitrary file upload and might indicate a backdoor.
44
* @kind path-problem
55
* @problem.severity warning
66
* @precision medium

javascript/ql/src/semmle/javascript/security/dataflow/HttpToFileAccessCustomizations.qll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,22 @@ module HttpToFileAccess {
2424
abstract class Sanitizer extends DataFlow::Node { }
2525

2626
/** A source of remote user input, considered as a flow source for writing user-controlled data to files. */
27-
class RemoteFlowSourceAsSource extends Source {
27+
deprecated class RemoteFlowSourceAsSource extends DataFlow::Node {
2828
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
2929
}
3030

31+
/**
32+
* An access to a user-controlled HTTP request input, considered as a flow source for writing user-controlled data to files
33+
*/
34+
private class RequestInputAccessAsSource extends Source {
35+
RequestInputAccessAsSource() { this instanceof HTTP::RequestInputAccess }
36+
}
37+
38+
/** A response from a server, considered as a flow source for writing user-controlled data to files. */
39+
private class ServerResponseAsSource extends Source {
40+
ServerResponseAsSource() { this = any(ClientRequest r).getAResponseDataNode() }
41+
}
42+
3143
/** A sink that represents file access method (write, append) argument */
3244
class FileAccessAsSink extends Sink {
3345
FileAccessAsSink() { exists(FileSystemWriteAccess src | this = src.getADataNode()) }

0 commit comments

Comments
 (0)