Skip to content

Fix AppSec/IAST context dropped when trace.propagation.behavior.extract=ignore/restart#11666

Draft
dougqh wants to merge 1 commit into
masterfrom
dougqh/fix-appsec-context-extract-ignore
Draft

Fix AppSec/IAST context dropped when trace.propagation.behavior.extract=ignore/restart#11666
dougqh wants to merge 1 commit into
masterfrom
dougqh/fix-appsec-context-extract-ignore

Conversation

@dougqh

@dougqh dougqh commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • With trace.propagation.behavior.extract=ignore or restart, CoreSpanBuilder.start nulls the remote TagContext parent before buildSpanContext reaches the instanceof TagContext branch that copies requestContextDataAppSec/requestContextDataIast into the DDSpanContext.
  • The DDSpanContext ends up with null AppSec context, causing every GatewayBridge callback to return NoopFlow.INSTANCE — silently bypassing WAF/RASP for all inbound requests in AppSec-enabled services configured to ignore distributed tracing extraction. IAST is similarly affected.
  • Fix: before the IGNORE/RESTART switch, promote AppSec/IAST data from the TagContext into the builder fields (builderRequestContextDataAppSec/builderRequestContextDataIast), which buildSpanContext applies after the parent is gone. Trace identifiers and sampling priority are still correctly dropped.

Test plan

  • CoreSpanBuilderTest.appSecContextPreservedFromTagContextWithIgnoreBehavior — asserts AppSec/IAST context survives extract=ignore
  • CoreSpanBuilderTest.appSecContextPreservedFromTagContextWithRestartBehavior — same for extract=restart
  • Run ./gradlew :dd-trace-core:test --tests "datadog.trace.core.CoreSpanBuilderTest.appSecContext*"

Fixes: APMSP-3198

tag: no release note
tag: ai generated

🤖 Generated with Claude Code

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/apm-reliability/dd-trace-java | spotless   View in Datadog   GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c6b6424 | Docs | Datadog PR Page | Give us feedback!

@dougqh dougqh added comp: asm iast Application Security Management (IAST) comp: asm waf Application Security Management (WAF) comp: context propagation Trace context propagation comp: core Tracer core tag: security Security related changes type: bug Bug report and fix labels Jun 17, 2026
@dougqh dougqh requested a review from cataphract June 17, 2026 15:16
@dd-octo-sts

dd-octo-sts Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.00 s 13.94 s [-0.4%; +1.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.91 s 13.07 s [-2.0%; -0.5%] (maybe better)
startup:petclinic:appsec:Agent 16.91 s 16.08 s [+0.7%; +9.7%] (maybe worse)
startup:petclinic:iast:Agent 16.93 s 16.85 s [-0.3%; +1.3%] (no difference)
startup:petclinic:profiling:Agent 16.58 s 16.96 s [-3.2%; -1.3%] (significantly better)
startup:petclinic:sca:Agent 16.79 s 16.74 s [-0.7%; +1.2%] (no difference)
startup:petclinic:tracing:Agent 16.11 s 16.03 s [-0.4%; +1.4%] (no difference)

Commit: c6b6424d · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@dougqh dougqh force-pushed the dougqh/fix-appsec-context-extract-ignore branch from 2e5fe4c to 7480c60 Compare June 22, 2026 15:51
…ct=ignore/restart

With IGNORE or RESTART, CoreSpanBuilder nulls the remote TagContext parent before
buildSpanContext reaches the instanceof TagContext branch that copies
requestContextDataAppSec/requestContextDataIast. The AppSec context is lost and
GatewayBridge callbacks no-op, silently bypassing WAF/RASP for all inbound requests
in AppSec-enabled services configured to ignore distributed tracing extraction.

Fix: promote the AppSec/IAST data from the TagContext into the builder fields before
nulling the parent. The builder-field path in buildSpanContext applies these after
the parent is gone, preserving the request context while still correctly dropping
trace identifiers and sampling priority.

Fixes: APMSP-3198

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dougqh dougqh force-pushed the dougqh/fix-appsec-context-extract-ignore branch from 7480c60 to c6b6424 Compare June 22, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: asm iast Application Security Management (IAST) comp: asm waf Application Security Management (WAF) comp: context propagation Trace context propagation comp: core Tracer core tag: security Security related changes type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant