Skip to content

Edge cases require all implementations to couple authorization and storage #97

Closed

Description

@RubenVerborgh
No description provided.

Activity

  1. csarven commented on Aug 16, 2021

    @csarven
    Member

    An agent needs Read on C/R for a server to return 200 (when resource exists) or 404 (when resource does not exist). How else are typical 200 or 404 are returned?

    If agent does not have Read on C/R, the server returns 403. It doesn't have to do anything further. That'd be a conforming implementation.

    If however, a server wants to return a more specific/useful code by taking in other information into account, eg. can the agent actually know C/R exists by viewing C/ if they have Read on C/? Those servers wanting to do more would still be conformant if they returned 404 (IMO). That's one of the reasons why there is a difference between the codes. solid/specification#288 (comment) mentions they are not fixed for various reasons.


    Don't we have some existing issues/discussions in Protocol on locking? Happy to revise the text in WAC so that it doesn't necessarily mean that WAC has to check with the system for each container or whatever. I'd expect the system to only query (like ASK) for Authorization rules that's relevant as opposed to for each path segment eg. if /a/ exists but /a/a/ doesn't exist, don't need to work from the lowest in path to highest (towards root).

  2. justinwb commented on Aug 17, 2021

    @justinwb
    Member

    I believe the ideal situation for scalability purposes would be as follows:

    • WAC can be implemented as a layer that either:

      • returns 403 OR
      • sends the request through to the (LDP) backend, which then generates the status code (which is not 403)
    • This means that, to make a decision, WAC only needs as input:

      • the request
      • the ACL state
    • Specifically, WAC does not need any non-ACL Pod document state as input.

    +1 - I believe that this decoupling is essential to scale and to good implementation design.

    Also, would like to mention the value of having explicit modes for create / delete on a container in this context, as detailed in these authorization use cases (and associated requirements):

    Having this added specificity in permissions would allow the authorization subsystem to make better and more accurate choices about what is does / doesn't pass through, while at the same time applying principle of least privilege to operations that could/would update the non-server-managed graph of the container.

  3. kjetilk commented on Aug 17, 2021

    @kjetilk
    Member

    I am very sympathetic to the goal of this issue. I will just record an opinion that I also voiced in the Solid Editor's meeting today:

    I had a design for an auth proxy that could sit in front of the rest of the interaction, but in my design, I had an optimization that would record creates and deletions with the intention of keeping track of the existence of a resource (specifically into an in-memory trie). Originally, I didn't have this in mind, but simply to make it very cheap to reject a request with a 404 or 410, if the resource did not exist, as I see this as a protection against a DoS attack that seeks to overwhelm the relatively expensive auth operations on non-existent resources. With this design, the above wouldn't be so much of a concern. Then, I feel that this is something that should be done anyway, and so, I don't see quite the importance of this issue.

    Nevertheless, I acknowledge the concern, and that more access modes would be helpful, and that it should be something that we consider. Urgently, even.

  4. TallTed commented on Aug 20, 2021

    @TallTed
  5. csarven commented on Sep 5, 2021

    @csarven
    Member

    The tables in that comment are (obviously) populated from the point of the Protocol, not WAC's response codes.

    PUT- and PATCH-to-create have the same requirements. I brought back the C/ column to the PATCH table and added the note: solid/specification#14 (comment) . I've also added a row including DELETE + INSERT payload that we should review:

    |-|Read,Write|DELETE+INSERT|false|?|?|

    "false" if no match for DELETE.


    WAC ED says that server manages the association between resources and ACL resources so that applicable Authorization rules can be located (after effective-acl-resource) and evaluated. Let's pick on that: the backend, the WAC system, or something else needs to track that association. Conceptually similar to the "auth proxy" that Kjetil mentioned above but without tracking creates and deletes.

    https://github.com/solid/web-access-control-tests/issues/41#issuecomment-898295543 :

    Typically there is no ACL resource for a non-existing resource, but the WAC spec doesn't prohibit that. (If there is an ACL resource for a non-existing resource, server would apply that ACL resource and checks for accessTo).

    I'm curious to know how Solid servers + WAC implementations currently determine the effective-acl-resource.


    When an operation requests to create a resource as a member of a container resource

    How can the server know an HTTP request strictly entails a Create operation? Here are some examples (there may be others):

    Request Operation
    POST /C/ Create
    PUT /C/R + If-None-Match Create, Read
    PATCH /C/R + If-None-Match + INSERT in message body Create, Read

    Edit: See table WIP at #85 (comment) for reference.


    A WAC system cannot tell for a given PUT or PATCH request whether it is a creation by looking at the request itself. It has to go to the backend and check whether that resource exists.

    WAC doesn't need to. Server does (as per tables above). WAC is asked about [2] and [3]. That can be one or more queries.

    WAC can be implemented as a layer that either:
    returns 403 OR

    This means that, to make a decision, WAC only needs as input:
    the request

    Not strictly. For example - just to illustrate an idea for a possible implementation - the backend can send data about the collection hierarchy (or however collection hierarchy is determined) and the associated ACL resources. The WAC system somehow needs to know how a resource and its containers are connected, whether it is for example informed about slash semantics, checks for reverse relation from resource to its container, or something else. It also needs to be informed about (or keeps track of it) how resources and ACL resources are associated, which is required to determine the effective-acl-resource.

    For PUT /foo/bar/baz, WAC in context of Solid will/can get to know the following paths and the associated ACL resources (if any):

    /
    /foo/
    /foo/bar/
    /foo/bar/baz
    
    /.acl
    /foo/.acl
    /foo/bar/.acl
    /foo/bar/baz.acl
    

    WAC goes through the authorization-process, responds to the backend with allowed or denied:

    For PUT, it checks for Authorization rule with Write access on /foo/bar/baz and Append (or Write) access on closest container (heading towards the root container) with an associated ACL resource that has an Authorization rule with said permission.

    If allowed, backend determines if resource state is to be created or replaced, as well as any intermediate containers that needs to be created.

  6. csarven commented on Sep 5, 2021

    @csarven
    Member

    Again, the final status codes are determined by the server. For GET /C/R, the backend must:

    1: Check WAC for Read on /C/R.

    1a: If there is a matching Authorization rule (=server can check storage):
    1ai: If /C/R exists, return 200, otherwise return 404.

    1b: If there is no matching Authorization rule (=server does not need to check storage):
    1bi: Return 403.

    The backend may consider checking the following (in the same query with 1 above) as an alternative to 1b above:

    2: Check WAC for Read on /C/:

    2a: If there is a matching Authorization rule (=server does not need to check storage):
    2ai: Return 404.

    2b: If there is no matching Authorization rule (=server does not need to check storage):
    2bi: Return 403.

    Single query (snippet) below -- you'll have to excuse me as I'm probably getting the query wrong... it is Sunday night and I'm having sage tea, my own crop, fyi:

    SELECT ?authorizationA ?authorizationB
    WHERE {
      ?authorizationA
        acl:mode acl:Read ;
        acl:accessTo </C/R> ;
        acl:agent foo:#bar .
    
      OPTIONAL {
        ?authorizationB
          acl:mode acl:Read ;
          acl:accessTo </C/> ;
          acl:agent foo:#bar .
      }
    }
    

    Before I think through the other table rows, does the above bring us closer to a possible solution/perspective?

    I said one or more queries because I think a single ASK or a SELECT query (with desired cols, rows) will do, but since it is an implementation detail, multiple ASKs or SELECTs can also work.

    Marked with "Create?" because at some point the storage needs to be checked. It is not on WAC to know if resource exists. While I agree on the architecture to check access control before visiting the storage, I don't think an implementation choosing or perhaps even needing to visit the storage before and during with multiple trips makes it wrong - probably undesirable, inefficient, and things can potentially go wrong but it is still an implementation detail as far as the specs are concerned. Based on my understanding... but happy to be corrected on that or if there is an assumption somewhere that I'm not considering at the moment.

  7. csarven commented on Sep 5, 2021

    @csarven
    Member

    My mental model is a pipeline in which a request goes through the sequential stages:
    So once a request has left WAC stage, it cannot go back.

    I'm saying that's a fine implementation detail. I don't quite see how the spec prevents that possibility.

    You seem to be assuming an architecture in which some subsystem is asking questions to an ACL store and an LDP store.
    So the system you call "WAC" seems to be an ACL store to which you can ask questions; the system I call "WAC" is a processing stage which makes a decision: 401, 403, or PASS.

    Can you break it down for me as to what's wrong with the pseudocode I wrote above? I thought it showed exactly what you wanted. Check if required Authorization rule exists (=exit WAC), and check storage only when need to (=before HTTP response).

    For the WAC subsystem to decide whether it should return 403, it first needs to check whether the LDP system would have given a 404. We're instead interested to have a WAC subsystem whose decision for 403 is not influenced by LDP.

    I think that's a misinterpretation of the pseudocode above.

  8. acoburn commented on Sep 5, 2021

    @acoburn
    Member

    My mental model is a pipeline in which a request goes through the sequential stages:
    WAC: either returns 401/403 (skipping the next stage) or passes on to the next stage
    LDP: serves documents and returns status codes such as 2xx, 400, 404

    I approach this slightly differently.

    The key point I would make is that the WAC layer would not be responsible for producing a 403. (it may generate a 401)

    Rather, the WAC layer would be responsible only for identifying what operations a particular agent can perform on a particular resource. This stage might produce an array: [read, write, append]. But these do not need to correspond to the WAC modes. More likely they would be [read, create, write, append, delete] or [read, create, append] or a null set: [], indicating that the agent has no access. Either way, this is all internal impl detail: only the Pod server needs to understand it. Importantly, this is where you need to define things like: can the agent create a new resource (e.g. create) or merely add triples to an existing resource (e.g. append). Can the agent delete the resource?

    I would emphasize that the data at this stage is purely implementation detail.

    Once that data arrives at the pod server / HTTP layer, you can inspect conditional headers (If-Match, etc) or whether the intended resource exists or not (is this a create or update operation?). That is when the 403 would be returned on error or 200/201/204/etc on success.

    This structure will work with a completely externalized authorization server or with a single server that uses layers, as described above.

  9. kjetilk commented on Sep 6, 2021

    @kjetilk
    Member

    I think @RubenVerborgh and I share a mental model on this, since we worked this out in the early F2F while designing a NSS replacement. I think your design is very interesting, @acoburn , the reason why I/we (or whoever, don't remember) didn't further entertain that model was that it was perceived as a heavier than the approach taken by acl-check.js, which would return a boolean "authorized or not".

    Of course, there has always been some tension for our idea too, in particular around PATCH where the request body would have to be parsed. In your design, @acoburn , the authz evaluation could sit entirely within the authz component, and still let subsequent layers return the actual status codes.

    In practical terms, how much of a burden do you think this would put on other implementers, @acoburn ?

  10. acoburn commented on Sep 6, 2021

    @acoburn
    Member

    In practical terms, how much of a burden do you think this would put on other implementers?

    @kjetilk it is hard to say unequivocally whether a certain pattern puts too much burden on implementers. I would say that the model described by you and @RubenVerborgh has the advantage of being very straight-forward (I've implemented variations on that model numerous times, and it is certainly the one that is more obvious).

    One additional consideration, though, is the requirement for a WAC-Allow response header. For that, a server will need to know the modes for a given user (and the public user), which may require additional checks on the ACL layer (after a boolean access/no-access has been determined). By computing that access data once and then passing it down to the Pod layer, a server can avoid that additional check. Of course, if the impl translates ACL vocabulary terms into an internal data structure (e.g. [read, create, append]) that would need to be converted back to the standard WAC-Allow terms.

    In summary, I would say that there are advantages and disadvantages to both approaches. In my comment, I was mostly trying to point out that it is possible to construct a system where multiple round-trips are not required. Whether that model is desirable for a given implementation is very much dependent on context.

  11. 19 remaining items

  12. kjetilk commented on Oct 21, 2021

    @kjetilk
    Member

    For me, don't require Append on the container to create/update a resource for which a specific ACL already grants Write or Append.

    But if you do that, wouldn't that also be an argument to revert the decision in solid/specification#197 ?

  13. kjetilk commented on Oct 22, 2021

    @kjetilk
    Member

    OK.

    First of all, it is important that the status codes are derived, not decided, and that is important because I (for one) don't want to see the kind of incoherence we see in e.g. LDP.

    Therefore, I think it is important that all these things are derived from the same principles. I think we could consider not requiring write on the container for 0.9, I would want to have a principled approach to it for 1.0.

    Given that solid/specification#197 has been decided, I think it is a difficult thing to change though.

  14. changed the title [-]Proposed access rules cannot be implemented without roundtrips to the backend[/-] [+]Proposed access rules require authentication to know about backend or vice versa[/+] on Nov 1, 2021
  15. changed the title [-]Proposed access rules require authentication to know about backend or vice versa[/-] [+]Proposed access rules require coupling between authentication and backend in edge cases[/+] on Dec 1, 2021
  16. changed the title [-]Proposed access rules require coupling between authentication and backend in edge cases[/-] [+]Proposed access rules require coupling between authentication and backend to cover edge cases[/+] on Dec 1, 2021
  17. michielbdejong commented on Dec 24, 2021

    @michielbdejong
  18. michielbdejong commented on Dec 27, 2021

    @michielbdejong
  19. changed the title [-]Proposed access rules require coupling between authentication and backend to cover edge cases[/-] [+]Edge cases require all implementations to couple authorization and storage[/+] on Dec 30, 2021
  20. csarven commented on Feb 9, 2022

    @csarven
    Member

    @RubenVerborgh , it was explained that this is not a WAC bug and the label was removed - something you've agreed with: #97 (comment) - but I'm now noting that you've introduced the label without discussion.

  21. timbl commented on Feb 9, 2022

    @timbl

    Happy for this discussion to be moved to another issue. But while I am here I want to leave a short rant against false economies. Solid works well when the protocol allows powerful operations. If you shirk doing something like iterating over a path /a/b/c/d/e/f in the server in order to save milliseconds on the server, remember how it is orders of magnitude slower to force the client to iterate over them as each client iteration is an operation across the global internet and is limited at the end of the day by the speed of light, and can take seconds. That that the server creates intermediate directories automatically with a PATCH INSERT to a non-existing file is great speed-up, for which no amount of internal server optimization can compete.

    Another example - If by giving insufficient data about container contents to the client forcing it to iterate over the folder contents doing a HEAD, that's massively slower.

    In this case, if you you don't tell a client whether a potentially forbidden resource exists, only that it is forbidden, forcing the client to get the user to log in and retry with credentials to find actually it does not exist, that's not an optimization. (Yes it might be more secure but it is dysfunctional). So if giving better service to the client and the user involves running the Authorization function in parallel with the Storage function every time (for GET/HEAD) rather than starting the storage only of the auth gives an ok, maybe that makes solid a more useful platform. To make the server faster but less powerful would maybe be a false economy. For PATCH, clearly you can't do them in parallel, and maybe the corner cases are different, but still beware of false economies.

  22. timbl commented on Feb 9, 2022

    @timbl

    For comparison here is Google docs shows you a file which does not exist
    Screen Shot 2022-02-09 at 12 55 24
    :

    compared to one which does exist but you don't have access to:
    Screen Shot 2022-02-09 at 12 55 47

    The distinction is important. People expect it I think. It does provide an onboarding path with the protected document , but it does not waste user's time with the one which does not exist.

  23. csarven commented on Feb 10, 2022

    @csarven
    Member

    @RubenVerborgh solid/specification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions