Skip to content

Commit 1e12c11

Browse files
committed
Java: Model System.in as stdin threat-model
1 parent 7395223 commit 1e12c11

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

java/ql/lib/semmle/code/java/dataflow/FlowSources.qll

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ deprecated class EnvInput extends DataFlow::Node {
207207
EnvInput() {
208208
this instanceof EnvironmentInput or
209209
this instanceof CliInput or
210-
this instanceof FileInput
210+
this instanceof FileInput or
211+
this instanceof StdinInput
211212
}
212213
}
213214

@@ -234,12 +235,21 @@ private class CliInput extends LocalUserInput {
234235
exists(Field f | this.asExpr() = f.getAnAccess() |
235236
f.getAnAnnotation().getType().getQualifiedName() = "org.kohsuke.args4j.Argument"
236237
)
237-
or
238+
}
239+
240+
override string getThreatModel() { result = "commandargs" }
241+
}
242+
243+
/**
244+
* A node with input from stdin.
245+
*/
246+
private class StdinInput extends LocalUserInput {
247+
StdinInput() {
238248
// Access to `System.in`.
239249
exists(Field f | this.asExpr() = f.getAnAccess() | f instanceof SystemIn)
240250
}
241251

242-
override string getThreatModel() { result = "commandargs" }
252+
override string getThreatModel() { result = "stdin" }
243253
}
244254

245255
/**

0 commit comments

Comments
 (0)