-
Notifications
You must be signed in to change notification settings - Fork 896
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
db.statement sanitization default behavior #3104
Comments
I would expect the default behavior would be not to present sensitive data. (in js-contrib, redis instrumentation, has a default serializer that returns only the non-sensitive data: and in mongo db we have the same behavior: (https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts#L606). |
I agree that sanitizing the queries and other sensitive data by default would be a good idea. People can always choose to send the raw query if there's a config option for it. In most cases sending unsanitized queries will likely leak PII data out to other systems. Something that could put companies and people in some legal trouble and open them up for security headaches. Providing developers with config options to sanitize queries is good, but since it is not the default and configured by the user it may be less well tested and not cover all cases, or be forgotten when the instrumentation is added. We make sure that anything we detect as an SQL queries is run through our own sql_lexer library to sanitize them before their send to our servers. But we can't do that for everything, like Redis queries, and it would be best to put the query sanitization in the instrumentation packages itself. |
I think it should be default sanitized and mentioned explicitly. Instead of removing db.statement attribute completely, can we set its value to "sanitized"? That way users can differentiate between empty statements/lack of instrumentation/sanitization. |
I wouldn't say it needs to always remove the attribute to sanitize, or replace the value in its entirety. If the instrumentation package can store a sanitized version, that would still be helpful to any person who views the span data. For example, a sanitized SQL query could look like this |
Btw OTel Java does this at this moment. Maybe it would be helpful to replicate this behavior in other languages, sharing the parsing rules? See this Java-infused Lex definition: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation-api-semconv/src/main/jflex/SqlSanitizer.jflex |
Related thing. I think that if the instrumentation library does not sanitize the I know that some security engineers would even say that emitting |
Update the Redis instrumentation library to not change the default behavior for the Redis instrumentation. This can be enabled at a later time when the spec discussion about this topic has concluded. open-telemetry/opentelemetry-specification#3104
+1 in favor of sanitizing by default or omitting if the instrumentation (or library) does not support it. We offer options in the Ruby instrumentations of It would be great to have standard option names and reduce the likelihood of accidentally exporting sensitive data. |
* Add Redis instrumentation query sanitization Add a query sanitizer to the Redis instrumentation. This can be disabled with the `sanitize_query = False` config option. Given the query `SET key value`, the sanitized query becomes `SET ? ?`. Both the keys and values are sanitized, as both can contain PII data. The Redis queries are sanitized by default. This changes the default behavior of this instrumentation. Previously it reported unsanitized Redis queries. This was previously discussed in the previous implementation of this PR in PR #1571 Closes #1548 * Update Redis sanitize_query option documentation Changes suggested in #1572 (comment) * Remove uninstrument & instrument from test setup The Redis test that performs the tests with the default options, doesn't need to uninstrument and then instrument the instrumentor. This commit removes the unnecessary setup code. The setup code is already present at the top of the file. * Fix code style formatting * Update Redis functional tests - Update the sanitizer to also account for a max `db.statement` attribute value length. No longer than 1000 characters. - Update the functional tests to assume the queries are sanitized by default. - Add new tests that test the behavior with sanitization turned off. Only for the tests in the first test class. I don't think it's needed to duplicate this test for the clustered and async setup combinations. * Test Redis unsanitized queries by default Change the Redis functional tests so that they test the unsanitized query by default, and test the sanitized query results in the separate test functions. This is a partial revert of the previous commit 8d56c2f * Fix formatting issue in Redis utils * Disable Redis query sanitization by default Update the Redis instrumentation library to not change the default behavior for the Redis instrumentation. This can be enabled at a later time when the spec discussion about this topic has concluded. open-telemetry/opentelemetry-specification#3104 * Fix pylint issue Remove else statement. * Update changelog about Redis query sanitization default [ci skip] Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com> * Fix potential error on Redis args being 0 Check the length of the args array and return an empty string if there are no args. That way it won't cause an IndexError if the args array is empty and it tries to fetch the first element, which should be the Redis command. --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Also +1 for sanitizing by default and ommiting if theres no support/implementation for it by the instrumentation. The Go instrumentation for MongoDB doesn't sanitize the query, I had to warn another team at work about it because they deal with sensitive data and was about to migrate to open telemetry. |
This is a huge red flag for capturing db statements by default in tracing data, surely? Trying to learn more about this behaviour currently, but I'm seeing our DynamoDB payload being captured in tracing span data (db.statement) when using the AWS ADOT collector for lambda out of the box (nodeJS). Is there an easy way/environment var to stop this behaviour? I'd previously seen Datadog was doing something similar with their python dd-trace, but they quickly patched this when I highlighted it. Any pointers appreciated, will keep investigating EDIT: I guess the best thing to do here is have custom processors which delete/hash known attributes that could contain sensitive data? An environment var to do this also would be nice, but can’t see that. |
Also +1 |
From the spec triage meeting: Accepting this one in retrospect as it looks like there's agreement to move forward as per the discussion on the PR. |
What are you trying to achieve?
According to the db spec:
It does not strictly describes what should be the default behavior - sanitize the data, or not?
I am thinking that this approach might be risky, because of several cases:
I am suggestion that the spec should clarify what should be the default behavior regarding sanitization.
Additional context.
This issue is talking about missing examples, which might also clarify the behavior
The text was updated successfully, but these errors were encountered: