APMSP-3552 Redact sensitive data in DI log-probe messages - #6155
APMSP-3552 Redact sensitive data in DI log-probe messages#6155p-datadog wants to merge 6 commits into
Conversation
serialize_value_for_message rendered EL expression results into log-probe
messages without consulting the Redactor, so a template referencing an
object or hash (e.g. {user}, {params}) interpolated every instance
variable and hash entry verbatim. Identifiers on the redaction list
(@password, @api_key, session-key, ...) and values of redacted types were
emitted in plaintext to the debugger intake, even though the snapshot path
(serialize_value) redacts them.
Gate the message path the same way as the snapshot path: redact by type at
entry, and replace hash-entry and instance-variable values whose name
matches a redacted identifier with a [redacted] placeholder.
Typing analysisNote: Ignored files are excluded from the next sections.
|
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Updates Dynamic Instrumentation’s log-probe message serialization to apply the same redaction decisions already used for snapshot capture, preventing message templates from leaking sensitive values by explicitly referencing them.
Changes:
- Add a dedicated
[redacted]placeholder for log-probe message serialization. - Redact message output when a value’s type matches redaction configuration.
- Redact message output for Hash values / object instance variables when the identifier matches redaction configuration.
- Add unit test cases covering redaction behavior in
#serialize_value_for_message.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/datadog/di/serializer.rb | Adds message-path redaction logic for redacted types and identifiers in serialize_value_for_message. |
| spec/datadog/di/serializer_spec.rb | Adds unit coverage for redaction behavior in message serialization. |
| sig/datadog/di/serializer.rbs | Exposes the new REDACTED_VALUE_FOR_MESSAGE constant in the RBS signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a9189c268
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: c0328cc | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-08-05 23:50:45 Comparing candidate commit c0328cc in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 1 unstable metrics.
|
serialize_value_for_message only redacted values discovered while walking
a structure (redacted types, hash keys, instance-variable names). A template
that referenced a redacted identifier directly ({password}, {@password},
{obj.password}, {hash['password']}) still emitted the plaintext value,
whereas the snapshot path redacts the equivalently-named local/ivar/key.
Thread the referenced identifier from each template segment through to the
serializer: Compiler#redaction_identifier returns the top-level referenced
name (ref/iref var, getmember field, index string key), Expression carries
it, and serialize_value_for_message redacts when that name is a redacted
identifier -- mirroring serialize_value on the snapshot path.
Verified: bundle exec rspec on serializer, compiler, probe_builder and
probe_notification_builder specs (new cases pass). Steep not run (tooling
gemfile targets Ruby 3.4/4.0; this container is 3.2).
…e messages
Address review comments (Copilot, codex): serialize_value_for_message ran
redactor.redact_identifier?(key) on every hash key. redact_identifier? sends
the key through Redactor#normalize, which calls #to_s. For non-String/Symbol
keys this invokes customer-defined #to_s -- running customer code (which DI
must not do) and, when #to_s raises, turning the whole message into a
serialization error.
Only String/Symbol keys can name a redacted identifier, so guard the check on
key type. Redaction for String/Symbol keys is unchanged; the value under a
non-String/Symbol key is still type-redacted when serialized.
- Fixed in lib/datadog/di/serializer.rb (hash-key branch of
serialize_value_for_message)
- Added coverage in spec/datadog/di/serializer_spec.rb: a hash whose key is a
non-String/Symbol object with a raising #to_s now serializes as
"{... => value}" without invoking #to_s
Verified: bundle exec rspec on serializer, probe_notification_builder, compiler
and probe_builder specs (libdatadog_api compiled) -- 219 examples, 0 failures.
What does this PR do?
Redacts DI log probe messages the same way that the values are redacted in snapshots.
Motivation:
Currently it is possible to bypass value redaction by explicitly referencing values in the message template.
The behavior of most tracers is to redact in messages also. This PR makes Ruby aligned with the majority of tracers.
Change log entry
Yes. Dynamic Instrumentation now redacts sensitive identifiers and types in log probe messages, matching the redaction already applied to captured snapshots.
How to test the change?
Unit tests added.