feat(aws): restrict security group inbound to current user IP by default#362
feat(aws): restrict security group inbound to current user IP by default#362alexjurkiewicz wants to merge 4 commits into
Conversation
|
Note: most Docker setups don't pass IPv6 connectivity to containers, run the script directly on your host OS to set up IPv6 connectivity. |
|
Great addition - a long time need for security. Note on implementation and interface: code in Core is also used on the platform, in this context "my IP" does not make sense. Core should remain as agnostic as possible from runtime context (the CLI or another usage), eg:
Also I have concerns about using an external API for this. How can we trust this domain will remain clean ? What if later someone take control and starts returning their own CIDR to access instances easily? |
Understood, I will rework this.
IMO, the security benefit is critical. Sunshine is not particularly well hardened software. As far as I can see there is absolutely no rate limiting or protection from abuse. Users can easily create a top-1000 password (eg Having
The service is run by AWS and hostname is in the |
Previously all inbound ports were open to 0.0.0.0/0 and ::/0. This adds a --no-restrict-to-my-ip flag (and matching interactive prompt) to control a new restrictToMyIp option, which is enabled by default. When enabled, the provisioner detects the user's current IPv4 and IPv6 addresses before each Pulumi run by making a request to checkip.global.api.aws with a 5-second timeout per address family. The resulting /32 and /128 CIDRs are passed to the Pulumi stack and used as the security group ingress CIDR instead of the open defaults. IPv6 is optional: if the user has no external IPv6 address the timeout fires and IPv6 ingress rules are skipped. IPv4 is required: failure to detect it raises an error with a hint to use --no-restrict-to-my-ip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add description field to SimplePortDefinition interface and populate descriptions for all Sunshine and Wolf ports. Wire description into AWS security group ingress rule mapping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ve IPs in CLI layer - Replace restrictToMyIp boolean flag with allowedCidrs in state schema. Defaults to open access (0.0.0.0/0); stores restricted /32+/128 when IP restriction is enabled. Refreshed on every provision by the provisioner. - Move IP detection to CLI layer (resolveAllowedCidrs): fetches current IP at create time based on --no-restrict-to-my-ip flag (default: restrict). - Provisioner re-fetches IPs on each provision so the security group stays current across create and start flows. Open CIDRs are passed through as-is.
c74b271 to
6e050b4
Compare
|
Changes:
I'm a little worried I didn't perfectly understand the layers of separation in |
|
Thanks - that may be a bit complex indeed, you did the boilerplate on IP restriction already. Do you mind if I update your PR directly to make the interface generic and usable on all providers ?
Absolutely! Note: for the use case you specifiy, Sunshine UI is not accessible other internet, only streaming ports are open. Accessing UI requires an SSH tunnel (UI access is restricted to LAN by default)
Fair enough |
Sounds great, please go ahead |
|
Continued work on #372 - I made sure to keep your commit history as-is for your contributions :) |
Summary
--no-restrict-to-my-ipCLI flag and matching interactive promptDetails
Previously all inbound ports were open to
0.0.0.0/0and::/0. This change closes the security group to the user's current IPs by default, reducing the attack surface on the instance.IP detection uses a request to
checkip.global.api.awswith a 5-second timeout per address family. The resulting/32and/128CIDRs are passed to Pulumi and used as the security group ingress CIDRs instead of the open defaults.The detected IPs are printed to the console so the user can verify them.
Use
--no-restrict-to-my-ipto restore the previous open-to-all behaviour (e.g. if using a VPN or dynamic IP).Test plan
/32(and/128if you have IPv6)--no-restrict-to-my-ipand confirm SG uses0.0.0.0/0/::/0🤖 Generated with Claude Code