Skip to content

Security: Make optional the hard-coded Security Group runner_sg? #748

Closed

Description

@boldandbusted

Howdy. I have a restriction in an environment that prevents wide open egress AWS Security Group rules from being applied (automation actually reverses what this module sets). Each time I apply this rule the automation undoes this, so we get repeating change-in-place loops from TF apply to apply. I'd rather manage this via other means - like using the default SG for the VPC. Is this possible? Or am I missing a path to this functionality that already is available via the module input variables?

https://github.com/philips-labs/terraform-aws-github-runner/blob/65aab803262e0616a8895d2fdbc0bc112e2572f9/modules/runners/main.tf#L117

What would be great would be a method to either:

  • Customize this SG
  • Disable applying this SG (and then rely on the VPC default SG)

Note that I'm already using runner_additional_security_group_ids input variable to specify the default VPC SG, but I don't think I can use that to undo what this code is doing?

Thanks in advance! :) Happy to provide more info.

Activity

  1. npalm commented on Apr 13, 2021

    @npalm
    Member

    The security group should be better configurable, what do you think of making the egress fully configureable with the current defaults. In that case we avoid breaking changes. I have done the same for another module, check

    https://github.com/npalm/terraform-aws-gitlab-runner/blob/8b15241b34c87d7b21c7a14fddf7d0b84f750f1b/security_groups.tf#L5

    Feel free to suggest the change in a PR

  2. added
    enhancement
    good first issue
    help wanted
    on Apr 15, 2021
  3. new23d commented on Jul 16, 2021

    @new23d
    Contributor

    @boldandbusted does the automation in your environment not like the destination range of IP addresses (that is, 0.0.0.0/0) or the list of ports (0 to 65535)?

    I'm wondering if keeping 0.0.0.0/0 but restricting the ports will resolve this issue.

  4. boldandbusted commented on Aug 11, 2021

    @boldandbusted
    ContributorAuthor

    @boldandbusted does the automation in your environment not like the destination range of IP addresses (that is, 0.0.0.0/0) or the list of ports (0 to 65535)?

    I'm wondering if keeping 0.0.0.0/0 but restricting the ports will resolve this issue.

    Sorry for the late reply. It's hard for me to tell because there are other groups that have automation that slams closed security groups that open ports and IPs to the public Internet. It would probably be useful to have what @npalm suggests for a PR, if that gives us flexibility to specify address and ports, together.

  5. new23d commented on Aug 14, 2021

    @new23d
    Contributor

    FWIW, we analysed the egress traffic from the runner through a firewall. As of today, it was TLS port 443 (so HTTPS I guess) connections to:

    logs.<region>.amazonaws.com
    ssm.<region>.amazonaws.com
    
    pipelines.actions.githubusercontent.com
    github.com
    codeload.github.com
    api.github.com
    vstoken.actions.githubusercontent.com
    
    <var.environment>-dist-<random>.s3.<region>.amazonaws.com
    <var.environment>-dist-<random>.s3.amazonaws.com
    

    The S3 bucket at the end of that allowlist is the one with the runner binaries. So the hostname can be deduced/output from that module.

    And very early on, on instance boot:

    1 attempt to ec2-instance-connect.<region>.amazonaws.com over TLS on port 443 and 3 attempts to some S3 IP address on port 80 (we did not capture the details of these.) All these were not allowed 🔒 and the runners still functioned as expected ✔️

    GitHub have documented Communication between self-hosted runners and GitHub nicely. Maybe because of our simplistic Hello World pipeline we did not see connections to all those mentioned but they should be expected.

    The Lambda functions were not run in the VPC and therefore not analysed yet.

    Disclosure: I work for a network firewall co. and their firewall was used. We are working on a support case that requires GitHub self-hosted runners in their VPC to be filtered outbound, hence the interest and the work 🤓

  6. new23d commented on Sep 21, 2021

    @new23d
    Contributor

    For completeness, the Lambda talks to

    ec2.<region>.amazonaws.com
    ssm.<region>.amazonaws.com
    api.github.com
    

    We've documented our scan here.

    @npalm since the PR was merged, this issue can be closed?
    @boldandbusted your thoughts? Satisfied with the PR?

  7. boldandbusted commented on Sep 21, 2021

    @boldandbusted
    ContributorAuthor

    For completeness, the Lambda talks to

    ec2.<region>.amazonaws.com
    ssm.<region>.amazonaws.com
    api.github.com
    

    We've documented our scan here.

    @npalm since the PR was merged, this issue can be closed?
    @boldandbusted your thoughts? Satisfied with the PR?

    This looks fantastic! I'm satisfied, and grateful. :) I think this can be closed, from my perspective. Wooohoo!

  8. gertjanmaas commented on Sep 22, 2021

    @gertjanmaas
    Contributor

    Alright, closing it then :)

  9. added a commit that references this issue on Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions