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

ObjectMapperWrapper logging sensitive data on deserialisation errors #601

Open
jlous opened this issue Mar 30, 2023 · 3 comments
Open

ObjectMapperWrapper logging sensitive data on deserialisation errors #601

jlous opened this issue Mar 30, 2023 · 3 comments

Comments

@jlous
Copy link

jlous commented Mar 30, 2023

If ObjectMapperWrapper encounters a deserialisation error, it unconditionally dumps the entire json into the message of an IllegalArgumentException, which, if unexpected, will often make its way into the logs.

This is extremely ill-advised:
Json in the production database will often contain private or sensitive data that should not be accessible to everyone with access to the techincal logs.

Jackson does the same thing by default (although truncating the content a little), but it can at least be easily configured not to (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION)
But this is of little help when the library using it logs it again by itself.

Logback-level pattern-based masking is not suitable for redacting large and arbitrary jsob clobs.

Please provide a config to omit json-content from these errors, to limit data-leakage via logs.
Or maybe even better: drop it entirely, and leave content-logging it to the root-cause message from jackson, which is more informative about what is wrong anyway, even with content-quoting turned off.

@vladmihalcea
Copy link
Owner

vladmihalcea commented Mar 30, 2023

It's not the ObjectMapperWrapper printing those failures into the application log. That's your own app doing that.

The ObjectMapperWrapper only throws the Exception, so your application should decide what is the best way to handle that.

@vladmihalcea vladmihalcea changed the title Logs sensitive data on deserialisation errors ObjectMapperWrapper logging sensitive data on deserialisation errors Mar 30, 2023
@jlous
Copy link
Author

jlous commented Mar 30, 2023 via email

@vladmihalcea
Copy link
Owner

@jlous This is what Spring does when catching a JsonProcessingException.

So, here's what you'll have to do:

  1. Fork the project
  2. Change the ObjectMapperWrapper to use the strategy used by Spring
  3. Validate whether it's better for this use case
  4. Send me a Pull Request to review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants