When an observability agent captures HTTP request bodies, sensitive data such as payment card numbers, email addresses, or patient details can enter traces before it is redacted. If those traces reach an observability backend, the sensitive values may be stored and exposed to anyone with access to the data. eBPF PII masking helps prevent this by capturing plaintext at supported tracing hooks and sanitizing a separate copy before exporting it, without modifying the application’s traffic.
This guide explains how eBPF PII masking works, including how to choose the right hooks, inspect plaintext, and export sanitized events. You’ll also learn its limitations, how it compares with application-level, OpenTelemetry Collector, and proxy-based redaction, and how to deploy and audit masking controls in Kubernetes.
What Is eBPF PII Masking
eBPF PII masking uses programs running in the Linux kernel to identify and mask sensitive fields in telemetry captured at selected tracing hooks. The program reads a bounded copy of the available data, checks it against defined masking rules, and exports a record with matching values removed or replaced. The application’s original request or response remains unchanged.
eBPF provides a sandboxed execution environment inside the Linux kernel without requiring kernel modules. A user-space loader loads programs through the bpf() system call, and the kernel verifier checks memory access, execution paths, and other safety constraints before allowing them to run. The JIT compiler can then translate verified bytecode into native machine instructions for efficient execution. Programs attach to kernel or user-space events, while eBPF maps maintain state and transfer telemetry to collectors. Masking coverage depends on supported hooks, runtimes, permissions, and payload formats.
Beyond PII masking, eBPF supports runtime threat detection, deep packet inspection of supported cleartext traffic, and monitoring network activity for possible data exfiltration. These capabilities help identify suspicious processes and data transfers, while PII masking controls which sensitive values appear in captured telemetry.
How eBPF PII Masking Works
eBPF PII masking captures application data at a tracing hook, identifies sensitive values, and removes or replaces them in a separate telemetry copy. Depending on the payload format and implementation, redaction can happen inside the kernel or in a local user-space agent before telemetry reaches the observability backend.
Capturing Data at eBPF Tracing Hooks
eBPF programs attach to kernel events or user-space functions to inspect data as applications process it. The attachment point determines which data is available and whether it is readable or encrypted.
- Uprobes: Attach to user-space functions, including supported TLS library functions. They can capture application data before encryption or after decryption.
- Kprobes: Attach to kernel functions and can inspect syscall arguments and buffers. For applications that encrypt data in user space, socket buffers generally contain ciphertext.
- Tracepoints: Expose predefined kernel events, including syscall entry and exit. They provide a more stable attachment interface than arbitrary kernel-function probes but have similar limitations when inspecting TLS traffic.
- XDP and TC: Operate on network packets. They can inspect cleartext traffic but cannot identify HTTP fields within TLS-encrypted payloads.
An HTTPS request contains plaintext before the TLS library encrypts it. At the network layer, the same request appears as encrypted records. A probe attached to a supported TLS function can therefore access application data that packet-level hooks cannot inspect.
Accessing Plaintext with SSL/TLS Uprobes
TLS encrypts application data before transmission, but plaintext is available at certain TLS library functions. Uprobes can attach to these functions and read the buffers before encryption or after decryption without obtaining TLS private keys.
For OpenSSL, two functions provide useful attachment points:
SSL_write: At function entry, the second argument points to the plaintext buffer, and the third specifies its length. An uprobe can inspect the data before OpenSSL encrypts it.SSL_read: At function entry, the application supplies a destination buffer for decrypted data. A return probe can inspect the populated buffer, using the function’s return value to determine how many bytes were read.
At SSL_write, the eBPF program can retrieve the buffer pointer using PT_REGS_PARM2(ctx) and the requested length using PT_REGS_PARM3(ctx). For SSL_read, an entry probe saves the destination pointer in a map associated with the current thread. The return probe retrieves that pointer and uses PT_REGS_RC(ctx) to obtain the number of bytes returned.
These TLS tracing hooks expose plaintext at the encryption boundary, but they do not automatically identify sensitive fields. Coverage also depends on the TLS implementation. OpenSSL probes do not automatically cover applications using Go’s crypto/tls, BoringSSL, or other libraries with different binary layouts or attachment requirements. Tools such as eCapture support multiple TLS implementations through separate capture mechanisms.
Interpreting and Masking Sensitive Fields
After obtaining the buffer pointer, an eBPF program can use bpf_probe_read_user() to copy the available bytes into temporary storage. The masking logic must identify sensitive fields in that copy before constructing a telemetry record with those values removed or replaced.
The captured bytes are not always a complete, readable request. An HTTP message can span multiple TLS function calls, leaving a single buffer with only part of a field. HTTP/2 uses binary frames and HPACK-compressed headers, while gRPC commonly carries protobuf messages. These formats can require request reconstruction and protocol decoding before individual fields can be identified.
Masking can occur at two processing points:
- Kernel-side masking: The eBPF program scans a bounded copy for supported patterns or fields and replaces sensitive values before submitting the telemetry to a ring buffer. The program must be able to interpret the data within its execution and memory limits.
- User-space masking: The eBPF program transfers captured data to a local agent, which can reconstruct messages, decode supported formats, and apply redaction rules before exporting telemetry to the backend.
The eBPF verifier checks program execution and memory access. It requires loops to have verifiable bounds and restricts memory usage, limiting the parsing and matching logic that can run in the kernel. More complex operations, including reconstructing fragmented messages and decoding structured payloads, can be handled in user space.
Consider an HTTP request body containing an email address and payment card number:
With masking rules that recognize both fields, the telemetry copy could contain:
The application’s request remains unchanged. However, a rule that only detects 16 consecutive digits would leave the email address exposed. It could also miss card numbers containing separators or values split across capture buffers. Field-level masking depends on both the available data and the rules used to interpret it. If the necessary bytes are missing or the payload format is unsupported, the program cannot reliably identify every sensitive value.
Masking a Card Number Inside an eBPF Program
You can mask sensitive values inside an eBPF program before exporting them to a collector. For example, a uprobe attached to OpenSSL’s SSL_write can capture a plaintext record containing card=4111111111111111, replace the first 12 card digits in a separate copy, and leave the application’s original data unchanged.
The following BCC program validates the 21-byte record, checks that the card field contains 16 digits, and exports the masked value through a BPF ring buffer:
Save the code as mask_ssl_write.c. To attach it to the target OpenSSL process and read sanitized events, create a Python file named mask_loader.py in the same directory:
Replace 12345 with the target process ID and update the OpenSSL library path for your system. Run the loader with the necessary tracing permissions:
At SSL_write, the eBPF program copies the plaintext using bpf_probe_read_user(), validates the card field with bounded, unrolled loops, and replaces the first 12 digits before submitting the event to the ring buffer.
For the matching input, the collector receives:
The original application buffer remains unchanged. This example processes the specified fixed-length record; inputs that do not match its format are excluded from the ring-buffer output.
Exporting Sanitized Events with eBPF Maps
eBPF maps provide temporary storage and transfer events to user space. Per-CPU array maps can hold working buffers while the program processes captured data, while hash maps preserve information such as buffer pointers and thread identifiers between function entry and return probes. A BPF ring buffer transfers events to a user-space collector or processing agent, using shared storage across CPUs and preserving event reservation order. The program submits records through a helper such as bpf_ringbuf_output(), allowing a user-space process to consume them.
Whether the ring buffer carries sanitized or raw data depends on where masking occurs. With kernel-side masking, the program modifies the temporary copy before submitting it, so the collector receives sanitized records. With user-space masking, the ring buffer carries captured data to a local agent for reconstruction, decoding, and redaction before telemetry is exported to the backend. Sensitive bytes can therefore exist temporarily in the ring buffer and agent memory. For larger payloads, OpenTelemetry eBPF Instrumentation can transfer data through multiple ring-buffer events and reassemble it in user space, with HTTP payload capture support depending on the protocol and application runtime.
Incomplete capture and export failures affect which records reach the collector:
- Incomplete or fragmented data: A field may extend beyond the capture window or span multiple events. Without sufficient reconstruction, masking cannot reliably process the complete value.
- Unsupported formats: A parser cannot identify sensitive fields in data it does not understand.
- Ring-buffer exhaustion: If the buffer has insufficient capacity, an output operation fails without blocking, and the event is not delivered.
When redaction is required before export, the masking implementation must exclude payloads it cannot safely process rather than forward them unchanged. This prevents unsanitized data from passing through the export path, although omitted or dropped records create gaps in the collected telemetry.
Capabilities and Limits of eBPF PII Masking
eBPF PII masking can prevent selected sensitive values from reaching an observability backend without changing the application’s requests or responses. However, its coverage depends on which data the tracing hooks expose, the payload formats supported by the masking logic, and where redaction occurs. Capturing plaintext does not automatically mean every sensitive field can be identified.
What eBPF PII Masking Can Protect
When the captured data is available in a supported format, masking rules can remove entire fields, replace sensitive values, or exclude a payload while retaining the metadata needed for troubleshooting.
For example, an HTTP trace can retain its request method, route, status code, and duration while omitting an Authorization header or replacing a customer’s email address with [REDACTED]. Known field names and fixed byte patterns are easier to recognize than values whose meaning depends on the surrounding application data.
Kernel-side masking can handle supported patterns within a bounded capture window. More complex field-level redaction can run in a local user-space processor that reconstructs requests and interprets structured data. OpenTelemetry eBPF Instrumentation, for example, supports rules for obfuscating selected HTTP headers and JSON body fields before attaching them to spans.
The masking rules determine which fields are protected. They do not automatically recognize every type of personal, financial, or authentication data present in a captured request.
Where eBPF Masking Has Limited Coverage
A masking program can only process data it captures and understands. Several conditions limit that coverage:
- Attachment points and runtimes: TLS plaintext capture depends on the libraries, application runtimes, and function hooks supported by the sensor. A probe attached to OpenSSL functions does not automatically inspect an application using Go’s
crypto/tlsor another TLS implementation. - Payload formats: HTTP/2 framing, compressed headers, protobuf messages, and compressed bodies may require decoding before individual fields can be identified. Bounded byte-pattern checks cannot reliably recognize sensitive values inside formats they do not understand.
- Incomplete data: A capture window can end in the middle of a field, or a value can span multiple function calls. A matcher operating on only one fragment may miss the complete value.
- Other telemetry sources: Sensitive information can also appear in application logs, manually instrumented spans, exception messages, and custom attributes. Masking data captured at eBPF hooks does not automatically sanitize these separate sources.
Complex matching also affects where redaction can run. The eBPF verifier restricts memory access and program execution, making bounded pattern checks more practical inside the kernel than general-purpose decoding and stateful parsing. Processing that requires reconstructing larger requests or maintaining protocol state is often handled in user space.
These limits mean that an observability sensor may capture enough information to identify a slow request without capturing or understanding every field in its body. Reliable PII masking depends on the coverage of the specific sensor, parser, and masking rules.
Why Telemetry Masking Does Not Modify Application Data
Observing, sanitizing, and enforcing are different eBPF capabilities. A tracing program can observe application data, while a masking program can modify a separate telemetry copy before it reaches the backend. Neither operation prevents the application from sending the original sensitive information to its destination.
eBPF can also enforce certain security decisions through BPF LSM programs, which attach to Linux Security Module hooks and can deny supported operations. Blocking an operation is not the same as redacting a field from a request or trace.
The bpf_probe_write_user() helper can modify a process’s user-space memory, but it is unsuitable for production security enforcement. The target memory can change between inspection and modification, writes can fail, and changing an application’s buffers can interfere with its execution.
Telemetry masking therefore leaves the application’s data unchanged and applies redaction to the observability copy. When masking occurs inside the kernel, the event can be sanitized before entering the ring buffer. When it occurs in a local user-space agent, raw data may exist in that agent’s memory before processing. Neither approach removes sensitive information from the application’s own memory, logs, or other telemetry paths.
eBPF PII Masking vs. Other Redaction Methods
Sensitive data can be removed inside the application, during eBPF capture, or in a telemetry processor. Where redaction occurs determines which systems handle raw values and what configuration is required.
For telemetry already emitted by applications or eBPF agents, the OpenTelemetry Collector can delete, replace, hash, or filter sensitive attributes using processors. Running the Collector locally allows redaction before forwarding telemetry to a remote backend. With a gateway Collector, unredacted data may cross the network before processing.
A proxy can inspect request contents when it receives plaintext. For HTTPS interception, this may require terminating TLS and configuring certificate trust, as with Cilium’s TLS inspection.
Compliance Requirements for Sensitive Trace Data
Redacting sensitive telemetry can help meet privacy and security requirements, but the rules depend on what information is collected and stored. GDPR, HIPAA, and PCI DSS do not require eBPF specifically.
- GDPR: Article 5(1)(c) requires personal data to be limited to what is necessary for its purpose. Removing unnecessary identifiers from traces supports data minimization. Replacing them with linkable tokens or hashes does not automatically take the data outside GDPR.
- HIPAA: The Safe Harbor method requires removal of 18 categories of identifiers, including names, email addresses, IP addresses, and certain dates, wherever they appear in a record. Masking a few known fields does not by itself establish de-identification. Expert Determination is a separate permitted method.
- PCI DSS: Requirement 3.4.1 covers masking payment account numbers when displayed, while Requirement 3.5.1 covers rendering stored PAN unreadable. Display masking is not equivalent to protecting stored PAN, including when payment data appears in stored traces or logs.
An eBPF masking rule only protects the telemetry it captures and processes. Compliance still depends on whether sensitive information remains in other traces, logs, storage systems, or application records.
Deploying and Auditing eBPF Masking in Kubernetes
An eBPF masking agent can run as a DaemonSet to observe supported workloads on each Kubernetes node. Loading tracing programs requires elevated permissions. On supported Linux kernels, these commonly include CAP_BPF and CAP_PERFMON, although additional permissions may be needed for particular hooks or process inspection.
Kubernetes Baseline and Restricted Pod Security policies do not permit adding these capabilities. The agent therefore needs an appropriate security-policy exception or deployment environment, with permissions limited to the operations it requires. Container seccomp settings and host access also affect which tracing operations are available.
Check the deployed masking controls for:
- Program inventory: Identify the loaded eBPF programs and their attachments using
bpftool. Match them against the approved agent deployment and expected hooks. - Redaction coverage: Use representative test values to verify that sensitive fields are removed before reaching the observability backend. Include truncated payloads, unsupported formats, and values split across buffers.
- Failure handling: Track capture failures, sanitization failures, and dropped events. If a payload cannot be safely processed, it must not be exported unchanged.
The following commands inspect loaded programs and active BPF links:
These commands provide program and link information, but they do not establish which masking rules are applied or prove that every sensitive field is protected. Some attachment types also require additional inspection.
For custom masking programs, BCC provides APIs for developing and attaching probes, while bpftrace helps inspect tracing hooks and bpftool lets you inspect loaded programs and maps. Other eBPF projects serve different purposes: Cilium provides Kubernetes networking and security, Hubble provides network-flow visibility, and Tetragon provides runtime security observability and enforcement. These tools do not automatically implement the application-field masking rules described here.
Audit evidence should connect the deployed programs, attachment points, masking-rule configuration, and test results. If redaction occurs in a local user-space agent, its raw-data buffers and processing path also need protection because sensitive values can exist there before sanitization.
How groundcover Protects Sensitive Observability Data
groundcover uses an eBPF sensor to collect traces from supported Kubernetes workloads without requiring application code changes. Its eBPF-based trace enrichment captures HTTP request and response payloads, headers, and query parameters. You can protect sensitive values in that telemetry through sensor-level obfuscation and OTTL trace-pipeline rules before storage.
Obfuscating Sensitive Data at the Sensor
groundcover obfuscates sensitive HTTP and gRPC headers by default, including Authorization, Cookie, and X-Api-Key. You can also configure payload and query obfuscation for supported protocols such as HTTP, gRPC, SQL, Redis, MongoDB, and AMQP.
For structured data such as JSON and query parameters, groundcover supports two obfuscation modes:
KeepSpecificValues: Masks all values except those associated with explicitly allowed keys.ObfuscateSpecificValues: Masks values associated with selected keys while retaining the remaining data.
You can also enable unstructured obfuscation for free-text payloads. These controls let you retain the request details needed for troubleshooting while masking sensitive values.
Redacting Traces with OTTL Rules
groundcover’s Traces Pipeline uses OpenTelemetry Transformation Language (OTTL) to modify request bodies, response bodies, headers, and span attributes. Rules run in the sensors before spans are forwarded to the backend, while traces sent directly to the groundcover-managed OTLP endpoint are processed at ingestion.
The obfuscate_pii function detects sensitive values such as email addresses, payment card numbers, and authentication tokens without requiring custom regular expressions. You can also use replace_pattern for custom patterns, delete_key to remove attributes, and obfuscate_matching_keys to mask values based on header or attribute names.
For example, this rule masks email addresses and payment card numbers in checkout request bodies:
The single-character * masks each detected byte while preserving its length and the surrounding JSON structure. You can apply similar rules to other supported fields, including sensitive content in AI agent traces, where prompts and responses may contain personal information.
Manage these rules through Settings > Data Pipelines > Traces Pipeline. You can simulate standard transformations against sample spans and validate sensor-side PII obfuscation with non-production test traffic. groundcover Agent can also generate OTTL rules from natural-language instructions, such as “mask emails in request bodies.”
Keeping Trace Data in Your Cloud with BYOC
With groundcover’s Bring Your Own Cloud (BYOC) architecture, telemetry ingestion, processing, and storage run in your own cloud environment. The eBPF sensors collect telemetry in your monitored clusters, while the observability backend operates within your cloud account.
Your traces remain in your environment rather than being stored in a third-party observability backend. The managed control plane stays separate from the telemetry data plane, allowing you to maintain security controls over telemetry storage, access, and retention.
FAQs
Yes, when supported tracing hooks expose plaintext before encryption or after decryption. HTTPS payloads can be inspected through TLS library uprobes, while gRPC requires additional protocol decoding. Since gRPC commonly uses protobuf, identifying individual fields may require the message schema. Coverage depends on the runtime, TLS implementation, and parser.
Masking hides part or all of a value, while redaction removes or replaces sensitive content. Pseudonymization substitutes identifiers while retaining a means of linking them to individuals. Anonymization makes individuals no longer identifiable. Masking or pseudonymizing fields does not automatically anonymize an entire trace.
eBPF programs can implement bounded pattern matching, but general-purpose regex processing is difficult to run inside the kernel because of verifier and execution constraints. Complex regular expressions and structured payload parsing are better handled in user space. Groundcover’s replace_pattern function, for example, supports custom regex-based masking in its trace pipeline.
A failed masking operation does not necessarily discard the captured event. If unprocessed data must never be exported, configure the pipeline to remove the affected payload or drop the span instead of forwarding it unchanged. Test failure cases involving malformed payloads, missing fields, and unsupported formats.
Send test requests containing known email addresses, payment card numbers, and other sensitive values through the supported application paths. Inspect the resulting telemetry at the export destination and confirm that the values are absent or masked. Test truncated and fragmented payloads as well as normal requests.
In groundcover, you can simulate standard OTTL transformations against sample spans. For sensor-side PII obfuscation, use non-production test traffic and check that the captured traces contain masked values.
No. Trace-pipeline changes apply to newly processed spans, not data already stored. If historical traces contain sensitive values, address them separately through the applicable retention, deletion, and access-control procedures.
Kernel-side masking can reduce data transfers and user-space processing by sanitizing events before export. It avoids forwarding every captured payload to a separate processor for redaction. However, eBPF tracing still consumes CPU, and actual performance depends on the attachment points, request volume, and masking complexity.





