Skip to content

A user with just createRecord rights cannot create edges #830

Closed

Description

@mik1234mc

ArcadeDB Version: ArcadeDB Server v23.1.2-SNAPSHOT (build 213e72b/1674852682016/main)

JDK Version: openjdk 11.0.16 2022-07-19

OS: debian11

Expected behavior

A user with specified createRecord and without updateRecord rights in the security groups should be able to create edges such as CREATE EDGE edge FROM #76:3 TO #112:438273 IF NOT EXISTS.

Actual behavior

The attempt to create an edge with such a user returns edge @rid , but the edge is not created. Likely, the reason is that creating an edge requires internally an update of @in/@out in the ending vertex and this user does not have the rights to update. I would like to have this feature, but I don't have a complete picture what is behind the security design decisions. At least, some exception should be returned.

Activity

  1. lvca commented on Feb 3, 2023

    @lvca
    Member

    What's the exception that is returned?

  2. self-assigned this
    on Feb 3, 2023
  3. added this to the 23.2.1 milestone on Feb 3, 2023
  4. mik1234mc commented on Feb 4, 2023

    @mik1234mc
    Author

    For instance, this command:

    CREATE EDGE charmeas_e FROM #76:3 TO #112:438273 IF NOT EXISTS
    

    Returns:

    {"user":"eltinsertonly","version":"23.1.2-SNAPSHOT (build 213e72bc410b21f3322839e462f3549b13289f31/1674852682016/main)","serverName":"ArcadeDB_0","result":[{"@rid":"#166:32","@type":"charmeas_e","@cat":"e","@in":"#112:438273","@out":"#76:3"}]}
    

    However, the edge is not added to the DB; there is no record with @rid:#166:32.

  5. lvca commented on Feb 9, 2023

    @lvca
    Member

    @mik1234mc does the user have createRecord permission on the whole database or the edge type?

  6. lvca commented on Feb 9, 2023

    @lvca
    Member

    I was able to reproduce it with a new test case:

    java.lang.SecurityException: User 'elon' is not allowed to update records on type 'Vertex1'
    
    	at com.arcadedb.database.EmbeddedDatabase.checkPermissionsOnFile(EmbeddedDatabase.java:572)
    	at com.arcadedb.engine.Bucket.updateRecord(Bucket.java:114)
    	at com.arcadedb.database.EmbeddedDatabase.updateRecordNoLock(EmbeddedDatabase.java:874)
    	at com.arcadedb.database.EmbeddedDatabase.lambda$updateRecord$17(EmbeddedDatabase.java:836)
    	at com.arcadedb.database.EmbeddedDatabase.executeInReadLock(EmbeddedDatabase.java:1298)
    	at com.arcadedb.database.EmbeddedDatabase.updateRecord(EmbeddedDatabase.java:815)
    	at com.arcadedb.graph.GraphEngine.createOutEdgeChunk(GraphEngine.java:246)
    	at com.arcadedb.graph.GraphEngine.connectEdge(GraphEngine.java:136)
    	at com.arcadedb.graph.GraphEngine.newEdge(GraphEngine.java:128)
    	at com.arcadedb.graph.MutableVertex.newEdge(MutableVertex.java:130)
    	at com.arcadedb.server.security.ServerProfilingIT.createOnlyAccess(ServerProfilingIT.java:212)

    Your guess was correct, once the edge is created, the vertices are updated with the reference, so technically you need the create permission on the Edge type and create+update on vertices.

    Security acts at a low level, on buckets, so my fear is that if I create exceptions, I'd introduce some security hole in there.

  7. lvca commented on Feb 9, 2023

    @lvca
    Member

    Just added this note in the docs:


    NOTE: creating an edge is technically 2 operations: (1) create a new edge record and (2) update the vertices with the reference. For this reason, if you want to allow a user to create edges, you have to grant the createRecord permission on the edge type and updateRecord on the vertex type.


  8. mik1234mc commented on Feb 9, 2023

    @mik1234mc
    Author
  9. lvca commented on Feb 9, 2023

    @lvca
    Member

    You could limit the update only to the vertex types. I know it's not a perfect solution for your use case, but at least the scope of the update would be limited.

  10. added
    documentation
    and removed on Feb 9, 2023
  11. added a commit that references this issue on Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentation

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions