[Openstack] [OSSG][OSSN] Heat templates with invalid references allows unintended network access

Nathan Kinder nkinder at redhat.com
Sat Apr 5 03:44:05 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Heat templates with invalid references allows unintended network access
- ---

### Summary ###
Orchestration templates can create security groups to define network
access rules.  When creating these rules, it is possible to have a rule
grant incoming network access to instances belonging to another security
group.  If a rule references a non-existent security group, it can
result in allowing incoming access to all hosts for that rule.

### Affected Services / Software ###
Heat, nova-network, Havana

### Discussion ###
When defining security groups of the "AWS::EC2::SecurityGroup" type in a
CloudFormation-compatible format (CFN) orchestration template, it is
possible to use references to other security groups as the source for
ingress rules.  When these rules are evaluated by Heat in the OpenStack
Havana release, a reference to a non-existent security group will be
silently ignored.  This results in the rule using a "CidrIp" property of
"0.0.0.0/0".  This will allow incoming access to any host for the
affected rule.  This has the effect of allowing unintended network
access to instances.

This issue only occurs when Nova is used for networking (nova-network).
The Neutron networking service is not affected by this issue.

The OpenStack Icehouse release is not affected by this issue.  In the
Icehouse release, Heat will check if a non-existent security group is
referenced in a template and return an error, causing the creation of
the security group to fail.

### Recommended Actions ###
If you are using Heat in the OpenStack Havana release with Nova for
networking (nova-network), you should review your orchestration
templates to ensure that all references to security groups in ingress
rules are valid.  Specifically, you should look at the use of the
"SourceSecurityGroupName" property in your templates to ensure that
all referenced security groups exist.

One particular improper usage of security group references that you
should look for is the case where you define multiple security groups
in one template and use references between them.  In this case, you
need to make sure that you are using the "Ref" intrinsic function to
indicate that you are referencing a security group that is defined in
the same template.  Here is an example of a template with a valid
security group reference:

- ---- begin example correct template snippet ----
"WikiDatabaseSecurityGroup" : {
  "Type" : "AWS::EC2::SecurityGroup",
  "Properties" : {
    "GroupDescription" : "Enable HTTP access plus SSH access",
    "SecurityGroupIngress" : [
      {
        "IpProtocol" : "icmp",
        "FromPort" : "-1",
        "ToPort" : "-1",
        "CidrIp" : "10.1.1.0/24"
      },
      {
        "IpProtocol" : "tcp",
        "FromPort" : "80",
        "ToPort" : "80",
        "CidrIp" : "10.1.1.0/24"
      },
      {
        "IpProtocol" : "tcp",
        "FromPort" : "22",
        "ToPort" : "22",
        "CidrIp" : "10.1.1.0/24"
      },
      {
        "IpProtocol" : "tcp",
        "FromPort" : "3306",
        "ToPort" : "3306",
        "SourceSecurityGroupName" : {
          "Ref": "WebServerSecurityGroup"
        }
      }
    ]
  }
},

"WebServerSecurityGroup" : {
  "Type" : "AWS::EC2::SecurityGroup",
  "Properties" : {
    "GroupDescription" : "Enable HTTP access plus SSH access",
    "SecurityGroupIngress" : [
      {
        "IpProtocol" : "icmp",
        "FromPort" : "-1",
        "ToPort" : "-1",
        "CidrIp" : "10.1.1.0/24"
      },
      {
        "IpProtocol" : "tcp",
        "FromPort" : "80",
        "ToPort" : "80",
        "CidrIp" : "10.1.1.0/24"
      },
      {
        "IpProtocol" : "tcp",
        "FromPort" : "22",
        "ToPort" : "22",
        "CidrIp" : "10.1.1.0/24"
      }
    ]
  }
},
- ---- end example correct template snippet ----

Here is an example of an incorrect reference to a security group defined
in the same template:

- ---- begin example INVALID template snippet ----
      {
        "IpProtocol" : "tcp",
        "FromPort" : "3306",
        "ToPort" : "3306",
        "SourceSecurityGroupName" : "WebServerSecurityGroup" #INCORRECT!
      }
- ---- end example INVALID template snippet ----

The above invalid reference will result in allowing incoming networking
on port 3306 from all hosts:

    IP Protocol | From Port | To Port | IP Range    | Source Group |
  +-------------+-----------+---------+-------------+--------------+
  |        icmp |        -1 |      -1 | 10.1.1.0/24 |              |
  |         tcp |        80 |      80 | 10.1.1.0/24 |              |
  |         tcp |        22 |      22 | 10.1.1.0/24 |              |
  |         tcp |      3306 |    3306 |   0.0.0.0/0 |              |
  +-------------+-----------+---------+-------------+--------------+

It is also recommended that you test your templates if you are using
security group references to ensure that the resulting network rules
are as intended.

### Contacts / References ###
This OSSN : https://wiki.openstack.org/wiki/OSSN/OSSN-0011
Original LaunchPad Bug : https://bugs.launchpad.net/heat/+bug/1291091
OpenStack Security ML : openstack-security at lists.openstack.org
OpenStack Security Group : https://launchpad.net/~openstack-ossg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTP3wFAAoJEJa+6E7Ri+EV5oEH/2JRzNAL8vqsLuZGDDfI/+N5
JiJmv8zXk+A5t2ajxAyG/GO8Ludqr+GxTY+xDkx+GOgXSV0+MDpSeXlFeOnvOxaS
5qNylJF3LLbmXN4PU+lux0zQgizxXAedbjUJVJ5uQHtxHuAvQjRueHI49ynVQfbq
7kmpC/sJFxtQEeunGbxX5O3mERp4HNp8qyRPkyaxmNeAMU0PFk3kOVkOUj0sPys4
lKLjbDJochGgFJXlonbvtPCDFiVtWR3LoxXt5gL2/Rg+oBwIxReTE7H2Jf7f5F3M
KBws/V5hbAKhn1JqB59LM2AShxZhcFD/1/6RdLuqBnsPezIfAkjPEd59Wb/sVvQ=
=lxOL
-----END PGP SIGNATURE-----



More information about the Openstack mailing list