-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
User Can Read Token Material for Other Users When Creating Token #11091
Comments
This is following up from a disclosure to the security email group which redirected us here. A user having the A permission can be scoped to limit a user’s ability to only create tokens owned by themselves (constraint like
|
But that's the entire purpose of the feature. Some other system having the possibility of provisioning tokens for other users and then either providing the token or using the token to perform actions as the user. I agree that it's an inherently dangerous functionality. As such I'm having a hard time seeing this as a bug, seems more like a feature request to suggest removing the feature.
Are you interested in providing a PR for the updated documentation? For reference this is what's currently there:
|
To clarify, users can create tokens for themselves via the UI without the assignment of any specific permissions. This is intentional per #6073/#8436 and noted in the REST API documentation. You're correct in that explicit permission assignment is needed for a user to edit/delete his or her own tokens via the UI, and I've opened #11491 to capture this as a bug. As @kkthxbye-code points out above, the ability to enable a user to create tokens on behalf of other users is intentional and desired in certain use cases. I'm happy to consider potential safeguards against the accidental misuse of this feature, but so far no specific implementation has been proposed. |
Proposal:
|
@moonrail we'll have to dig into the implementation details to determine feasibility, but IMO that sounds reasonable. Would you mind opening a feature request to capture this please? |
An alternative might be requiring a different action to create tokens for other users, like Haven't looked at the current implementation though, so not sure what is more feasible. |
@kkthxbye-code ooh I like that idea, it would be a very natural use of custom permission actions. |
Separate permission set sounds perfectly fine to me - this also cannot be used by accident, as the Admin UI does not show these as checkboxes. |
@kkthxbye-code's proposal above has been captured under #12207. Closing this out as no further action is required. |
NetBox version
v3.3.9
Python version
3.8
Steps to Reproduce
user1
, with id of1
) has superuser permissionsuser300
) with theadd_token
permission without constraint, no other permissions (not staff or superuser)user300
issues themselves a token (either via the UI, or endpoint discussed below)user300
sends a POST to://netbox/api/users/tokens/
with the payload below:{"user": 1}
user300
is presented with a token issued foruser1
, with entire key material datauser300
will only be able to see the key material once, as the key is not associated to their account the query for/api/users/tokens
is restricted to their useruser1
doesn't exist, or does not have superuser permissions,user300
can continue incrementing the user ID until one is found.Expected Behavior
At the very least
user300
with theadd_token
may be able to create a token for other users who may have a higher privilege than themselves but should not be able to receive the response payload as they do not haveview_token
permissions.Ideally, the
add_token
permission would not be able to allow a user to create tokens for users with higher permissions than themselves.Observed Behavior
user300
is able to receive the token foruser1
and then impersonate that user who may be a superuser, including changing the password.This can be confirmed in the demo environment.
The text was updated successfully, but these errors were encountered: