App Security Groups (ASGs) are a collection of egress rules that enable you to specify the protocols, ports, and IP address ranges where app or task instances send traffic.

ASGs define allow rules, and their order of evaluation is unimportant when multiple ASGs apply to the same space or deployment. The platform sets up rules to filter and log outbound network traffic from app and task instances. ASGs apply to both buildpack-based and Docker-based apps and tasks.

Staging and running ASGs

Admins can define a staging ASG for app and task staging, and a running ASG for app and task runtime.

When apps or tasks begin staging, they require traffic rules permissive enough to allow them to pull resources from the network. A running app or task no longer needs to pull resources, so traffic rules can be more restrictive and secure. To distinguish between these two security requirements, you can define a staging ASG for app and task staging with more permissive rules, and a running ASG for app and task runtime with less permissive rules.

Platform wide and space scoped ASGs

To provide granular control when securing a deployment, you can assign platform-wide ASGs that apply to all app and task instances for the entire deployment, or space scoped ASGs that apply only to apps and tasks in a particular space.

In environments with both platform-wide and space-specific ASGs, the ASGs for a particular space are combined with the platform ASGs to determine the effective rules for that space. Any of the permitted traffic in the set of applicable ASGs is then effectively permitted for that app.

Dynamic ASGs

Dynamic ASGs allow ASGs to be applied to apps without the need for an application restart. Only containers using the Silk CNI will have their ASGs updated dynamically; Windows apps and apps using other CNIs (e.g., NSX-T) do not support Dynamic ASGs at this time. Dynamic ASGs are enabled with cf deployment v20.0.0 and higher through cf-networking-release 3.0.0. It is recommended to use Dynamic ASGs with capi-release v1.126.0 or later for improved performance on the /v3/security_groups APIs.

To deactivate Dynamic ASGs: use the ops file operations/disable-dynamic-asgs.yml from cf-deployment v20.0.0 or higher.

Simplifying ASGs with a services subnet

ASGs can be complicated to configure correctly, especially when the specific IP addresses listed in a group change.

To simplify securing a deployment while still allowing apps reach external services, operators can deploy the services into a subnet that is separate from their TAS for VMs deployment, then create ASGs for the apps that allow those service subnets, while denying access to any VM hosting other apps.

For examples of typical ASGs, see Typical ASGs.

Default ASGs

TAS for VMs defines one default ASG, default_security_group. This group allows all outbound traffic from app containers on public and private networks except for the link-local range, 169.254.0.0/16, which is blocked.

For security, TAS for VMs administrators must modify the default ASGs so that outbound network traffic cannot access internal components. For more information, see Restricting app access to internal TAS for VMs components.

The ASG is defined in the Cloud Controller configuration as follows:

security_group_definitions:
- name: default_security_group
  rules:
  - protocol: all
    destination: 0.0.0.0-169.253.255.255
  - protocol: all
    destination: 169.255.0.0-255.255.255.255

ASG sets

ASGs are applied by configuring ASG sets differentiated by scope, platform-wide or space specific, and lifecycle, staging or running.

Currently, the following ASG sets exist in TAS for VMs:

  • Platform-wide staging ASG set, also called “default-staging”
  • Platform-wide running ASG set, also called “default-running”
  • Space-scoped staging ASG set
  • Space-scoped running ASG set

In environments with both platform-wide and space-specific ASG sets, combine the ASG sets for a particular space with the platform ASG sets to determine the rules for that space.

The following table indicates the differences between the four sets:

When an ASG is bound to the… the ASG rules are applied to…
Platform-wide staging ASG set the staging lifecycle for all apps and tasks.
Platform-wide running ASG set the running lifecycle for all app and task instances.
Space-scoped staging ASG set the staging lifecycle for apps and tasks in a particular space.
Space-scoped running ASG set the running lifecycle for app and task instances in a particular space.

Typically, ASGs applied during the staging lifecycle are more permissive than the ASGs applied during the running lifecycle. This is because staging often requires access to different resources, such as dependencies.

You use different commands to apply an ASG to each of the four sets.

For more information, see Managing ASGs with the cf CLI.

Important To apply a staging ASG to apps within a space, you must use cf CLI v6.28.0 or later.

Structure and attributes of ASGs

ASG rules are specified as a JSON array of ASG objects. An ASG object has the following attributes:

Attribute Description Notes
protocol tcp, udp, icmp, or all Required
destination A single IP address, an IP address range like 192.0.2.0-192.0.2.50, or a CIDR block that can receive traffic
ports A single port, multiple comma-separated ports, or a single range of ports that can receive traffic. Examples: 443, 80,8080,8081, 8080-8081 Only possible if protocol is tcp or udp.
code ICMP code Required when protocol is icmp. A value of -1 allows all codes.
type ICMP Required when protocol is icmp. A value of -1 allows all types.
log Set to true to enable logging. For more information about how to configure system logs to be sent to a syslog drain, see Using Log Management Services. Logging is only supported with protocol type tcp.
description An optional field for operators managing ASG rules

Managing ASGs

The following table outlines the flow of tasks that you implement over the lifecycle of ASGs.

For information about procedures for each of these tasks, see Managing ASGs with cf CLI.

  Task For more information, see:
1. Review the existing ASGs. If this is a new deployment, these consist of only the default ASGs. View ASGs
2. Create new ASGs. Create ASGs
3. Update the existing ASGs. Update ASGs
4. Bind ASGs to an ASG set. Bind ASGs
5. If you need to delete an ASG, first unbind it, then delete it. Unbind ASGs and Delete ASGs

Managing ASGs with cf CLI

Learn about the commands you need to create and manage ASGs.

Many of the following procedures require the Cloud Foundry Command Line Interface (cf CLI). To download the cf CLI, see Installing the cf CLI.

Viewing ASGs

To view information about existing ASGs, run the following commands:

Command Output
cf security-groups All ASGs
cf staging-security-groups All ASGs applied to the platform-wide staging ASG set
cf running-security-groups All ASGs applied to the platform-wide running ASG set
cf security-group ASG All rules in the specified ASG, where ASG is the name of the ASG

Note: You can also view ASGs in Apps Manager under the Settings tab of a space or an app.

Creating ASGs

To create an ASG:

  1. Create a rules file: a JSON-formatted single array containing objects that describe the rules. See the following example, which allows ICMP traffic of code 1 and type 0 to all destinations, and TCP traffic to 10.0.11.0/24 on ports 80 and 443. For more information, see The Structure and Attributes of ASGs.

    [
      {
        "protocol": "icmp",
        "destination": "0.0.0.0/0",
        "type": 0,
        "code": 0
      },
      {
        "protocol": "tcp",
        "destination": "10.0.11.0/24",
        "ports": "80,443",
        "log": true,
        "description": "Allow http and https traffic to ZoneA"
      }
    ]
    
  2. Run:

    cf create-security-group ASG PATH-TO-RULES-FILE.json
    

    Where:

    • ASG is the name of your ASG.
    • PATH-TO-RULES-FILE.json is the absolute or relative path to a rules file.

    In the following example, EXAMPLE-ASG is the name of an ASG, and ~/workspace/example-asg.json is the path to a rules file:

    cf create-security-group EXAMPLE-ASG ~/workspace/example-asg.json
    

After the ASG is created, you must bind it to an ASG set before it takes effect. For more information, see Bind ASGs.

Bind ASGs

Note If you enable dynamic ASGs, binding an ASG affects started apps automatically. If dynamic ASGs are not enabled, binding does not affect started apps until you run cf restart on them. To restart all of the apps in an org or a space, use the app-restarter cf CLI plug-in.

To apply an ASG, you must first bind it to an ASG set.

Platform-wide Staging ASG Set

To bind an ASG to the platform-wide staging ASG set:

  1. Run:

    cf bind-staging-security-group ASG
    

    Where ASG is the name of your ASG.

Platform-wide Running ASG Set

To bind an ASG to the platform-wide running ASG set:

  1. Run:

    cf bind-running-security-group ASG
    

    Where ASG is the name of your ASG.

Space-scoped Running ASG Set

To bind an ASG to a space-scoped running ASG set:

  1. Run:

    cf bind-security-group ASG ORG --space SPACE
    

    Where:

    • ASG is the name of your ASG.
    • ORG is the name of the org where you want to bind the ASG set.
    • SPACE is the name of the space where you want to bind the ASG set.

Space-scoped Staging ASG Set

To bind an ASG to a space-scoped staging ASG set:

  1. Run:

    cf bind-security-group ASG ORG --space SPACE --lifecycle staging
    

    Where:

    • ASG is the name of your ASG.
    • ORG is the name of the org where you want to bind the ASG set.
    • SPACE is the name of the space where you want to bind the ASG set.

Update ASGs

Updating an ASG does not affect started apps unless you have Dynamic ASGs enabled. If disabled, you will need to run cf restart the apps. To restart all of the apps in an org or a space, use the app-restarter cf CLI plug-in.

To update an existing ASG:

  1. Edit the ASG rules in the JSON file you created in Create ASGs.

  2. Run:

    cf update-security-group ASG PATH-TO-RULES-FILE.json
    

    Where:

    • ASG is name of the existing ASG you want to change.
    • PATH-TO-RULES-FILE.json is the absolute or relative path to a rules file.

    In the following example, example-asg is the name of an ASG, and ~/workspace/example-asg-v2.json is the path to a rules file:

    cf update-security-group example-asg ~/workspace/example-asg-v2.json
    

Unbind ASGs

Unbinding an ASG does not affect started apps unless you have Dynamic ASGs enabled. If disabled, you will need restart the apps. To restart all of the apps in an org or a space, use the app-restarter cf CLI plug-in.

Platform-wide Staging ASG Set

To unbind an ASG from the platform-wide staging ASG set:

  1. Run:

    cf unbind-staging-security-group ASG
    

    Where ASG is the name of your ASG.

Platform-wide Running ASG Set

To unbind an ASG from the platform-wide running ASG set:

  1. Run:

    cf unbind-running-security-group ASG
    

    Where ASG is the name of your ASG.

Space-scoped ASG Set

To unbind an ASG from a specific space:

  1. Run:

    cf unbind-security-group ASG ORG --space SPACE --lifecycle running
    

    Where:

    • ASG is the name of your ASG.
    • ORG is the org where you want to unbind the ASG set.
    • SPACE is the space where you want to unbind the ASG set.
    • To unbind from the staging ASG set, replace running with staging.

Delete ASGs

You can only delete unbound ASGs. To unbind ASGs, see Unbind ASGs.

To delete an ASG:

  1. Run:

    cf delete-security-group ASG
    

    Where ASG is the name of your ASG.

Typical ASGs

The following table describes examples of typical ASGs. Configure your ASGs in accordance with your organization’s network access policy for untrusted apps.

ASG For access to:
dns DNS, either public or private
public-networks Public networks, excluding IaaS metadata endpoints
private-networks Private networks in accordance with RFC-1918
load-balancers The internal TAS for VMs load balancer and others
internal-proxies Internal proxies
internal-databases Internal databases

DNS

To resolve hostnames to IP addresses, apps require DNS server connectivity, which typically use port 53. Admins should create or update a dns ASG with appropriate rules. Admins can further restrict the DNS servers to specific IP addresses or ranges of IP addresses.

The following is an example dns ASG:

[
  {
    "protocol": "tcp",
    "destination": "0.0.0.0/0",
    "ports": "53"
  },
  {
    "protocol": "udp",
    "destination": "0.0.0.0/0",
    "ports": "53"
  }
]

Public Networks

Apps often require public network connectivity to retrieve app dependencies, or to integrate with services available on public networks. Example app dependencies include public Maven repositories, NPM, RubyGems, and Docker registries.

You should exclude IaaS metadata endpoints, such as 169.254.169.254, because the metadata endpoint can expose sensitive environment information to untrusted apps. The public_networks example below accounts for this recommendation.

The following is an example public_networks ASG:

[
  {
    "destination": "0.0.0.0-9.255.255.255",
    "protocol": "all"
  },
  {
    "destination": "11.0.0.0-169.253.255.255",
    "protocol": "all"
  },
  {
    "destination": "169.255.0.0-172.15.255.255",
    "protocol": "all"
  },
  {
    "destination": "172.32.0.0-192.167.255.255",
    "protocol": "all"
  },
  {
    "destination": "192.169.0.0-255.255.255.255",
    "protocol": "all"
  }
]

Private Networks

Network connections that are commonly allowable in private networks include endpoints such as proxy servers, Docker registries, load balancers, databases, messaging servers, directory servers, and file servers. Configure appropriate private network ASGs as appropriate. You might find it helpful to use a naming convention with private_networks as part of the ASG name, such as private_networks_databases.

You should exclude any private networks and IP addresses that app and task instances should not have access to.

The following is an example private_networks ASG:

[
  {
    "protocol": "tcp",
    "destination": "10.0.0.0-10.255.255.255",
    "ports": "443"
  },
  {
    "protocol": "tcp",
    "destination": "172.16.0.0-172.31.255.255",
    "ports": "443"
  },
  {
    "protocol": "tcp",
    "destination": "192.168.0.0-192.168.255.255",
    "ports": "443"
  }
]

ASGs and Performance on Windows

Each ASG bound to an app results in one or more network policy created on the Host, depending on the number of destinations (ranges and CIDRs count as one destination each). Windows apps with ASGs to many destinations will experience increased latency when the app is starting. Windows apps with ASGs to more than 1000 destinations may fail to start.

Marketplace Services

Each installed Marketplace Service requires its own set of ASG rules to function properly. To determine which ASG rules it requires, see the installation instructions for each installed Marketplace Service. For more information about how to provision and integrate services, see Services Overview.

About the ASG Creator Tool

The ASG Creator is a command line tool that you can use to create JSON rules files. The ASG Creator lets you specify IP addresses, CIDRs, and IP address ranges that you want to disallow traffic to, as well as the addresses that you want to allow traffic to. Based on these disallow/allow (exclude/include) lists that you provide as input, the ASG Creator formulates a JSON file of allow rules.

In turn, the JSON file is the input for the cf create-security-group command that creates an ASG.

To download the latest release of the ASG Creator, see the Cloud Foundry Incubator repository on GitHub.

ASG Logging

For information about how you can use ASGs to correlate emitted logs back to an app, see How to use Application Security Group (ASG) logging in the Tanzu Support Hub.

check-circle-line exclamation-circle-line close-line
Scroll to top icon