Available prefixes endpoint use parent prefix permissions on POST #4580

Closed
opened 2025-12-29 18:37:54 +01:00 by adam · 5 comments
Owner

Originally created by @Dimaqa on GitHub (Feb 19, 2021).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.9
  • NetBox version: 2.10.3

Steps to Reproduce

  1. Create permission allowing to add only reserved prefixes
  2. Create reserved prefix
  3. POST on /ipam/prefixes/{created_prefix_id}/available-prefixes/
  4. Returned prefix will have active status

Also you can do this:

  1. Create permission allowing to add only reserved prefixes
  2. Create active prefix
  3. POST on /ipam/prefixes/{created_prefix_id}/available-prefixes/ with body {"status" : "reserved"}
  4. API will return 404 NOT FOUND error

Expected Behavior

In the first case api should return permission error.
In the second create reserved child prefix.

Observed Behavior

We can get around add permissions using parent prefixes.

Originally created by @Dimaqa on GitHub (Feb 19, 2021). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reporting reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.6.9 * NetBox version: 2.10.3 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Create permission allowing to add only reserved prefixes 2. Create reserved prefix 3. POST on /ipam/prefixes/{created_prefix_id}/available-prefixes/ 4. Returned prefix will have active status Also you can do this: 1. Create permission allowing to add only reserved prefixes 2. Create active prefix 3. POST on /ipam/prefixes/{created_prefix_id}/available-prefixes/ with body {"status" : "reserved"} 4. API will return 404 NOT FOUND error <!-- What did you expect to happen? --> ### Expected Behavior In the first case api should return permission error. In the second create reserved child prefix. <!-- What happened instead? --> ### Observed Behavior We can get around add permissions using parent prefixes.
adam added the type: bugstatus: accepted labels 2025-12-29 18:37:54 +01:00
adam closed this issue 2025-12-29 18:37:55 +01:00
Author
Owner

@Dimaqa commented on GitHub (Feb 24, 2021):

I believe this won't fix second case, when you can't create child prefix with all needed permissions

@Dimaqa commented on GitHub (Feb 24, 2021): I believe this won't fix second case, when you can't create child prefix with all needed permissions
Author
Owner

@jeremystretch commented on GitHub (Feb 24, 2021):

Yes, that's expected: If you don't have permission to view a prefix, you won't be able to automatically create child prefixes within it.

@jeremystretch commented on GitHub (Feb 24, 2021): Yes, that's expected: If you don't have permission to view a prefix, you won't be able to automatically create child prefixes within it.
Author
Owner

@Dimaqa commented on GitHub (Feb 24, 2021):

No, my point is that if you have view all permissions and create reserved permissions, you still won't be able to create prefix with 404 error. But GET works fine, so that's probably different bug

@Dimaqa commented on GitHub (Feb 24, 2021): No, my point is that if you have view all permissions and create reserved permissions, you still won't be able to create prefix with 404 error. But GET works fine, so that's probably different bug
Author
Owner

@jeremystretch commented on GitHub (Feb 24, 2021):

Sorry, I'm probably just not following. Would you bind opening a separate bug for it?

@jeremystretch commented on GitHub (Feb 24, 2021): Sorry, I'm probably just not following. Would you bind opening a separate bug for it?
Author
Owner

@Dimaqa commented on GitHub (Feb 24, 2021):

Sure

@Dimaqa commented on GitHub (Feb 24, 2021): Sure
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4580