Skip to content

Restrict ALB integration-test security group to the test runner's IP - #2532

Open
GarrettBeatty wants to merge 1 commit into
devfrom
restrict-alb-integ-test-sg-to-runner-ip
Open

Restrict ALB integration-test security group to the test runner's IP#2532
GarrettBeatty wants to merge 1 commit into
devfrom
restrict-alb-integ-test-sg-to-runner-ip

Conversation

@GarrettBeatty

Copy link
Copy Markdown
Contributor

Description

The TestServerlessApp.ALB integration test provisions an internet-facing ALB whose security group is open to 0.0.0.0/0 on port 80 with no authentication. DyePack's EC2IPAuthentication scanner flags this publicly accessible endpoint, which has required a standing AppSec exception for the test accounts.

This change closes the exposure at the source instead of relying on the exception.

Changes

  • TestServerlessApp.ALB/serverless.template
    • Add an AllowedCidr parameter (IPv4-CIDR validated, no default so a deploy without it fails closed rather than opening the ALB to the internet).
    • Point the security-group ingress at { "Ref": "AllowedCidr" } instead of 0.0.0.0/0.
  • TestServerlessApp.ALB.IntegrationTests/DeploymentScript.ps1
    • Resolve the runner's public egress IP (via checkip.amazonaws.com, with retries + validation) and pass --template-parameters "AllowedCidr=<ip>/32". Throws if it can't get a valid IP.

The ALB remains internet-facing, so the existing test — which calls the ALB's public DNS from outside the VPC — is unchanged. Locking ingress to the runner's /32 means the ALB is reachable by the test client but not by DyePack's scanners, so the finding should no longer fire.

Notes

  • Test-only change (no published library affected), so no .autover change file.
  • Egress-IP assumption: works cleanly when the runner's egress IP is stable and matches the IP that resolved checkip (single host / NAT with one EIP, e.g. VPC-attached CodeBuild). On a network with an egress IP pool, the /32 could occasionally miss; widen to the runner's NAT CIDR if that occurs in CI.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The ALB integration test provisioned an internet-facing ALB with a security
group open to 0.0.0.0/0 on port 80 and no authentication. DyePack's
EC2IPAuthentication scanner flags this publicly accessible endpoint, which has
required a standing AppSec exception for the test accounts.

Add an AllowedCidr template parameter (no default, fails closed) and point the
security group ingress at it. DeploymentScript.ps1 resolves the runner's public
egress IP and passes it as AllowedCidr=<ip>/32, so the ALB stays reachable by
the test client but not by DyePack's scanners. The ALB remains internet-facing
so the existing test, which calls the public DNS from outside the VPC, is
unchanged.
@GarrettBeatty
GarrettBeatty requested review from a team as code owners August 14, 2026 15:04
@GarrettBeatty
GarrettBeatty requested a review from normj August 14, 2026 15:04
@GarrettBeatty GarrettBeatty added the Release Not Needed Add this label if a PR does not need to be released. label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release Not Needed Add this label if a PR does not need to be released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant