-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ec2): Allow ingress to VPC interface endpoints #4938
Conversation
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
The build failed because changing the security group is a security related change. I don't know what I need to do to fix this. |
How about a See my comment here on why I think that allowing all inbound traffic is not a good default, this is especially true in the context of the CDK where security groups allow all outbound traffic by default. |
This seems to be a common enough issue that trips people up. Maybe Given that most security groups will be defaulted to "allow all outbound", it will Just Work (which we prize highly), and given that the endpoint will only be routable from the VPC, not much of a security risk. People who care enough about locking down to the highest degree will still have the opportunity of doing so by setting |
Yes adding a prop and changing the default is fine. I would call this |
In that sense I like |
@jogold @rix0rrr The There isn't a security risk by allowing inbound traffic as most use cases are to set up an VPC Endpoint for AWS Services such as those listed here. These services are accessible to the open internet and already have an access control mechanism. Inside the VPC, the endpoints work the same and are only accessible inside the VPC. |
Yes, I'm also talking about adding this prop to the interface endpoint.
OK @joehillen something like: if (open) {
this.connections.allowDefaultPortFromAnyIpv4()
} @rix0rrr or |
@jogold If that's true, then that is not reflected in the type. https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-ec2/lib/vpc-endpoint.ts#L202 |
This is only to define the |
The default rule created for VPC endpoints did not have any ingress rules meaning that the VPC endpoints were totally inaccessible. This made them completely useless. This commit add a default ingress rule that allows all IPv4 and IPv6 traffic to the port of the service. fixes aws#4937
fc75423
to
d110e20
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
The default rule created for VPC endpoints did not have any ingress rules meaning that the VPC endpoints were totally inaccessible. This made them completely useless. Add `open` property to control security group ingress. Default is true which means allow all IPv4 and IPv6 traffic to the service port. fixes aws#4937
1561352
to
95481c9
Compare
Thank you @rix0rrr! I'm happy with this. I've squashed and rebased off of master. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
After discussing with AWS security, they requested the default be |
Can't argue with that logic. It's the most secure if nothing can talk to it. |
I'm going back to them to really understand the possible attacks. I'd still prefer to have the default the "it works out of the box" experience. |
This is exactly why I argued against the To give an example, I had lambda functions that were running outside of a VPC. While outside the VPC they were able to talk to services like S3, SSM, SQS, SNS, and APIGW without extra configuration or network access except for the IAM permissions for the specific resources. After configuring to run them inside a VPC, I had to add to create the VPC Interface Endpoints so that these lambda functions could talk to those services. The extra restriction of the security group adds nothing.
According to this, a new security group shouldn't even be created, it should use the default security group for the VPC by default. I'll open a new PR for that instead. |
I wouldn't rely on the default security group because you don't know what ingress rules are currently configured in it (it could be that it has been modified since VPC creation). |
@jogold That's the behavior of AWS. You should take that up with whoever designed VPC Endpoints |
securityGroupIds isn't even a required argument on CfnVpcEndpoint, so there should have never been a default security group in the first place. |
@joehillen The defaults of CDK do not need to mirror the defaults for AWS. The defaults for CDK are more like sensible defaults that most people should want. So, while the default for AWS is "if you don't specify anything you all share the default security group", the default for CDK is "if you don't specify anything, each resource is going to get its own individual security group". @slipdexic I guess we have a difference of mental model here that is worth exploring further. I guess your mental model is "I will prepare a SG with all the rules I want to see, then I pass it into a construct and it should stay as is". My mental model was "I let the SG be created (maybe I will I pass an SG in to share the same SG between constructs) and afterwards I will tell the construct where to allow traffic from (which incidentally changes the SG, but that is not my primary focus). Where is your restrictive ( I guess we satisfy both use cases at the same time if security groups had a I don't find the linked OWASP vulnerability very enlightening. "Missing appropriate hardening" seems to apply, but it's none too specific about what it thinks is "appropriate". The 99% use case of interface endpoints will be exposing AWS services inside your VPC. Those are already hardened because they can just as easily be hit from the Internet (and even if they weren't, it's not even your problem). And even for other kinds of endpoints, the attack surface is still limited as it will be scoped to "your VPC". The AWS security department has required that the security group rule be restricted to the VPC CIDR if it is to be added by default, so that's a change I intend to make to this PR. |
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
4 similar comments
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@rix0rrr Thank you so much for your hard work to make this happen and for taking the problem seriously! <3 |
The default rule created for VPC endpoints did not have any ingress
rules meaning that the VPC endpoints were totally inaccessible.
This made them completely useless.
This commit add a default ingress rule that allows all IPv4 and IPv6
traffic to the port of the service.
fixes #4937
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license