Skip to content

feat(cloudfront): warn users that minimumProtocolVersion defaults to TLSv1 without a custom certificate#35416

Closed
AkitoAndo wants to merge 5 commits intoaws:mainfrom
AkitoAndo:fix/cloudfront-distribution-clean
Closed

feat(cloudfront): warn users that minimumProtocolVersion defaults to TLSv1 without a custom certificate#35416
AkitoAndo wants to merge 5 commits intoaws:mainfrom
AkitoAndo:fix/cloudfront-distribution-clean

Conversation

@AkitoAndo
Copy link
Copy Markdown

Issue # (if applicable)
Closes #35404

Reason for this change
Currently, AWS CDK allows setting minimumProtocolVersion on a CloudFront Distribution without requiring a custom SSL/TLS certificate. However, CloudFront silently ignores this setting when using its default certificate, defaulting to TLSv1 regardless of the configured value. This creates a security vulnerability where developers believe their distribution enforces TLS 1.2+ when it actually accepts TLS 1.0 and 1.1.

Description of changes
Added validation in the Distribution constructor to throw an error when minimumProtocolVersion is specified without a custom certificate
Added validation for sslSupportMethod as well, as it has the same dependency on custom certificates
The validation ensures that developers are explicitly aware that these security settings require a custom certificate to take effect
Added comprehensive unit tests to verify the validation logic
The validation logic checks if either minimumProtocolVersion or sslSupportMethod are set without a certificate, and throws a descriptive error message guiding users to provide a custom certificate.

Alternative considered: Adding a warning instead of an error for backward compatibility. However, given the security implications of this misconfiguration, a breaking change with clear error messaging was deemed more appropriate to prevent security vulnerabilities.

Describe any new or updated permissions being added
No new or updated IAM permissions are required for this change.

Description of how you validated changes
Added unit tests to verify that an error is thrown when minimumProtocolVersion is set without a certificate
Added unit tests to verify that an error is thrown when sslSupportMethod is set without a certificate
Added unit tests to confirm that no error is thrown when these properties are set with a valid certificate
Verified that existing tests pass with the new validation
Manually tested the changes by attempting to deploy a Distribution with the problematic configuration and confirming the error is raised during synthesis
Checklist
My code adheres to the [CONTRIBUTING GUIDE](https:/ /github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
DESIGN GUIDELINES
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add validation to prevent setting minimumProtocolVersion and
sslSupportMethod without providing a custom certificate, which
would cause CloudFormation deployment errors.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p1 labels Sep 4, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team September 4, 2025 15:18
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

Add integration test to verify that minimumProtocolVersion and
sslSupportMethod validation works correctly with and without
custom certificates.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@AkitoAndo
Copy link
Copy Markdown
Author

@badmintoncryer
Your advice really helped me out! Thanks a lot!!

@AkitoAndo AkitoAndo changed the title fix(cloudfront): Don't allow minimumProtocolVersion on default cert fix(cloudfront): dont allow minimumProtocolVersion on default cert Sep 4, 2025
Add CloudFormation template snapshots for the certificate validation
integration test.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 4, 2025 15:40

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@kaizencc kaizencc self-assigned this Sep 4, 2025
Fix trailing whitespace errors in CloudFront distribution tests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@dgandhi62 dgandhi62 self-requested a review September 5, 2025 19:11
// Validate that minimumProtocolVersion and sslSupportMethod are only specified with a certificate
if (!props.certificate) {
if (props.minimumProtocolVersion !== undefined) {
throw new ValidationError('minimumProtocolVersion can only be specified when using a custom certificate. Use the \'certificate\' property to provide a certificate.', this);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing an error could potentially be a breaking change for existing users. Could we show a warning instead? We want to let the users know that CloudFront will default to TLSv1. The error message would change accordingly

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback! I've updated the implementation to use Annotations.addWarningV2() instead of throwing a ValidationError.

new IntegTest(app, 'cloudfront-distribution-certificate-validation-test', {
testCases: [stack],
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can consider leaving an assertion to verify that the test succeeds. Alternatively, try mentioning it in the PR why an assertion was not needed. The Integration Test guide has some helpful examples!

https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. I've added assertions to the integration test to verify the CloudFront behavior.

throw new ValidationError('sslSupportMethod can only be specified when using a custom certificate. Use the \'certificate\' property to provide a certificate.', this);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise for sslSuportMethod

Based on PR feedback:
- Change ValidationError to warning when minimumProtocolVersion or
  sslSupportMethod are specified without a certificate
- Update unit tests to verify warnings instead of errors
- Add assertions to integration test to verify CloudFront behavior

This maintains backward compatibility while informing users that
CloudFront will use defaults (TLSv1 for protocol, SNI for method)
when no custom certificate is provided.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@AkitoAndo
Copy link
Copy Markdown
Author

@dgandhi62 Thanks for the review! I've updated the PR based on your feedback:

  • Changed ValidationError to warnings for backward compatibility
  • Added explicit default behavior in warning messages (TLSv1, SNI)
  • Added assertions to the integration test
  • Updated all unit tests accordingly

Ready for re-review when you have time. Thank you 🙇

@dgandhi62 dgandhi62 changed the title fix(cloudfront): dont allow minimumProtocolVersion on default cert feat(cloudfront): warning users on minimumProtocolVersion defaulting to TLSv1 without a custom certificate Sep 8, 2025
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@kaizencc kaizencc added the pr-linter/exempt-readme The PR linter will not require README changes label Sep 9, 2025
@kaizencc kaizencc changed the title feat(cloudfront): warning users on minimumProtocolVersion defaulting to TLSv1 without a custom certificate feat(cloudfront): warn users that minimumProtocolVersion defaults to TLSv1 without a custom certificate Sep 9, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 9, 2025 18:11

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing

To prevent automatic closure:

  • Resume work on the PR
  • OR request an exemption by adding a comment containing 'Exemption Request' with justification e.x "Exemption Request: "
  • OR request clarification by adding a comment containing 'Clarification Request' with a question e.x "Clarification Request: "

This PR will automatically close in 14 days if no action is taken.

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Oct 12, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1 pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-cloudfront: minimumProtocolVersion setting should not be allowed without custom SSL/TLS certificate

4 participants