Skip to content

Commit ff4834c

Browse files
committed
Address review feedback
1 parent 4472828 commit ff4834c

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CAPPathInjectionQuery.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,3 @@ class ControlledInputPath extends UtilsControlledPathSink {
7777
exists(DirectoryReaders dr | dr.getPath() = this)
7878
}
7979
}
80-
81-
/**
82-
* This represents calls where the taint flows through the call. e.g.
83-
* ```javascript
84-
* let dir = isdir ('app')
85-
* ```
86-
*/
87-
class CDSAdditionalFlowStep extends UtilsExtraFlow {
88-
DataFlow::CallNode outNode;
89-
90-
CDSAdditionalFlowStep() {
91-
exists(PathConverters pc | pc.getPath() = this and outNode = pc)
92-
or
93-
exists(PathPredicates pr | pr.getPath() = this and outNode = pr)
94-
}
95-
96-
DataFlow::CallNode getOutgoingNode() { result = outNode }
97-
98-
DataFlow::Node getIngoingNode() { result = this }
99-
}

javascript/frameworks/cap/src/path-traversal/PathInjection.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ const cds = require("@sap/cds");
3434
const { rm } = cds.utils
3535

3636
module.exports = class Service1 extends cds.ApplicationService {
37-
38-
init() {
39-
this.on("send1", async (req) => {
40-
let userinput = req.data
41-
await write(userinput).to('db/data') // Path injection alert
42-
}
37+
init() {
38+
this.on("send1", async (req) => {
39+
let userinput = req.data
40+
await write(userinput).to('db/data') // Path injection alert
4341
}
42+
}
4443
}
45-
4644
```
4745
4846
## References
4947
5048
- OWASP 2021: [Injection](https://owasp.org/Top10/A03_2021-Injection/).
51-
- SAP CAP CDS Utils : [Documentation](https://cap.cloud.sap/docs/node.js/cds-utils).
49+
- SAP CAP CDS Utils : [Documentation](https://cap.cloud.sap/docs/node.js/cds-utils).
50+
- Common Weakness Enumeration: [CWE-020](https://cwe.mitre.org/data/definitions/20.html).
51+
- Common Weakness Enumeration: [CWE-022](https://cwe.mitre.org/data/definitions/22.html).

javascript/frameworks/cap/src/path-traversal/PathInjection.ql

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @name Use of user controlled input in CAP CDS file system utilies
2+
* @name Use of user controlled input in CAP CDS file system utilities
33
* @description Using unchecked user controlled values can allow an
44
* attacker to affect paths constructed and accessed in
55
* the filesystem.
@@ -16,17 +16,24 @@
1616
import javascript
1717
import advanced_security.javascript.frameworks.cap.CAPPathInjectionQuery
1818
import advanced_security.javascript.frameworks.cap.RemoteFlowSources
19+
private import semmle.javascript.security.dataflow.TaintedPathCustomizations
20+
private import semmle.javascript.security.dataflow.TaintedPathQuery
1921

2022
module PathInjectionConfig implements DataFlow::ConfigSig {
2123
predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }
2224

2325
predicate isSink(DataFlow::Node sink) { sink instanceof UtilsSink }
2426

2527
predicate isAdditionalFlowStep(DataFlow::Node nodein, DataFlow::Node nodeout) {
26-
exists(CDSAdditionalFlowStep step |
27-
step.getIngoingNode() = nodein and
28-
step.getOutgoingNode() = nodeout
29-
)
28+
exists(PathConverters pc | pc.getPath() = nodein and nodeout = pc)
29+
or
30+
exists(PathPredicates pr | pr.getPath() = nodein and nodeout = pr)
31+
}
32+
33+
predicate isBarrier(DataFlow::Node node) {
34+
node instanceof TaintedPath::Sanitizer
35+
or
36+
TaintedPathConfig::isBarrier(node)
3037
}
3138
}
3239

0 commit comments

Comments
 (0)