Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a91d91

Browse files
committed
JS: Allow path.basename sanitization in zipslip.
1 parent 69a048d commit 0a91d91

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • javascript/ql/src/semmle/javascript/security/dataflow

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ module ZipSlip {
1515
*/
1616
abstract class Sink extends DataFlow::Node { }
1717

18+
/**
19+
* A sanitizer for unsafe zip extraction.
20+
*/
21+
abstract class Sanitizer extends DataFlow::Node { }
22+
1823
/**
1924
* A sanitizer guard for unsafe zip extraction.
2025
*/
@@ -28,6 +33,8 @@ module ZipSlip {
2833

2934
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3035

36+
override predicate isSanitizer(DataFlow::Node sanitizer) { sanitizer instanceof Sanitizer }
37+
3138
override predicate isSanitizerGuard(TaintTracking::SanitizerGuardNode nd) {
3239
nd instanceof SanitizerGuard
3340
}
@@ -90,6 +97,13 @@ module ZipSlip {
9097
FileSystemWriteSink() { exists(FileSystemWriteAccess fsw | fsw.getAPathArgument() = this) }
9198
}
9299

100+
/** An expression that sanitizes by calling path.basename */
101+
class BasenameSanitizer extends Sanitizer {
102+
BasenameSanitizer() {
103+
this = DataFlow::moduleImport("path").getAMemberCall("basename")
104+
}
105+
}
106+
93107
/**
94108
* Gets a string which is sufficient to exclude to make
95109
* a filepath definitely not refer to parent directories.

0 commit comments

Comments
 (0)