Skip to content

No Redaction of Numeric Attribute Values in the OpenTelemetry Collector #36684

@Tiberius202

Description

@Tiberius202

Component(s)

processor/redaction

What happened?

Description

The redaction processor does not redact attributes that are numbers.

For instance, consider the following example where two spans are sent for processing:

./otel-cli span -s my-service --attrs app.dummy="4111111111111"
./otel-cli span -s my-service --attrs app.dummy="VISA 4111111111111"

In this case, the redaction processor only redacts the second span's attribute value, leaving the first one untouched.

This is a follow up to this stale issue
#26348

Steps to Reproduce

  1. Set up the OpenTelemetry Collector with the provided configuration for the redaction processor.
  redaction:
    allow_all_keys: true
    blocked_values:
      - "4[0-9]{12}(?:[0-9]{3})?" ## Visa credit card number
  1. Generate spans with attributes containing numeric values, such as credit card numbers.
otel-cli span --endpoint 127.0.0.1:4317 --protocol grpc --insecure true -s my-service --attrs app.dummy="4111111111111"
otel-cli span --endpoint 127.0.0.1:4317 --protocol grpc --insecure true -s my-service --attrs app.dummy="VISA 4111111111111"

  1. Observe that the redaction regex does not properly match and redact numeric attribute values.
2024-12-04T15:26:25.089-0500    info    [email protected]/service.go:166 Setting up own telemetry...
2024-12-04T15:26:25.092-0500    info    telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"}
2024-12-04T15:26:25.096-0500    info    builders/builders.go:26 Development component. May change in the future.        {"kind": "exporter", "data_type": "traces", "name": "debug"}
2024-12-04T15:26:25.099-0500    info    [email protected]/service.go:238 Starting otelcol-contrib...     {"Version": "0.115.0", "NumCPU": 8}
2024-12-04T15:26:25.100-0500    info    extensions/extensions.go:39     Starting extensions...
2024-12-04T15:26:25.107-0500    warn    [email protected]/warning.go:40 Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks.       {"kind": 
"receiver", "name": "otlp", "data_type": "traces", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-att
acks"}
2024-12-04T15:26:25.107-0500    info    [email protected]/otlp.go:112       Starting GRPC server    {"kind": "receiver", "name": "otlp", "data_type": "traces", "endpoint": "0.0.0.0:4317"}
2024-12-04T15:26:25.107-0500    info    [email protected]/service.go:261 Everything is ready. Begin running and processing data.
2024-12-04T15:26:30.121-0500    info    Traces  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
2024-12-04T15:26:30.121-0500    info    todo-generate-default-span-names a4ba89b46bd31085a1485d43d41e78de 64826c6a258df964 app.dummy=4111111111111
        {"kind": "exporter", "data_type": "traces", "name": "debug"}
2024-12-04T15:26:30.191-0500    info    Traces  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
2024-12-04T15:26:30.191-0500    info    todo-generate-default-span-names 9f0f6a6039496915add1df61ae4d0341 230fa53949041e37 app.dummy=VISA ****
        {"kind": "exporter", "data_type": "traces", "name": "debug"}

Expected Result

The redaction processor should consistently match and redact attribute values that fit the specified regex patterns, including numeric values. The attribute app.dummy in the first span should be redacted as ****.

Actual Result

Currently, the redaction processor does not process numeric attribute values. The attribute app.dummy in the first span is revealed as 4111111111111.

Collector version

v0.115.1

Environment information

Environment

OS: Darwin_amd64
Compiler(if manually compiled): N/A. Pulled from https://github.com/open-telemetry/opentelemetry-collector-releases/releases/tag/v0.115.1

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317

processors:
  redaction:
    allow_all_keys: true
    blocked_values:
      - "4[0-9]{12}(?:[0-9]{3})?" ## Visa credit card number

exporters:
  debug:
    verbosity: normal
  otlp:
    endpoint: 0.0.0.0:18443
    tls:
      insecure: true
    compression: none
    sending_queue:
      queue_size: 50

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [redaction]
      exporters: [otlp, debug]

Log output

2024-12-04T15:26:25.089-0500    info    [email protected]/service.go:166 Setting up own telemetry...
2024-12-04T15:26:25.092-0500    info    telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"}
2024-12-04T15:26:25.096-0500    info    builders/builders.go:26 Development component. May change in the future.        {"kind": "exporter", "data_type": "traces", "name": "debug"}
2024-12-04T15:26:25.099-0500    info    [email protected]/service.go:238 Starting otelcol-contrib...     {"Version": "0.115.0", "NumCPU": 8}
2024-12-04T15:26:25.100-0500    info    extensions/extensions.go:39     Starting extensions...
2024-12-04T15:26:25.107-0500    warn    [email protected]/warning.go:40 Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks.       {"kind": 
"receiver", "name": "otlp", "data_type": "traces", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-att
acks"}
2024-12-04T15:26:25.107-0500    info    [email protected]/otlp.go:112       Starting GRPC server    {"kind": "receiver", "name": "otlp", "data_type": "traces", "endpoint": "0.0.0.0:4317"}
2024-12-04T15:26:25.107-0500    info    [email protected]/service.go:261 Everything is ready. Begin running and processing data.
2024-12-04T15:26:30.121-0500    info    Traces  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
2024-12-04T15:26:30.121-0500    info    todo-generate-default-span-names a4ba89b46bd31085a1485d43d41e78de 64826c6a258df964 app.dummy=4111111111111
        {"kind": "exporter", "data_type": "traces", "name": "debug"}
2024-12-04T15:26:30.191-0500    info    Traces  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
2024-12-04T15:26:30.191-0500    info    todo-generate-default-span-names 9f0f6a6039496915add1df61ae4d0341 230fa53949041e37 app.dummy=VISA ****
        {"kind": "exporter", "data_type": "traces", "name": "debug"}

Additional context

#26348

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/redactionprocessor/processor.go#L190

This line uses the Str, but perhaps should use AsString in order to detect when a number should be redacted. There was a worry that this would change the type of the data, but this could be mitagited by replacing the number with 0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions