Back to Checks
iac

Load balancers should drop invalid headers

AWS-0052
Service: elbSeverity: high
OfficialBuilt-inVerified

Passing unknown or invalid headers through to the target poses a potential risk of compromise. By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler iac --checks AWS-0052

Recommendation

Set drop_invalid_header_fields to true

Check Code

# METADATA
# title: Load balancers should drop invalid headers
# description: |
#   Passing unknown or invalid headers through to the target poses a potential risk of compromise.
#   By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
# scope: package
# schemas:
#   - input: schema["cloud"]
# related_resources:
#   - https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html
# custom:
#   id: AWS-0052
#   long_id: aws-elb-drop-invalid-headers
#   aliases:
#     - AVD-AWS-0052
#     - drop-invalid-headers
#     - aws-elb-drop-invalid-headers
#   provider: aws
#   service: elb
#   severity: HIGH
#   recommended_action: Set drop_invalid_header_fields to true
#   input:
#     selector:
#       - type: cloud
#         subtypes:
#           - service: elb
#             provider: aws
#   examples: checks/cloud/aws/elb/drop_invalid_headers.yaml
package builtin.aws.elb.aws0052

import rego.v1

import data.lib.cloud.metadata

deny contains res if {
	some lb in input.aws.elb.loadbalancers
	isManaged(lb)
	lb.type.value == "application"
	not lb.dropinvalidheaderfields.value
	res := result.new(
		"Application load balancer is not set to drop invalid headers.",
		metadata.obj_by_path(lb, ["dropinvalidheaderfields"]),
	)
}