Any user can set a network as external

Bug #1338880 reported by Gabriel Assis Bezerra
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Elena Ezhova
Icehouse
Fix Released
High
Tristan Cacqueray

Bug Description

Even though the default policy.json restrict the creation of external networks to admin_only, any user can update a network as external.

I could verify this with the following test (PseudoPython):

project: ProjectA
user: ProjectMemberA has Member role on project ProjectA.

with network(name="UpdateNetworkExternalRouter", tenant_id=ProjectA, router_external=False) as test_network:
            self.project_member_a_neutron_client.update_network(network=test_network, router_external=True)

project_member_a_neutron_client encapsulates a python-neutronclient, and here it is what the method does.

    def update_network(self, network, name=None, shared=None, router_external=None):
        body = {
            'network': {
            }
        }
        if name is not None:
            body['network']['name'] = name
        if shared is not None:
            body['network']['shared'] = shared
        if router_external is not None:
            body['network']['router:external'] = router_external

        self.python_neutronclient.update_network(network=network.id, body=body)['network']

The expected behaviour is that the operation should not be allowed, but the user without admin privileges is able to perform such change.

Trying to add an "update_network:router:external": "rule:admin_only" policy did not work and broke other operations a regular user should be able to do.

Revision history for this message
Eugene Nikanorov (enikanorov) wrote :

What kind of operations break if "update_network:router:external": "rule:admin_only" is added?

Changed in neutron:
importance: Undecided → High
tags: added: api
Changed in neutron:
assignee: nobody → Eugene Nikanorov (enikanorov)
Revision history for this message
Gabriel Assis Bezerra (gabriel-bezerra) wrote :

A regular user cannot update the network anymore, e.g., to set its name.

This is the exception:

  [project_member_a_neutron_client.update_network...]
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 101, in with_params
    ret = self.function(instance, *args, **kwargs)
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 350, in update_network
    return self.put(self.network_path % (network), body=body)
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 1324, in put
    headers=headers, params=params)
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 1300, in retry_request
    headers=headers, params=params)
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 1243, in do_request
    self._handle_fault_response(status_code, replybody)
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 1211, in _handle_fault_response
    exception_handler_v20(status_code, des_error_body)
  File "/opt/stack/python-neutronclient/neutronclient/v2_0/client.py", line 74, in exception_handler_v20
    message=error_dict)

NeutronClientException: The resource could not be found.

Elena Ezhova (eezhova)
Changed in neutron:
assignee: Eugene Nikanorov (enikanorov) → Elena Ezhova (eezhova)
Changed in neutron:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/105792

Changed in neutron:
status: Confirmed → In Progress
Kyle Mestery (mestery)
Changed in neutron:
milestone: none → juno-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/105792
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=dc444960946445f2bef0b8eaab675420a29d5ba3
Submitter: Jenkins
Branch: master

commit dc444960946445f2bef0b8eaab675420a29d5ba3
Author: Elena Ezhova <email address hidden>
Date: Wed Jul 9 20:10:17 2014 +0400

    Add rule for updating network's router:external attribute

    Set admin_only rule for update_network:router:external in policy.json

    Also, change the default value of router:external from attr.ATTR_NOT_SPECIFIED
    to False, because each time we try to get or update a network the dict with
    its attributes is extended by _extend_network_dict_l3 function which adds
    router:external=False to the dict if this attribute is not specified.
    Thus, if the default value is not specified, router:external is considered
    to be updated in any case and the policy rule is applied.

    Change-Id: I899d98c7d8c9d9863ac5d8f992b6a2d507ec4482
    Closes-Bug: 1338880

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
Gabriel Assis Bezerra (gabriel-bezerra) wrote :

This bug has not been completely fixed. Any user can still unset the network from being external.

The change in the test of the description would be:

with network(name="UpdateNetworkExternalRouter", tenant_id=ProjectA, router_external=True) as test_network:
            self.project_member_a_neutron_client.update_network(network=test_network, router_external=False)

Revision history for this message
Elena Ezhova (eezhova) wrote :

Thank you for bringing this up! That seems like a thing that definitely should be fixed.

Revision history for this message
Elena Ezhova (eezhova) wrote :

Gabriel, the problem you described is a part of another bug (https://bugs.launchpad.net/neutron/+bug/1357379) for which there is a fix on review.

Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (stable/icehouse)

Related fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/123849

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (master)

Reviewed: https://review.openstack.org/114531
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=74d10939903984d5f06c1749a8707fa3257e44ff
Submitter: Jenkins
Branch: master

commit 74d10939903984d5f06c1749a8707fa3257e44ff
Author: Elena Ezhova <email address hidden>
Date: Tue Aug 19 15:54:36 2014 +0400

    Forbid regular users to reset admin-only attrs to default values

    A regular user can reset an admin-only attribute to its default
    value due to the fact that a corresponding policy rule is
    enforced only in the case when an attribute is present in the
    target AND has a non-default value.

    Added a new attribute "attributes_to_update" which contains a list
    of all to-be updated attributes to the body of the target that is
    passed to policy.enforce.

    Changed a check for whether an attribute is explicitly set.
    Now, in the case of update, the function should not pay attention
    to a default value of an attribute, but check whether it was
    explicitly marked as being updated.

    Added unit-tests.

    Closes-Bug: #1357379
    Related-Bug: #1338880
    Change-Id: I6537bb1da5ef0d6899bc71e4e949f2c760c103c2

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (stable/havana)

Related fix proposed to branch: stable/havana
Review: https://review.openstack.org/123952

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (stable/havana)

Change abandoned by Elena Ezhova (<email address hidden>) on branch: stable/havana
Review: https://review.openstack.org/123952
Reason: Abandon change due to the stopped support of stable/havana.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (stable/icehouse)

Reviewed: https://review.openstack.org/123849
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=dd4b77ff53479389a5af8b45fd95ee2987562f29
Submitter: Jenkins
Branch: stable/icehouse

commit dd4b77ff53479389a5af8b45fd95ee2987562f29
Author: Elena Ezhova <email address hidden>
Date: Tue Aug 19 15:54:36 2014 +0400

    Forbid regular users to reset admin-only attrs to default values

    A regular user can reset an admin-only attribute to its default
    value due to the fact that a corresponding policy rule is
    enforced only in the case when an attribute is present in the
    target AND has a non-default value.

    Added a new attribute "attributes_to_update" which contains a list
    of all to-be updated attributes to the body of the target that is
    passed to policy.enforce.

    Changed a check for whether an attribute is explicitly set.
    Now, in the case of update, the function should not pay attention
    to a default value of an attribute, but check whether it was
    explicitly marked as being updated.

    Added unit-tests.

    Conflicts:
     neutron/common/constants.py

    Closes-Bug: #1357379
    Related-Bug: #1338880
    Change-Id: I6537bb1da5ef0d6899bc71e4e949f2c760c103c2
    (cherry picked from commit 74d10939903984d5f06c1749a8707fa3257e44ff)

tags: added: in-stable-icehouse
Thierry Carrez (ttx)
Changed in neutron:
milestone: juno-3 → 2014.2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (feature/lbaasv2)

Related fix proposed to branch: feature/lbaasv2
Review: https://review.openstack.org/130864

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (feature/lbaasv2)
Download full text (72.6 KiB)

Reviewed: https://review.openstack.org/130864
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=c089154a94e5872efc95eab33d3d0c9de8619fe4
Submitter: Jenkins
Branch: feature/lbaasv2

commit 62588957fbeccfb4f80eaa72bef2b86b6f08dcf8
Author: Kevin Benton <email address hidden>
Date: Wed Oct 22 13:04:03 2014 -0700

    Big Switch: Switch to TLSv1 in server manager

    Switch to TLSv1 for the connections to the backend
    controllers. The default SSLv3 is no longer considered
    secure.

    TLSv1 was chosen over .1 or .2 because the .1 and .2 weren't
    added until python 2.7.9 so TLSv1 is the only compatible option
    for py26.

    Closes-Bug: #1384487
    Change-Id: I68bd72fc4d90a102003d9ce48c47a4a6a3dd6e03

commit 17204e8f02fdad046dabdb8b31397289d72c877b
Author: OpenStack Proposal Bot <email address hidden>
Date: Wed Oct 22 06:20:15 2014 +0000

    Imported Translations from Transifex

    For more information about this automatic import see:
    https://wiki.openstack.org/wiki/Translations/Infrastructure

    Change-Id: I58db0476c810aa901463b07c42182eef0adb5114

commit d712663b99520e6d26269b0ca193527603178742
Author: Carl Baldwin <email address hidden>
Date: Mon Oct 20 21:48:42 2014 +0000

    Move disabling of metadata and ipv6_ra to _destroy_router_namespace

    I noticed that disable_ipv6_ra is called from the wrong place and that
    in some cases it was called with a bogus router_id because the code
    made an incorrect assumption about the context. In other case, it was
    never called because _destroy_router_namespace was being called
    directly. This patch moves the disabling of metadata and ipv6_ra in
    to _destroy_router_namespace to ensure they get called correctly and
    avoid duplication.

    Change-Id: Ia76a5ff4200df072b60481f2ee49286b78ece6c4
    Closes-Bug: #1383495

commit f82a5117f6f484a649eadff4b0e6be9a5a4d18bb
Author: OpenStack Proposal Bot <email address hidden>
Date: Tue Oct 21 12:11:19 2014 +0000

    Updated from global requirements

    Change-Id: Idcbd730f5c781d21ea75e7bfb15959c8f517980f

commit be6bd82d43fbcb8d1512d8eb5b7a106332364c31
Author: Angus Lees <email address hidden>
Date: Mon Aug 25 12:14:29 2014 +1000

    Remove duplicate import of constants module

    .. and enable corresponding pylint check now the only offending instance
    is fixed.

    Change-Id: I35a12ace46c872446b8c87d0aacce45e94d71bae

commit 9902400039018d77aa3034147cfb24ca4b2353f6
Author: rajeev <email address hidden>
Date: Mon Oct 13 16:25:36 2014 -0400

    Fix race condition on processing DVR floating IPs

    Fip namespace and agent gateway port can be shared by multiple dvr routers.
    This change uses a set as the control variable for these shared resources
    and ensures that Test and Set operation on the control variable are
    performed atomically so that race conditions do not occur among
    multiple threads processing floating IPs.
    Limitation: The scope of this change is limited to addressing the race
    condition described in the bug report. It may not address other issues
    such as pre-existing issue wit...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.