RBAC Privilege Update Propagation: Do Active Neo4j Sessions Reflect Changes Immediately?
0 reputation · 08 Jun 2023, 15:51 UTC
0 reputation · 08 Jun 2023, 15:51 UTC
Neo4j’s role‑based access control (RBAC) allows administrators to fine‑tune permissions for node labels and relationship types. When a role’s privileges are altered—such as adding or revoking read or write access—there is uncertainty about how quickly those changes take effect for users who are already connected to the database.
Existing documentation indicates that session state is cached and that certain changes may require a new session to be established. However, the exact propagation behavior, especially for active sessions that perform ongoing transactions, has not been formally verified. This creates a potential gap in enforcing least‑privilege principles, as users might retain elevated rights until they disconnect.
To determine the current behavior, we need to observe whether a privilege change is enforced in real time or only after a session restart. The key questions are:
32775 reputation · 09 Jun 2023, 03:47 UTC
Short answer: yes, for any new query issued after the role is modified, Neo4j will honor the updated privileges immediately. A running transaction that began before the change is not retroactively revoked; it can continue until the point where the new policy would be violated, typically at commit time.
COMMIT or the next query in the transaction).AUTHORIZATION_FAILURE.CREATE ROLE read_label_role;
GRANT READ ON :LabelName TO read_label_role;
CREATE USER alice SET PASSWORD 'pass' USER ROLE read_label_role;
alice and run a MATCH query to confirm success.REVOKE READ ON :LabelName FROM read_label_role;
MATCH in the same session; you should receive an AUTHORIZATION_FAILURE.
BEGIN;
MATCH (n:LabelName) RETURN n;
REVOKE READ ON :LabelName FROM read_label_role;
MATCH (m:LabelName) RETURN m;
COMMIT;
The second MATCH will fail, and the COMMIT will raise an authorization error.
Under normal circumstances, a session restart is not required for privilege changes to take effect. The only scenario where a restart might be considered is if you suspect a stale driver‑side cache in a long‑lived connection pool; in that case, closing all connections or restarting the driver application will clear any cached session state.
To tailor this guidance to your environment, could you confirm which Neo4j major version you are running (4.x or 5.x)? That will help narrow down the exact timing of the cache refresh.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.