File tree Expand file tree Collapse file tree
src/experimental/Security/CWE-022bis
test/experimental/query-tests/Security/CWE-022 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,8 +36,14 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
3636 source .( AttrRead ) .accesses ( o , any ( string s ) )
3737 )
3838 or
39- // A source catching a S3 filename download
40- exists ( API:: Node s3 | source = s3 .getMember ( "download_file" ) .getACall ( ) .getArg ( 2 ) )
39+ // A source catching an S3 filename download
40+ // see boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.download_file
41+ exists ( MethodCallNode mcn , Node s3 , Node bc |
42+ bc = API:: moduleImport ( "boto3" ) .getMember ( "client" ) .getACall ( ) and
43+ bc = s3 .getALocalSource ( ) and
44+ mcn .calls ( s3 , "download_file" ) and
45+ source = mcn .getArg ( 2 )
46+ )
4147 or
4248 // A source download a file using wget
4349 exists ( MethodCallNode mcn |
Original file line number Diff line number Diff line change 5454 if unpack_path :
5555 shutil .unpack_archive (to_path , unpack_path ) # $result=BAD
5656 to_path = unpack_path
57+
58+
59+ # A source catching an S3 filename download
60+ # see boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.download_file
61+ import boto3
62+
63+ remote_ziped_name = "remote_name.tar.gz"
64+ base_dir = "/tmp/basedir"
65+ local_ziped_path = os .path .join (base_dir , remote_ziped_name )
66+ bucket_name = "mybucket"
67+
68+ s3 = boto3 .client ('s3' )
69+ s3 .download_file (bucket_name , remote_ziped_name , local_ziped_path )
70+ shutil .unpack_archive (local_ziped_path , base_dir ) # $result=BAD
You can’t perform that action at this time.
0 commit comments