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

Fix security issue related to the inclusion of annotations on secured method parameters #5813

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private ResultHandle paramTypes(MethodCreator ctor, List<Type> parameters) {
ResultHandle result = ctor.newArray(String.class, ctor.load(parameters.size()));

for (int i = 0; i < parameters.size(); i++) {
ctor.writeArrayValue(result, i, ctor.load(parameters.get(i).toString()));
ctor.writeArrayValue(result, i, ctor.load(parameters.get(i).name().toString()));
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;

import io.quarkus.security.Authenticated;

Expand All @@ -25,6 +29,14 @@ public String forTesterOnly() {
return "forTesterOnly";
}

@GET
@RolesAllowed("tester")
@Path("forTesterOnlyWithMethodParamAnnotations")
public String forTesterOnlyWithMethodParamAnnotations(@Context SecurityContext ctx, @Context UriInfo uriInfo,
@Valid String message) {
return "forTesterOnlyWithMethodParamAnnotations";
}

@GET
@DenyAll
@Path("denied")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public void shouldRestrictAccessToSpecificRole() {
Optional.of("forTesterOnly"));
}

@Test
public void shouldRestrictAccessToSpecificRoleAndMethodParameterAnnotationsShouldntAffectAnything() {
String path = "/rbac-secured/forTesterOnlyWithMethodParamAnnotations";
assertForAnonymous(path, 401, Optional.empty());
assertStatusAndContent(RestAssured.given().auth().preemptive().basic("stuart", "test"), path, 403, Optional.empty());
assertStatusAndContent(RestAssured.given().auth().preemptive().basic("scott", "jb0ss"), path, 200,
Optional.of("forTesterOnlyWithMethodParamAnnotations"));
}

@Test
public void shouldFailToAccessForbidden() {
assertForAnonymous("/rbac-secured/denied", 401, Optional.empty());
Expand Down