-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Security roles checked after constraints validation with quarkus-resteasy-reactive #16897
Comments
@gwenneg Hi, what side-effects do you observe ? In both cases the end resultt should be the method is only being invoked if both security roles and constrains validation checks pass ? thanks |
I'm still in the middle of the migration and didn't have the occasion to use the app with I created this issue because I'm a bit concerned that security comes second. The problem could also be larger than the simple |
@gwenneg I see - as far as the test is concerned - it is a test problem since it is failing now because of the constraints check failing. The constraints check in itself has no side-effects (I hope, CC @gsmet ) so as long the method is protected all is safe - but I agree it would be better to run the sec check first - @geoand - hi, looks like an authorization filter priority is not taken into consideration ? |
Security checks should ALWAYS be executed first. Otherwise you expose your endpoint somehow. Obviously, it's not a big problem if your constraint is |
So the constraints check can have side-effects, they are not just checking the input values... |
@gsmet By the way - if the constraint validation exception can return information about the endpoint - it would be a CVE material. |
They are checking the input values but they can be business related anyway i.e. "@ValidOrderNumber" or whatever. People can implement their own constraints and you have absolutely no idea of what they will do with them. So you cannot assume they are entirely safe to execute before the security checks. |
Poorly written validation can also lead to DoS attacks. I wouldn't want that to be exposed before the security check is done. |
I haven't looked into it (and probably won't for the next few days as we have some public holidays here), but I would be surprised if that is the case as the TCK tests this extensively. |
Hey @geoand Enjoy the long weekend, I thought it was a JAX-RS filter but it is a CDI interceptor |
Aha, OK :) |
I had a quick look and what you are seeing is actually not caused by the interceptors at all - neither the validation interceptor nor the security interceptor get invoked at all. The code that results in HTTP 400 is: I think we have had this conversation somewhere before... The question is whether we should not return HTTP 400, but let the processing continue with a |
At the moment this is implemented as a CDI interceptor (this is not just a Resteasy Reactive thing, @RolesAllowed works on any CDI bean). We probably need to turn this into a handler, and push this up the chain and run it first thing after the pre-match interceptors. |
We could certainly do that, as it would run security before input is ever read |
Cool, this must be documented - will take care of it, thanks Stuart @stuartwdouglas for reminding about it |
I wonder if it makes sense to this sort of thing with other kinds of interceptors as well - like Caching for example |
This makes sure they are run before serialization. It also means that fully async checks will work as expected. Fixes quarkusio#16897 Fixes quarkusio#15935
This makes sure they are run before serialization. It also means that fully async checks will work as expected. Fixes quarkusio#16897 Fixes quarkusio#15935 (cherry picked from commit 51c4052)
Describe the bug
I noticed something weird while migrating a project from
quarkus-resteasy
toquarkus-resteasy-reactive
:quarkus-resteasy
, security roles are checked before constraints validation when the request content type is JSONquarkus-resteasy-reactive
, security roles are checked after constraints validation when the request content type is JSONThere's no difference between the two extensions when the content type is text.
Expected behavior
I would expect the same behavior with both versions of
quarkus-resteasy*
.Actual behavior
Different behavior.
To Reproduce
https://github.com/gwenneg/quarkus-resteasy-reactive-security
It contains two folders with the exact same code with one exception: the
quarkus-resteasy*
dependency.Steps to reproduce the behavior:
cd quarkus-resteasy
./mvnw clean test
> BUILD SUCCESScd quarkus-resteasy-reactive
./mvnw clean test
> BUILD FAILUREEnvironment (please complete the following information):
Output of
java -version
Quarkus version or git rev
1.13.3.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
The text was updated successfully, but these errors were encountered: