Skip to content

Commit 05e4677

Browse files
committed
Added ability to detect new AWS.ServiceName cases with hardcoded credentials
1 parent e6450a1 commit 05e4677

File tree

3 files changed

+388
-85
lines changed

3 files changed

+388
-85
lines changed

javascript/ql/lib/semmle/javascript/frameworks/AWS.qll

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@
55
import javascript
66

77
module AWS {
8+
/**
9+
* Gets the name of a supported AWS service.
10+
*/
11+
private string getAWSServiceName() {
12+
result =
13+
[
14+
"EC2", "Lambda", "ECS", "EKS", "Batch", "ElasticBeanstalk", "Lightsail", "AppRunner", "S3",
15+
"EFS", "Glacier", "S3Control", "StorageGateway", "Backup", "DynamoDB", "DynamoDBStreams",
16+
"RDS", "Redshift", "ElastiCache", "Neptune", "QLDB", "Athena", "Route53", "CloudFront",
17+
"APIGateway", "ApiGatewayV2", "DirectConnect", "GlobalAccelerator", "CloudWatch",
18+
"CloudFormation", "CloudTrail", "Config", "Organizations", "ServiceCatalog", "SSM",
19+
"ResourceGroups", "IAM", "CognitoIdentity", "CognitoIdentityServiceProvider", "GuardDuty",
20+
"Inspector", "KMS", "SecretsManager", "SecurityHub", "STS", "WAF", "WAFRegional",
21+
"SageMaker", "Rekognition", "Comprehend", "Textract", "Translate", "Polly",
22+
"LexModelBuildingService", "MachineLearning", "Personalize", "EMR", "Kinesis",
23+
"KinesisAnalytics", "KinesisVideo", "QuickSight", "DataPipeline", "Glue", "LakeFormation",
24+
"SNS", "SQS", "SES", "Pinpoint", "Chime", "Connect", "Amplify", "AppSync", "DeviceFarm",
25+
"IoTAnalytics", "IoTEvents", "IoT1ClickDevicesService", "IoTSiteWise", "MediaConvert",
26+
"MediaLive", "MediaPackage", "MediaStore", "ElasticTranscoder", "EventBridge", "MQ", "SWF",
27+
"StepFunctions"
28+
]
29+
}
30+
31+
/**
32+
* Gets a node representing an import of the AWS SDK.
33+
*/
34+
private API::Node getAWSImport() { result = API::moduleImport("aws-sdk") }
35+
36+
/**
37+
* Gets a data flow node representing an instantiation of an AWS service.
38+
*/
39+
private DataFlow::Node getServiceInstantation() {
40+
result =
41+
getAWSImport().getMember(getAWSServiceName()).getAnInstantiation().getReturn().asSource()
42+
}
43+
844
/**
945
* Holds if the `i`th argument of `invk` is an object hash for `AWS.Config`.
1046
*/
@@ -36,6 +72,11 @@ module AWS {
3672
exists(string prop, DataFlow::InvokeNode invk, int i |
3773
takesConfigurationObject(invk, i) and
3874
this = invk.getOptionArgument(i, prop)
75+
or
76+
// `new AWS.ServiceName({ accessKeyId: <user>, secretAccessKey: <password> })`
77+
invk = getServiceInstantation() and
78+
i = 0 and
79+
this = invk.getOptionArgument(i, prop)
3980
|
4081
prop = "accessKeyId" and kind = "user name"
4182
or

0 commit comments

Comments
 (0)