File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
csharp/ql/src/semmle/code/csharp/security/dataflow Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ module ZipSlip {
9696 }
9797
9898 /**
99- * An argument to `GetFileName`.
99+ * An call to `GetFileName`.
100100 *
101101 * This is considered a sanitizer because it extracts just the file name, not the full path.
102102 */
@@ -110,16 +110,30 @@ module ZipSlip {
110110 }
111111
112112 /**
113- * A qualifier in a call to `StartsWith` or ` Substring` string method .
113+ * A call to Substring.
114114 *
115- * A call to a String method such as `StartsWith` or `Substring` can indicate a check for a
115+ * This is considered a sanitizer because `Substring` may be used to extract a single component
116+ * of a path to avoid ZipSlip.
117+ */
118+ class SubstringSanitizer extends Sanitizer {
119+ SubstringSanitizer ( ) {
120+ exists ( MethodCall mc |
121+ mc .getTarget ( ) .hasQualifiedName ( "System.String" , "Substring" ) |
122+ this .asExpr ( ) = mc
123+ )
124+ }
125+ }
126+
127+ /**
128+ * A qualifier in a call to `StartsWith` string method.
129+ *
130+ * A call to a String method such as `StartsWith` can indicate a check for a
116131 * relative path, or a check against the destination folder for whitelisted/target path, etc.
117132 */
118133 class StringCheckSanitizer extends Sanitizer {
119134 StringCheckSanitizer ( ) {
120135 exists ( MethodCall mc |
121- mc .getTarget ( ) .hasQualifiedName ( "System.String" , "StartsWith" ) or
122- mc .getTarget ( ) .hasQualifiedName ( "System.String" , "Substring" ) |
136+ mc .getTarget ( ) .hasQualifiedName ( "System.String" , "StartsWith" ) |
123137 this .asExpr ( ) = mc .getQualifier ( )
124138 )
125139 }
You can’t perform that action at this time.
0 commit comments