Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create scs-XXXX-v1-default-rules-for-security-groups.md #525

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

josephineSei
Copy link
Contributor

closes #521

First draft of standard for default security group rules

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Copy link
Contributor

@artificial-intelligence artificial-intelligence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just noticed what I believe are two typos.

Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
josephineSei and others added 6 commits March 18, 2024 07:14
fix typos

Co-authored-by: Sven <kieske@osism.tech>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Create Test for the default security group rules

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Copy link
Contributor

@markus-hentsch markus-hentsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only added some minor spelling and phrasing improvement suggestions. And a small question about adding more hints to the examples section.

Otherwise looks good!

Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
josephineSei and others added 2 commits March 19, 2024 13:10
fix typos and adjust  some wording

Co-authored-by: Markus Hentsch <129268441+markus-hentsch@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Add example on how to create a rule only for custom security groups

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
@josephineSei
Copy link
Contributor Author

While trying some of the parameters of the create command for default security groups I found the following:

stack@devstack:~/devstack$ openstack default security group rule create --egress --ethertype IPv4 --for-custom-sg
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| description             |                                      |
| direction               | egress                               |
| ether_type              | IPv4                                 |
| id                      | 4e296fa3-4c7e-4883-9275-b6ff5374adda |
| port_range_max          | None                                 |
| port_range_min          | None                                 |
| protocol                | None                                 |
| remote_address_group_id | None                                 |
| remote_group_id         | None                                 |
| remote_ip_prefix        | 0.0.0.0/0                            |
| used_in_default_sg      | False                                |
| used_in_non_default_sg  | True                                 |
+-------------------------+--------------------------------------+
stack@devstack:~/devstack$ openstack default security group rule create --ingress --ethertype IPv4 --for-default-sg
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | 75707673-60d9-482c-8ebd-ada851e25718 |
| port_range_max          | None                                 |
| port_range_min          | None                                 |
| protocol                | None                                 |
| remote_address_group_id | None                                 |
| remote_group_id         | None                                 |
| remote_ip_prefix        | 0.0.0.0/0                            |
| used_in_default_sg      | True                                 |
| used_in_non_default_sg  | True                                 |
+-------------------------+--------------------------------------+

I thought when only providing the --for-default-sg parameter without the --for-custom-sg the rule will only be applied to the default sg. But it does not seem to be the case.
The debug output of the last command shows the API call:

....
REQ: curl -g -i -X POST http://192.168.23.238:9696/networking/v2.0/default-security-group-rules -H "Content-Type: application/json" -H "User-Agent: openstacksdk/2.1.0 keystoneauth1/5.5.0 python-requests/2.31.0 CPython/3.10.12" -H "X-Auth-Token: {SHA256}d59244f2b7304d41d023a86b2c4b52040a170aaf21fe7a792ec5ec448c8a56b6" -d '{"default_security_group_rule": {"remote_ip_prefix": "0.0.0.0/0", "used_in_default_sg": true, "ethertype": "IPv4", "protocol": null, "direction": "ingress", "used_in_non_default_sg": true}}'
Starting new HTTP connection (1): 192.168.23.238:9696
http://192.168.23.238:9696 "POST /networking/v2.0/default-security-group-rules HTTP/1.1" 201 360
RESP: [201] Connection: keep-alive Content-Length: 360 Content-Type: application/json Date: Tue, 19 Mar 2024 12:18:47 GMT X-Openstack-Request-Id: req-b2cd99e7-b20a-4e08-89a2-f5c13b2704ea
RESP BODY: {"default_security_group_rule": {"id": "f5bbf703-4a1c-4fa8-b37b-e5df2159516a", "ethertype": "IPv4", "direction": "ingress", "protocol": null, "port_range_min": null, "port_range_max": null, "remote_ip_prefix": "0.0.0.0/0", "remote_address_group_id": null, "remote_group_id": null, "description": "", "used_in_default_sg": true, "used_in_non_default_sg": true}}
....

This is a Client-specific behavior, as the default for the --for-custom-sg parameter is true: https://github.com/openstack/python-openstackclient/blob/2f9a523765ca99c9ef9a6968e430bab102f3208d/openstackclient/network/v2/default_security_group_rule.py#L145

@josephineSei
Copy link
Contributor Author

josephineSei commented Mar 19, 2024

I talked to upstream and found a bug report for this and a patch, which already fixes this behavior.
Bug report: https://bugs.launchpad.net/python-openstackclient/+bug/2054629
Patch: https://review.opendev.org/c/openstack/python-openstackclient/+/909815

My chat with the Neutron guys made come cores approve this patch and it will be merged :D

remove example in favor of the guide in docs:
SovereignCloudStack/docs#167

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Copy link
Contributor

@artificial-intelligence artificial-intelligence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@markus-hentsch markus-hentsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard's filename should be changed to fill in the document number before merging.

@josephineSei
Copy link
Contributor Author

The standard's filename should be changed to fill in the document number before merging.

We will do this as soon as we can merge it. But right now, when there is still discussion, we might use a number that then is already taken by another standard.

…ult security groups.

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
This will only allow ingress traffic from the same SG for the default security groups.

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
@josephineSei
Copy link
Contributor Author

@markus-hentsch , @horazont could you please review and @markus-hentsch test this standard? Thank you

Copy link
Member

@horazont horazont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes definitely requested (spelling/wording), but also a few places for discussion.

Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Comment on lines 41 to 45
Until the 2023.1 release (antelope) the default Security Group rules are hardcoded in the OpenStack code.
We should require to not change this behavior through code changes in deployments.

Beginning with the 2023.2 release (bobcat) the default Security Group rules can now be edited by administrators through an API.
All rules that should be present as default in Security Groups MUST be configured by admins through this API.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please discuss in the design considerations the two options:

  1. Mandate that admins set a specific set of rules
  2. Mandate that users should always explicitly set security groups

Elaborate the trade-offs and motivate the eventual choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done a discussion on this, please review it and tell, if it is what you suggested

Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Comment on lines 56 to 58
The whitelisting concept of Security Group rules makes it hard to allow traffic with an exception of certain ports.
It would be possible to just define many rules to achieve what a blacklist would achieve.
This has the severe downside that users could be confused by these rules and will not disable unnecessary default rules in their SGs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me what this discussion contributes to the standard for default rules. Please motivate it (e.g. if there was discussion to have a default ruleset which allows most stuff but blocks often-abused services like NFS/rpcbind, DNS etc., then please add that information).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased the sentence.

This can be achieved through having ingress rules in the default Security Group rules that allow ingress traffic from the Remote Security Group "PARENT" but are only used in the default Security Group.

The default Security Group rules for ALL Security Groups SHOULD allow egress Traffic for both IPv4 and IPv6.
This standard does not forbid to also disallow all outgoing traffic making the existence of egress rules OPTIONAL.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This standard does not forbid to also disallow all outgoing traffic making the existence of egress rules OPTIONAL."

I don't understand this sentence fully. Could you please elaborate what is the intent behind this interop statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this sentence, it is unnessecary.

Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Standards/scs-XXXX-v1-default-rules-for-security-groups.md Outdated Show resolved Hide resolved
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>

The rules of a Security Group can be edited by default by any user with the member role within a project.
But when a Security Group is created it automatically incorporates a few SG rules that are configured as default rules.
Since the 2023.2 release, this set of default rules can be adjusted by administrators only[^1][^2].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That now makes it sound as if previous releases allowed everyone to edit the default rules.

Suggestion:

Since the 2023.2 release, the default set of security group rules can be adjusted. This functionality is only available to administrators.

Comment on lines 50 to 53
OpenStacks default rules for security groups already provide a good baseline for port security, because they allow all egress traffic and for the default security group only ingress traffic from the same group.
Allowing more rules would not benefit the security level, while reducing or limiting the existing rules would barely improve it.
Nevertheless a standard could hold up the current security level against possible future release with more open default rules.
Changing the default rules will not change the rules any existing security groups.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting nitpick: I suggest to use paragraph breaks here (empty lines), to make this more readable in the rendered version. I.e.:

1. There could be a set of […].

   OpenStack default rules […].

   Allowing more rules […]. 
   Nevertheless a standard could uphold […].
   Changing the default rules […].

Comment on lines 55 to 57
2. With the already strict OpenStack default rules users are required in most use cases to create and manage their own security groups.
This has the benefit that users need to explicitly think about the port security of their VMs and may be less likely to apply security groups which rules open up more ports than needed.
There is also a guide from the SCS on how to set up a security group that also focuses on having a good port security[^3].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise.

Comment on lines 68 to 69
The requirement to not change the default code of earlier OpenStack releases is difficult to test.
It should be considered to only apply this standard onto versions of OpenStack that implement the new endpoint for the default Security Group rules, which would only include 2023.2 or higher releases.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really an open question, is it?

Code changes are unnecessary because, AFAICT, the setup the standard describes is identical to the setup already provided by stock OpenStack.

Comment on lines +75 to +77
The allowlisting concept of Security Group rules makes it hard to allow traffic with an exception of certain ports.
It would be possible to just define many rules to achieve what a blocklist would achieve.
But having many rules may confuse users and they may not disable unnecessary default rules in their SGs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the open question here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased the abtract, to better represent these annotations.

Comment on lines +71 to +73
It is possible to have different default Security Group rules for the default SG and custom SGs.
And it is arguable to have a more strict standard for default rules for the default Security Group than for the custom Security Groups.
Because the latter ones are not automatically applied to a VM but are always edited by the users to apply to their requirements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the open question here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased the abtract, to better represent these annotations.


## Conformance Tests

The conformance tests should check for the absence of any ingress traffic rules in the `openstack security group rule list`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conformance test should also create a new security group and check that, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the improvement of this? The default security group rules are the ones used to create the rules in security groups. Testing both would not test the standard but would test for bugs in the openstack code applying the default rules to the security groups.
PLUS: to test this through creating security groups, it would also be necessary to create a new project, to have a brand new default security group. We should be able to test everything as non-admin users.

## Conformance Tests

The conformance tests should check for the absence of any ingress traffic rules in the `openstack security group rule list`.
As having egress rules is allowed by this standard, but not forced and can be set in various ways, there will not be any tests for such rules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard explicitly says that egress SHOULD be allowed for both v4 and v6, so that should IMO be tested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the default setting in Openstack. I'm not sure what we are gaining by testing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the default setting in Openstack. I'm not sure what we are gaining by testing it.

Does the SCS mandate somewhere that CSPs may not deviate from OpenStack default settings unless SCS standards specify it?
If not, then I think the proposal is completely valid that we check a CSP has not changed this specific setting from its default (which would in turn violate the standard).

Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
Signed-off-by: josephineSei <128813814+josephineSei@users.noreply.github.com>
@josephineSei
Copy link
Contributor Author

Re-raising this: @markus-hentsch and @horazont I adjusted the tests and the Wording. Could you please review this again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add standard for default security group rules
4 participants