We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contactedHave 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
| Expand Up | @@ -46,20 +46,26 @@ private class MethodFileDelete extends Method { | |
| } | ||
|
|
||
| predicate isDeleteFileExpr(Expr expr) { | ||
| exists(MethodAccess ma | | ||
| expr = ma.getQualifier() and | ||
| ma.getMethod() instanceof MethodFileDelete | ||
| ) | ||
| expr = any(MethodFileDelete m).getAReference().getQualifier() | ||
| } | ||
|
|
||
| private class TempDirHijackingToDeleteConfig extends DataFlow::Configuration { | ||
| private class TempDirHijackingToDeleteConfig extends TaintTracking::Configuration { | ||
| TempDirHijackingToDeleteConfig() { this = "TempDirHijackingToDeleteConfig" } | ||
|
|
||
| override predicate isSource(DataFlow::Node source) { | ||
| exists(MethodAccess ma | | ||
| ma.getMethod() instanceof MethodFileCreateTempFile and | ||
| source.asExpr() = ma | ||
| ) | ||
| source.asExpr() = | ||
| any(MethodAccess ma | | ||
| ma.getMethod() instanceof MethodFileCreateTempFile and ma.getNumArgument() = 2 | ||
| ) or | ||
| // TODO: Replace with getSystemProperty("java.io.tmpdir") | ||
| source.asExpr() = any(MethodAccessSystemGetProperty maSgp | maSgp.hasCompileTimeConstantGetPropertyName("java.io.tmpdir")) | ||
| } | ||
|
|
||
| override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { | ||
| node2.asExpr() = | ||
| any(MethodAccess ma | | ||
| ma.getMethod() instanceof MethodFileCreateTempFile and ma.getArgument(2) = node1.asExpr() | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentIs this taint step correct in case the source is already a MethodFileCreateTempFile? (Though apparently the tests cover this and pass?)
Sorry, something went wrong.
All reactions
|
||
| ) | ||
| } | ||
|
|
||
| override predicate isSink(DataFlow::Node sink) { isDeleteFileExpr(sink.asExpr()) } | ||
| Expand Down Expand Up | @@ -137,11 +143,10 @@ private predicate safeUse(Expr e) { | |
|
|
||
| from | ||
| DataFlow::PathNode source, DataFlow::PathNode deleteCheckpoint, DataFlow2::Node deleteCheckpoint2, | ||
| DataFlow2::Node sink, MethodAccess creationCall, Expr unsafe, | ||
| TempDirHijackingToDeleteConfig toDeleteConfig, TempDirHijackingFromDeleteConfig fromDeleteConfig | ||
| DataFlow2::Node sink, MethodAccess creationCall, Expr unsafe | ||
| where | ||
| toDeleteConfig.hasFlowPath(source, deleteCheckpoint) and | ||
| fromDeleteConfig.hasFlow(deleteCheckpoint2, sink) and | ||
| any(TempDirHijackingToDeleteConfig c).hasFlowPath(source, deleteCheckpoint) and | ||
| any(TempDirHijackingFromDeleteConfig c).hasFlow(deleteCheckpoint2, sink) and | ||
| deleteCheckpoint.getNode().asExpr() = deleteCheckpoint2.asExpr() and | ||
| isUnsafeUseUnconstrainedByIfCheck(sink, unsafe) and | ||
| isNonThrowingDirectoryCreationExpression(sink.asExpr(), creationCall) | ||
| Expand Down | ||
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentMight be good to explain why check for = 2, that is, to match the method creating a file in the default OS temp directory.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentDone!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.