Open ghost opened 1 year ago
Seconding this request. 5xx errors should virtually never reveal unneeded details about the server-side exception.
You could accomplish this by creating an interceptor on the SERVER_PRE_PROCESS_OUTGOING_EXCEPTION
pointcut which logs the exception however you want, and rethrows something with a more generic message.
@jamesagnew I tried that but couldn't get it to work like I wanted at first. Before spending more time on it, I wanted to check with you whether the current implementation was intentional.
How do you feel about exposing arbitrary exception messages to the client?
Would it be an option to not send those by default?
I misconfigured my database credentials the other day and got an error back like this:
i.e. specifically this part:
I don't feel comfortable with such detailed exception details being disclosed to the client. To me, this feels like a case of CWE-209: Generation of Error Message Containing Sensitive Information.
I would rather have HAPI return a canned response a la "An unexpected error occurred" and the details being logged on the error-level to be picked up by Splunk or the like.
I tried implementing my own exception handling interceptor based on
ca.uhn.fhir.rest.server.interceptor.ExceptionHandlingInterceptor
but couldn't get it to work quite like I'd like. For example, I lost the nice browser formatting when an error was thrown, only getting rawapplication/fhir+json
responses back.To me personally, returning too much exception details to a client is a potential security issue, which is why I'd personally prefer showing canned error messages by default. If you think there's value in showing unhandled exception details, then it could be a configuration option that users should consciously decide to enable, but that shouldn't be the default (in my opinion).
I'd be happy to customize it myself, too, but couldn't find a straight-forward way to do that.
Is this achievable somehow? Has somebody already achieved something like that?