Skip to content

Collect Datadog security-testing headers on HTTP server entry spans#11418

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
christophe-papazian/aap-collect-security-testing-headers
May 21, 2026
Merged

Collect Datadog security-testing headers on HTTP server entry spans#11418
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
christophe-papazian/aap-collect-security-testing-headers

Conversation

@christophe-papazian

Copy link
Copy Markdown
Contributor

APPSEC-64531

Tags x-datadog-endpoint-scan and x-datadog-security-test HTTP request headers
on every HTTP server entry span as http.request.headers.<name>, unconditionally
— independent of DD_TRACE_HEADER_TAGS and AppSec enablement.

These markers let the API endpoint reducer distinguish Datadog scan/test traffic
from real user traffic and keep it out of the API inventory. They are not
propagated downstream: Java's propagator injects only DDSpanContext, not
arbitrary span tags.

When an inferred proxy span is the local root, the markers are forwarded from
the service-entry span at finish time (matching the Node.js implementation).

Test plan

  • 8 unit tests in HttpServerDecoratorSecurityTestingHeadersTest (new, JUnit 5)
  • 1 unit test in InferredProxySpanTests for inferred-proxy forwarding
  • Existing HttpServerDecoratorTest (Groovy) passes — no regression

🤖 Generated with Claude Code

Tags x-datadog-endpoint-scan and x-datadog-security-test as
http.request.headers.<name> on every HTTP server entry span,
unconditionally (independent of DD_TRACE_HEADER_TAGS and AppSec).
When an inferred proxy span is the local root, the markers are
forwarded from the service-entry span at finish time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@datadog-datadog-prod-us1

This comment has been minimized.

christophe-papazian and others added 2 commits May 20, 2026 10:31
Address PR review nit: replace two near-identical anonymous
HttpServerDecorator subclasses with one helper that takes the
ContextVisitor as a parameter.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@christophe-papazian christophe-papazian marked this pull request as ready for review May 20, 2026 08:45
@christophe-papazian christophe-papazian requested review from a team as code owners May 20, 2026 08:45
@christophe-papazian christophe-papazian requested review from claponcet, manuel-alvarez-alvarez, mtoffl01 and vandonr and removed request for a team May 20, 2026 08:45
@dd-octo-sts dd-octo-sts Bot added the tag: ai generated Largely based on code generated by an AI or LLM label May 20, 2026
@dd-octo-sts

dd-octo-sts Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@christophe-papazian christophe-papazian added comp: asm waf Application Security Management (WAF) type: enhancement Enhancements and improvements labels May 20, 2026

@manuel-alvarez-alvarez manuel-alvarez-alvarez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the follow up to use getRequestHeader when ready.

@vandonr vandonr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@christophe-papazian christophe-papazian added this pull request to the merge queue May 21, 2026
@dd-octo-sts

dd-octo-sts Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented May 21, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-05-21 09:57:01 UTC ℹ️ Start processing command /merge


2026-05-21 09:57:05 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-21 11:57:27 UTCMergeQueue: The build pipeline has timeout

The merge request has been interrupted because the build 1695803771668047523 took longer than expected. The current limit for the base branch 'master' is 120 minutes.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 21, 2026
@christophe-papazian christophe-papazian added this pull request to the merge queue May 21, 2026
@dd-octo-sts

dd-octo-sts Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented May 21, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-05-21 11:58:56 UTC ℹ️ Start processing command /merge


2026-05-21 11:59:02 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-21 13:12:00 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 21, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit f934d48 into master May 21, 2026
571 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the christophe-papazian/aap-collect-security-testing-headers branch May 21, 2026 13:11
@github-actions github-actions Bot added this to the 1.63.0 milestone May 21, 2026
christophe-papazian added a commit to DataDog/dd-trace-dotnet that referenced this pull request May 27, 2026
…ry spans (#8682)

## Summary of changes

Tag `x-datadog-endpoint-scan` and `x-datadog-security-test` HTTP request
headers as `http.request.headers.<name>` on every HTTP server entry span
(and the inferred-proxy span when one is created), unconditionally —
independent of `DD_TRACE_HEADER_TAGS` and AppSec enablement. Markers are
not propagated downstream.

## Reason for change

APPSEC-65483 — RFC ["Security Testing: Trace Attribution for Inventory
Enrichment and Pollution
Prevention"](https://docs.google.com/document/d/1uR4QQvU8pItEV2zFqr3-L6jO2jxzmvLrFTX_yyvqIOA).
These two markers let the API endpoint reducer distinguish Datadog
scan/test traffic from real user traffic and keep it out of the API
inventory.

Sibling-tracer implementations already merged:
[`dd-trace-py#18049`](DataDog/dd-trace-py#18049),
[`dd-trace-js#8463`](DataDog/dd-trace-js#8463),
[`dd-trace-java#11418`](DataDog/dd-trace-java#11418).

## Implementation details

- New `SpanContextPropagator.AddSecurityTestingHeadersAsTags<THeaders>`
reads both markers from any `IHeadersCollection` and tags them on the
supplied span. Tag names are precomputed; `string[]` fast-path avoids
enumerator allocation on the legacy `NameValueCollection` /
`WebHeaderCollection` carriers; presence-based (empty values still
tagged).
- Wired into every HTTP server entry path:
- `AspNetMvcIntegration` (System.Web MVC) — entry span + inferred-proxy
span (proxy tagged at creation site)
- `AspNetWebApi2Integration` (System.Web Web API 2) — entry span (no
proxy support on this path)
- `TracingHttpModule` (OWIN/IIS classic) — entry span + inferred-proxy
span
- `AspNetCoreHttpRequestHandler` (ASP.NET Core, including Azure
Functions isolated worker HTTP-proxying mode) — entry span +
inferred-proxy span
  - `WcfCommon` (WCF over HTTP) — entry span

## Test coverage

- `SpanContextPropagatorTests_AddSecurityTestingHeadersAsTags` (new — 13
cases): both markers + unrelated header, absent headers, no `HeaderTags`
config, only one marker present, empty-string value still tagged,
case-insensitive lookup, ASP.NET Core `HeadersCollectionAdapter` with
mixed-case lookup.
- All existing `SpanContextPropagatorTests*` continue to pass.

## Other details

<!-- Fixes #{issue} -->

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: asm waf Application Security Management (WAF) tag: ai generated Largely based on code generated by an AI or LLM type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants