Skip to content
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

Path-matching HTTP Security policy should secure exact path matches for both present and missing ending path separator #37285

Closed
michalvavrik opened this issue Nov 23, 2023 · 1 comment · Fixed by #39012
Labels
area/security kind/enhancement New feature or request
Milestone

Comments

@michalvavrik
Copy link
Member

michalvavrik commented Nov 23, 2023

Describe the enhancement

For RESTEasy Reactive resource

@Path("/api/users")
public class UsersResource {

    @GET
    @Path("/me")
    @RolesAllowed("user")
    public User me() {
        return new User(identity);
    }
}

both HTTP request paths /api/users/me and /api/users/me/ will be matched, but exact path match quarkus.http.auth.permission.t1.paths=/api/users/me will only match /api/users/me. This seems natural and we document it here https://quarkus.io/version/main/guides/security-authorize-web-endpoints-reference#authorization-using-configuration in a Warning.

But as user, I don't necessary mention every single part of documentation and it doesn't struct me that when I want to secure resource method me I need to add 2 path patterns. I'd go as was as argue that most of the time when you add exact path matches you want to secure both paths.

Also I dare say I don't necessary test both /api/users/me and /api/users/me/.

There are 2 ways I can see to handle this:

  • @maxandersen mentioned that in Nginx you can use /api/users/me/? to secure both paths; In that case, we would change documentation to always use ending question mark and only document with proper warning once that when question mark is missing, one path is secured.
  • I suggest to secure both paths by default and only allow to override this security first approach with exclamation mark, like /api/users/me! would mean you really want to secure only one path. However that would be breaking change and I can't see it being accepted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security kind/enhancement New feature or request
Projects
None yet
1 participant