Skip to content

Commit 399bb87

Browse files
authored
Merge pull request #726 from 0xdabbad00/check_alb_for_request_smuggling
Check alb for request smuggling
2 parents b61782a + 57f62f3 commit 399bb87

File tree

8 files changed

+82
-4
lines changed

8 files changed

+82
-4
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"analyzers": [
3+
{
4+
"arn": "arn:aws:access-analyzer:us-east-1:000000000000:analyzer/default",
5+
"createdAt": "2020-06-19T21:20:04Z",
6+
"lastResourceAnalyzed": "arn:aws:sqs:us-east-1:000000000000:test",
7+
"lastResourceAnalyzedAt": "2020-06-19T21:20:04.664Z",
8+
"name": "default",
9+
"status": "ACTIVE",
10+
"tags": {},
11+
"type": "ACCOUNT"
12+
}
13+
]
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"Attributes": [
3+
{
4+
"Key": "access_logs.s3.enabled",
5+
"Value": "false"
6+
},
7+
{
8+
"Key": "access_logs.s3.bucket",
9+
"Value": ""
10+
},
11+
{
12+
"Key": "access_logs.s3.prefix",
13+
"Value": ""
14+
},
15+
{
16+
"Key": "idle_timeout.timeout_seconds",
17+
"Value": "60"
18+
},
19+
{
20+
"Key": "deletion_protection.enabled",
21+
"Value": "false"
22+
},
23+
{
24+
"Key": "routing.http2.enabled",
25+
"Value": "true"
26+
},
27+
{
28+
"Key": "routing.http.drop_invalid_header_fields.enabled",
29+
"Value": "false"
30+
}
31+
]
32+
}

audit_config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,10 @@ ACCESSANALYZER_OFF:
382382
title: Access Analyzer off
383383
description: Access Analyzer is a free service that can tell you when resources are public or shared with unexpected accounts.
384384
severity: Medium
385-
group: AccessAnalyzer
385+
group: AccessAnalyzer
386+
387+
REQUEST_SMUGGLING:
388+
title: Request smuggling not denied
389+
description: "HTTP request smuggling is possible against ALBs, as described here: https://99designs.com/blog/engineering/request-smuggling/"
390+
severity: Low
391+
group: ELB

cloudmapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import pkgutil
3131
import importlib
3232

33-
__version__ = "2.9.0"
33+
__version__ = "2.9.1"
3434

3535

3636
def show_help(commands):

collect_commands.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
Parameters:
153153
- Name: TargetGroupArn
154154
Value: elbv2-describe-target-groups/*|.TargetGroups[].TargetGroupArn
155+
- Service: elbv2
156+
Request: describe-load-balancer-attributes
157+
Parameters:
158+
- Name: LoadBalancerArn
159+
Value: elbv2-describe-load-balancers.json|.LoadBalancers[].LoadBalancerArn
155160
- Service: elbv2
156161
Request: describe-tags
157162
Parameters:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mock==4.0.2
1919
netaddr==0.7.19
2020
nose==1.3.7
2121
pandas==1.0.4
22-
parliament==0.4.14
22+
parliament==0.5.0
2323
policyuniverse==1.1.0.1
2424
pycodestyle==2.5.0
2525
pyflakes==2.2.0

shared/audit.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,25 @@ def audit_ec2(findings, region):
834834
)
835835

836836

837+
def audit_elbv2(findings, region):
838+
json_blob = query_aws(region.account, "elbv2-describe-load-balancers", region)
839+
840+
for load_balancer in json_blob.get("LoadBalancers", []):
841+
arn = load_balancer["LoadBalancerArn"]
842+
843+
# Check attributes
844+
attributes_json = get_parameter_file(
845+
region, "elbv2", "describe-load-balancer-attributes", arn
846+
)
847+
848+
for attribute in attributes_json.get("Attributes", []):
849+
if (
850+
attribute["Key"] == "routing.http.drop_invalid_header_fields.enabled"
851+
and attribute["Value"] == "false"
852+
):
853+
findings.add(Finding(region, "REQUEST_SMUGGLING", arn))
854+
855+
837856
def audit_sg(findings, region):
838857
# TODO Check if security groups allow large CIDR range (ex. 1.2.3.4/3)
839858
# TODO Check if an SG restricts IPv4 and then opens IPv6 or vice versa.
@@ -1143,6 +1162,7 @@ def audit(accounts):
11431162
audit_redshift(findings, region)
11441163
audit_es(findings, region)
11451164
audit_ec2(findings, region)
1165+
audit_elbv2(findings, region)
11461166
audit_sg(findings, region)
11471167
audit_lambda(findings, region)
11481168
audit_glacier(findings, region)

tests/unit/test_audit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def test_audit(self):
4646
"EC2_OLD",
4747
"IAM_UNEXPECTED_S3_EXFIL_PRINCIPAL",
4848
"IAM_LINTER",
49-
"EC2_IMDSV2_NOT_ENFORCED"
49+
"EC2_IMDSV2_NOT_ENFORCED",
50+
"REQUEST_SMUGGLING"
5051
]
5152
),
5253
)

0 commit comments

Comments
 (0)