mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-02-05 00:29:40 +03:00
Manager unable to edit collections on testing branch #1413
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BlackDex on GitHub (Nov 23, 2022).
Originally assigned to: @BlackDex on GitHub.
Discussed in https://github.com/dani-garcia/vaultwarden/discussions/2930
Originally posted by louisfgr November 23, 2022
When trying to change or add new collections in the testing branch (v 1.26.0-7a767310) as a manager, the user is logged out and the following error appears in the log.
The issue seems to be similar to #2151 from Dec 2021
Your environment (Generated via diagnostics page)
Config (Generated via diagnostics page)
Show Running Config
Environment settings which are overridden:
@BlackDex commented on GitHub (Nov 23, 2022):
Confirmed. Seems to be because of groups.
@stefan0xC commented on GitHub (Nov 23, 2022):
Trying to edit a collection will get the groups of a collection:
7a7673103f/src/api/core/organizations.rs (L1750-L1751)Changing
AdminHeaderstoManagerHeadersLoosefixes this issue but I noticed that Managers that are restricted to specific collections still get listed all collections (and will be logged out if trying to change a collection they are not given access to).@BlackDex commented on GitHub (Nov 23, 2022):
I have no idea right now how this works on Bitwarden.
It might be needed to do some more filtering there, or ignore some stuff.
@stefan0xC commented on GitHub (Nov 23, 2022):
Okay, after further testing this only affects the default collection. On non-default collections the options (gear symbol) are missing and clicking it I get a client-side warning that I am missing the required permissions:

So this might be a client-side issue.
@stefan0xC commented on GitHub (Nov 23, 2022):
Okay, this only happened because the manager had no access to the collection but was part of a group that has access.
@louisfgr commented on GitHub (Nov 28, 2022):
Just tried the new testing version on my test system and again encountered similar problems.
Manager can now create collections and edit the users of this newly created collection, but when I try to edit the users of an already existing collection, I get this error again.
@stefan0xC commented on GitHub (Nov 28, 2022):
Has the manager been given access to the collection or only via a group? If so, then this is the behaviour I have noticed which is a different bug and possible happens in Bitwarden as well (I can't test this because I don't have access to a business plan). Can you create a new issue?
@BlackDex commented on GitHub (Nov 28, 2022):
Please provide the layout/access of the manager you use, and which groups/collections you have configured so that we can try and reproduce this.
I am able to test this on a Bitwarden server.
@BlackDex commented on GitHub (Nov 28, 2022):
I just re-opened this one, we just need more info.
@louisfgr commented on GitHub (Nov 28, 2022):
what @stefan0xC wrote seems to be the problem. The manager was only part of a group.
My broken configuration:
The configuration starts working correctly as soon as I give the manager direct access to collections.
This is also the reason why my manager can edit the newly created collection, as the creating user automatically gets access.
Nevertheless, even if this is a Bitwarden issue, I think there should be a proper error message instead of logging out the user. (If that's possible. I am not a Rust developer, nor am I familiar with the Vaultwarden code).
@BlackDex commented on GitHub (Nov 28, 2022):
Thanks. I have tested this, and it is broken on Vaultwarden, and works fine on Bitwarden.
The issue here is that i think the allowed collections are not retrieved correctly, which in turn causes the user to be logged-out.
Which in turn is good if that user was tampering, but it shouldn't in this case.
Looking at this on how to solve this properly.
@stefan0xC commented on GitHub (Nov 28, 2022):
I think I found the problem. This function
f3beaea9e9/src/db/models/collection.rs (L162-L205)is both called by ciphersf3beaea9e9/src/api/core/ciphers.rs (L116)and organizationsf3beaea9e9/src/api/core/organizations.rs (L265)the latter of which should not include the collections via the groups table.@BlackDex commented on GitHub (Nov 28, 2022):
I actually think it does need to do that. How else would someone be able by group rights to access a collection?
The problem lays in the ManagerHeaders, which calls a query which does not take groups into account.
@stefan0xC commented on GitHub (Nov 28, 2022):
Not sure why we would need that? The question would be if Bitwarden returns all collections in the
/api/collectionscall or only the ones you are able to manage? (As far as I tested it and what I gathered from the output I can gather it's the latter.)The access to the collection I get via group rights is given through the call in ciphers (and does not depend on the
/api/collectionsresult) which I think means that it should return a different result (i.e. more) than the /api/collections call which tells the web-vault which collections I can change. That these are returning the same is the cause of the bug as far as I can tell.I'm not sure if it's better to write a new function for the cipher call or the organization call but probably something like this is needed:
@stefan0xC commented on GitHub (Nov 28, 2022):
Note: I only made this patch to test if this would fix the issue which it does. I have not had time to test this for other possible side effects or come up with a better name. Maybe there is also a cleaner way to express this than code duplication, which is why I did not make a pull request yet.
@BlackDex commented on GitHub (Nov 28, 2022):
Bitwarden returns all the collections the manager has access to, including those granted by groeps.
@stefan0xC commented on GitHub (Nov 28, 2022):
Okay, one difference I just noticed is that we return a list of
collectionfor both /api/collections and /api/organization/<org_uuid>/collections while Bitwarden returns a list ofcollectionDetailsfor the former, which also has the fields readOnly and hidePassword. (Not sure if this is relevant.)Regarding:
Do you mean that a Manager that has access to a collection via a group should be able to edit that collection?
@BlackDex commented on GitHub (Nov 28, 2022):
Yes, since only admins or owners are able to manage those rights and managers (i think) are able to manage all rights they have access too.
@stefan0xC commented on GitHub (Nov 29, 2022):
Ah, sorry. I thought the problem was that they should not have transitive access but I thought about it and it does make sense if you have a larger organization with many collections where you want to utilize a group for management instead of adding an individual manager to each collection.
@BlackDex commented on GitHub (Nov 29, 2022):
I see that the new web-vault (v2022.11.1) reports a warning if a manager does not have access.
Though for our item, it still needs fixing, since that still logs-out the user.
Because of this, i think we do need to thoroughly check all those queries and flows.