-
Notifications
You must be signed in to change notification settings - Fork 93
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
Stop leaking exception information in errors #772
Comments
There's sometimes a difficult balance between security and usability. Maybe we should not generate the Or we could generate a |
In my opinion, the default config should follow the graphql specification and not include any extensions at all. |
I fully second that security goes first. Could you describe in more detail, what you consider a better alternative? |
I think implementing #299 (being able to add extensions yourself), and removing all default error codes and other error extensions would be my preferred alternative. No extensions should be added by the graphql implementation by default :) |
I agree that we should not show the error details in the extensions by default. I suggest we add a config to switch this feature on (like it is currently) and off, and making the default off. w.d.y.t ? |
Yes. I think that would be nice - as there might be some people relying on that functionality. |
Yea, so for those, it will be a breaking change (in the sense that they will have to add a config) but I think that is the correct default. I'll make a change a.s.a.p |
Another thing that I think is potentially dangerous is that the exception message is always exposed as the error message. Consider if the database would be down, and the exception would contain authentication information - that would then be leaked to the client. |
That can be controlled. By default, for RuntimeExceptions, it will show a generic server error message, and for Checked Exception, it will show the exception message. But that is configurable. See https://download.eclipse.org/microprofile/microprofile-graphql-1.0.4-RC1/microprofile-graphql-spec-1.0.4-RC1.html#_server_errors Note that the black/white list naming has changed and will be available in an upcoming MP version, but is already supported in SmallRye (use |
Ok, is there some standard convention that I am not aware of that says that checked exceptions should always be safe to show to the end-user? For example, I just got this:
That error message is neither secure nor helpful to the end-user. But perhaps this is a discussion to be had in the MP group? |
You can hide it if you prefer. Also note that you can use bean validation, that might give you a better message on validation |
@phillip-kruger ok, how would you do that in quarkus? I tried setting the 2 application.properties that I could think of:
And I still got the leaky error message above. |
There is no quarkus property for this (we can maybe add that). So the The |
Oh ok. So there is no way to hide all exception messages besides those that I whitelist? |
Well, checked exception is usually a fairly specific Exception that you throw, and are the only ones that show the message. You can try to add java.lang.Exception, I can not remember if this will include all subtypes. @t1 might remember. |
How about errors like this?
Not trying to be a pain in the ass, but I hope you see my point - plenty of internal error messages reaching the client and even if these are not dangerous to show there is no way to know if this is user friendly to show to the end-user, or if we should show some generic error message instead. |
That looks like errors from graphql-java ? We can maybe discuss to add those (validation) error to the hide list by default. But that will have to happen on spec (MicroProfile) level |
Also, try adding Bean validation to those methods. That might help... |
Can you share the full response of your example above ? What is the details in the extension ? |
I think me not having bean validation yet in this case helped to show a potential problem - that unexpected error messages are being sent :) Here is the full response:
It is likely that graphql-java is returning all sorts of error messages. I had to do this in my other code to make sure only the messages I trust are being sent:
|
^^^ Was trying to help you with a workaround This Error comes from graphql-java, so we would need a clean way to control these, and that does not exist at the moment. We would need to look into how we can make this extendable .... Thanks :) Maybe open a separate issue for this. (graphql-java errors) as this issue is for the extension switch as discussed earlier |
Ah yeah thanks - I appreciate the workaround 🙏 Isn't this a proper thread for this issue? I think the issue for extension switching is discussed in #299 |
I based it on: #772 (comment) I think we have multiple issues,
|
This convention is from the Jakarta EE tradition. Checked exceptions are considered to be application exceptions a.k.a. business exceptions, in contrast to technical exceptions. There is one famous exception to this rule: IOExceptions. But I hardly see checked exceptions being used any more... it's just too troublesome to pass them through several layers and they are generally not usable in functional APIs, e.g. Streams. You can show/hide messages by configuring a super class, so I think we can completely remove the Maybe we should just use the same config option pair to show/hide the message and Maybe we should rename the config options to What do you think? |
Yes I think that could make sense. |
I think there is still a valid case to make that even for Checked exceptions, we should not (by default) add the the stuff we do in extensions. The use should opt-in for this. I made a PR that will hide all our extensions by default, with the option to opt-in per field. |
It seems like the following extensions are added to errors by default:
I think this should be considered information leakage and improper error handling. See OWASP: https://owasp.org/www-community/Improper_Error_Handling
I think the @errorcode annotation is useful, because it lets GraphQL clients show actionable errors, but I think it is worth arguing that only very specific exceptions should have error codes. NPE is usually not something the end user can do anything about and should not have a code.
The text was updated successfully, but these errors were encountered: