Skip to content

Commit 91767f0

Browse files
authored
feat(elbv2): add dropInvalidHeaderFields for elbv2 (#22466)
Dropping invalid HTTP headers is recommended and also appears in Security Hub controls as [ELB.4](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-fsbp-controls.html#fsbp-elb-4) Attribute document: https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_LoadBalancerAttribute.html ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 73c443a commit 91767f0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export interface ApplicationLoadBalancerProps extends BaseLoadBalancerProps {
4343
* @default 60
4444
*/
4545
readonly idleTimeout?: Duration;
46+
47+
/**
48+
* Indicates whether HTTP headers with invalid header fields are removed
49+
* by the load balancer (true) or routed to targets (false)
50+
*
51+
* @default false
52+
*/
53+
readonly dropInvalidHeaderFields?: boolean;
4654
}
4755

4856
/**
@@ -100,6 +108,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic
100108

101109
if (props.http2Enabled === false) { this.setAttribute('routing.http2.enabled', 'false'); }
102110
if (props.idleTimeout !== undefined) { this.setAttribute('idle_timeout.timeout_seconds', props.idleTimeout.toSeconds().toString()); }
111+
if (props.dropInvalidHeaderFields) {this.setAttribute('routing.http.drop_invalid_header_fields.enabled', 'true'); }
103112
}
104113

105114
/**

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/load-balancer.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe('tests', () => {
8181
deletionProtection: true,
8282
http2Enabled: false,
8383
idleTimeout: cdk.Duration.seconds(1000),
84+
dropInvalidHeaderFields: true,
8485
});
8586

8687
// THEN
@@ -98,6 +99,10 @@ describe('tests', () => {
9899
Key: 'idle_timeout.timeout_seconds',
99100
Value: '1000',
100101
},
102+
{
103+
Key: 'routing.http.drop_invalid_header_fields.enabled',
104+
Value: 'true',
105+
},
101106
],
102107
});
103108
});

0 commit comments

Comments
 (0)