Skip to content

[ASM] Consolidate ASP.NET Core WAF scans and harden request-phase cov…#8856

Draft
daniel-romano-DD wants to merge 6 commits into
masterfrom
dani/aap/waf_call_refactor
Draft

[ASM] Consolidate ASP.NET Core WAF scans and harden request-phase cov…#8856
daniel-romano-DD wants to merge 6 commits into
masterfrom
dani/aap/waf_call_refactor

Conversation

@daniel-romano-DD

Copy link
Copy Markdown
Contributor

…erage

Consolidate the scattered ASP.NET Core WAF calls (basic request scan, path params, request/response body) into a single request-phase scan (RunRequestScan) plus the existing response-phase scan (CheckReturnedHeaders), keeping the WAF to two runs per request on the happy path.

Hardening on top of the consolidation:

  • Close the short-circuit coverage gap: when the request-phase scan never ran (e.g. an MVC request short-circuited by an authorization/resource filter before ActionResponseFilter.OnActionExecuting, with no end-pipeline fallback), fold the basic request addresses into the response-phase call so request rules still evaluate and can still block.
  • Make RunRequestScan idempotent via RequestScanCompleted so it is safe to call from more than one hook (non-MVC route event and MVC/Razor action filter).
  • Resolve the local-root span in ActionResponseFilter (InternalActiveScope.Root), consistent with FireOnStartCommon, instead of the innermost active scope.
  • End-pipeline 404 fallback marks RequestScanCompleted to avoid the response-phase scan redundantly re-adding the basic request addresses.

Summary of changes

Reason for change

Implementation details

Test coverage

Other details

@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8856) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration73.01 ± (72.90 - 73.41) ms71.60 ± (71.52 - 72.11) ms-1.9%
.NET Framework 4.8 - Bailout
duration75.22 ± (75.11 - 75.57) ms73.35 ± (73.53 - 73.96) ms-2.5%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1077.09 ± (1075.44 - 1083.65) ms1077.78 ± (1080.02 - 1086.62) ms+0.1%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.36 ± (22.30 - 22.41) ms22.26 ± (22.21 - 22.31) ms-0.4%
process.time_to_main_ms82.21 ± (81.92 - 82.51) ms81.57 ± (81.26 - 81.88) ms-0.8%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.85 ± (10.85 - 10.86) MB10.90 ± (10.90 - 10.91) MB+0.5%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.18 ± (22.14 - 22.23) ms22.06 ± (22.03 - 22.09) ms-0.6%
process.time_to_main_ms82.99 ± (82.74 - 83.23) ms81.32 ± (81.21 - 81.43) ms-2.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.95 - 10.96) MB10.93 ± (10.93 - 10.94) MB-0.2%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms208.95 ± (208.07 - 209.84) ms209.61 ± (208.82 - 210.41) ms+0.3%✅⬆️
process.time_to_main_ms528.75 ± (527.35 - 530.16) ms529.79 ± (528.59 - 530.99) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.67 ± (48.62 - 48.71) MB49.11 ± (49.07 - 49.14) MB+0.9%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.7%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms21.02 ± (20.98 - 21.06) ms20.92 ± (20.88 - 20.95) ms-0.5%
process.time_to_main_ms70.43 ± (70.21 - 70.64) ms69.37 ± (69.23 - 69.50) ms-1.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.62) MB10.60 ± (10.60 - 10.61) MB-0.1%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.94 ± (20.91 - 20.96) ms21.11 ± (21.07 - 21.16) ms+0.8%✅⬆️
process.time_to_main_ms70.54 ± (70.44 - 70.64) ms72.62 ± (72.37 - 72.87) ms+2.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.75 ± (10.74 - 10.75) MB10.72 ± (10.72 - 10.73) MB-0.2%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms368.94 ± (366.69 - 371.20) ms373.37 ± (371.08 - 375.66) ms+1.2%✅⬆️
process.time_to_main_ms535.35 ± (534.20 - 536.50) ms532.93 ± (531.77 - 534.09) ms-0.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed50.11 ± (50.09 - 50.13) MB50.11 ± (50.09 - 50.14) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.2%
.NET 8 - Baseline
process.internal_duration_ms19.17 ± (19.14 - 19.20) ms19.14 ± (19.10 - 19.17) ms-0.2%
process.time_to_main_ms68.79 ± (68.67 - 68.92) ms69.60 ± (69.35 - 69.86) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.66 ± (7.66 - 7.67) MB7.66 ± (7.66 - 7.67) MB-0.0%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.34 ± (19.29 - 19.38) ms19.04 ± (19.00 - 19.07) ms-1.6%
process.time_to_main_ms72.70 ± (72.48 - 72.92) ms69.81 ± (69.71 - 69.90) ms-4.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.72) MB7.71 ± (7.71 - 7.72) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms300.30 ± (297.71 - 302.90) ms296.82 ± (294.76 - 298.89) ms-1.2%
process.time_to_main_ms483.06 ± (482.19 - 483.92) ms485.68 ± (484.61 - 486.75) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed37.10 ± (37.08 - 37.13) MB37.50 ± (37.47 - 37.53) MB+1.1%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.1%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration201.49 ± (201.30 - 202.21) ms204.75 ± (204.43 - 205.52) ms+1.6%✅⬆️
.NET Framework 4.8 - Bailout
duration205.91 ± (205.49 - 206.23) ms209.80 ± (209.15 - 210.11) ms+1.9%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1208.90 ± (1207.23 - 1213.30) ms1213.88 ± (1213.47 - 1219.80) ms+0.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms195.91 ± (195.49 - 196.33) ms195.33 ± (194.85 - 195.80) ms-0.3%
process.time_to_main_ms85.20 ± (84.92 - 85.49) ms84.76 ± (84.50 - 85.02) ms-0.5%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.12 ± (16.10 - 16.14) MB16.08 ± (16.05 - 16.10) MB-0.3%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.5%
.NET Core 3.1 - Bailout
process.internal_duration_ms196.18 ± (195.76 - 196.60) ms196.96 ± (196.50 - 197.42) ms+0.4%✅⬆️
process.time_to_main_ms86.85 ± (86.60 - 87.10) ms87.79 ± (87.59 - 87.98) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.13 ± (16.10 - 16.15) MB16.10 ± (16.07 - 16.12) MB-0.2%
runtime.dotnet.threads.count21 ± (20 - 21)21 ± (21 - 21)+0.4%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms391.03 ± (389.66 - 392.39) ms391.51 ± (390.06 - 392.96) ms+0.1%✅⬆️
process.time_to_main_ms544.50 ± (543.53 - 545.48) ms547.04 ± (545.93 - 548.16) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.58 ± (58.35 - 58.81) MB58.69 ± (58.46 - 58.92) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms201.11 ± (200.64 - 201.57) ms200.87 ± (200.43 - 201.31) ms-0.1%
process.time_to_main_ms74.17 ± (73.95 - 74.40) ms73.96 ± (73.71 - 74.21) ms-0.3%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.36 ± (16.34 - 16.38) MB16.34 ± (16.32 - 16.37) MB-0.1%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.5%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms199.25 ± (198.80 - 199.70) ms199.85 ± (199.41 - 200.30) ms+0.3%✅⬆️
process.time_to_main_ms74.63 ± (74.43 - 74.83) ms74.94 ± (74.70 - 75.17) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.44 ± (16.41 - 16.47) MB16.41 ± (16.38 - 16.44) MB-0.2%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.4%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms587.15 ± (584.74 - 589.57) ms583.18 ± (580.89 - 585.47) ms-0.7%
process.time_to_main_ms554.52 ± (553.50 - 555.55) ms556.82 ± (555.76 - 557.87) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed61.40 ± (61.31 - 61.49) MB61.30 ± (61.22 - 61.39) MB-0.2%
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)-0.3%
.NET 8 - Baseline
process.internal_duration_ms200.44 ± (200.02 - 200.85) ms200.38 ± (200.00 - 200.76) ms-0.0%
process.time_to_main_ms74.18 ± (73.92 - 74.44) ms74.12 ± (73.90 - 74.35) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.70 ± (11.68 - 11.72) MB11.68 ± (11.66 - 11.70) MB-0.2%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (18 - 19)-0.9%
.NET 8 - Bailout
process.internal_duration_ms200.29 ± (199.85 - 200.74) ms200.04 ± (199.67 - 200.41) ms-0.1%
process.time_to_main_ms75.44 ± (75.26 - 75.61) ms75.36 ± (75.15 - 75.56) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.76 ± (11.74 - 11.78) MB11.70 ± (11.68 - 11.72) MB-0.5%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms513.21 ± (510.39 - 516.03) ms514.90 ± (512.15 - 517.65) ms+0.3%✅⬆️
process.time_to_main_ms503.53 ± (502.69 - 504.36) ms505.46 ± (504.62 - 506.30) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed50.92 ± (50.88 - 50.95) MB51.03 ± (50.99 - 51.08) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (29 - 30)-0.0%
Comparison explanation

Execution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (72ms)  : 67, 76
    master - mean (73ms)  : 70, 77

    section Bailout
    This PR (8856) - mean (74ms)  : 70, 77
    master - mean (75ms)  : 72, 79

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (1,083ms)  : 1037, 1130
    master - mean (1,080ms)  : 1032, 1127

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (111ms)  : 103, 118
    master - mean (112ms)  : 106, 117

    section Bailout
    This PR (8856) - mean (109ms)  : 108, 110
    master - mean (112ms)  : 107, 117

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (776ms)  : 751, 801
    master - mean (776ms)  : 749, 802

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (96ms)  : 93, 98
    master - mean (98ms)  : 92, 104

    section Bailout
    This PR (8856) - mean (100ms)  : 94, 106
    master - mean (97ms)  : 96, 99

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (934ms)  : 892, 975
    master - mean (934ms)  : 898, 970

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (96ms)  : 90, 101
    master - mean (95ms)  : 93, 98

    section Bailout
    This PR (8856) - mean (95ms)  : 94, 97
    master - mean (100ms)  : 95, 104

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (814ms)  : 775, 853
    master - mean (811ms)  : 770, 851

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (205ms)  : 199, 211
    master - mean (202ms)  : 197, 206

    section Bailout
    This PR (8856) - mean (210ms)  : 205, 214
    master - mean (206ms)  : 202, 209

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (1,217ms)  : 1172, 1261
    master - mean (1,210ms)  : 1166, 1255

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (290ms)  : 282, 298
    master - mean (291ms)  : 285, 298

    section Bailout
    This PR (8856) - mean (295ms)  : 289, 300
    master - mean (293ms)  : 288, 298

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (980ms)  : 960, 1000
    master - mean (977ms)  : 957, 998

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (284ms)  : 277, 290
    master - mean (284ms)  : 278, 291

    section Bailout
    This PR (8856) - mean (283ms)  : 278, 289
    master - mean (283ms)  : 276, 290

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (1,172ms)  : 1131, 1212
    master - mean (1,176ms)  : 1136, 1217

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8856) - mean (285ms)  : 279, 291
    master - mean (285ms)  : 278, 291

    section Bailout
    This PR (8856) - mean (286ms)  : 282, 291
    master - mean (286ms)  : 279, 293

    section CallTarget+Inlining+NGEN
    This PR (8856) - mean (1,051ms)  : 1010, 1093
    master - mean (1,046ms)  : 1004, 1088

Loading

@pr-commenter

pr-commenter Bot commented Jun 30, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-02 09:58:03

Comparing candidate commit 9b9d2cf in PR branch dani/aap/waf_call_refactor with baseline commit 7d4e607 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 72 metrics, 0 unstable metrics, 61 known flaky benchmarks, 65 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-5997.365op/s; -5522.766op/s] or [-7.111%; -6.548%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1

  • 🟥 throughput [-7393.029op/s; -5821.371op/s] or [-7.517%; -5.919%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+310.319ms; +317.359ms] or [+153.991%; +157.485%]
  • 🟥 throughput [-42.452op/s; -38.547op/s] or [-7.638%; -6.935%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 execution_time [+379.476ms; +380.430ms] or [+299.809%; +300.563%]
  • 🟩 throughput [+93.579op/s; +95.260op/s] or [+12.338%; +12.560%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+392.293ms; +395.863ms] or [+347.165%; +350.324%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+1.323KB; +1.324KB] or [+27.862%; +27.875%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟥 allocated_mem [+487 bytes; +488 bytes] or [+10.315%; +10.325%]
  • 🟩 execution_time [-15.282ms; -11.102ms] or [-7.137%; -5.185%]
  • 🟩 throughput [+7301.231op/s; +10102.830op/s] or [+5.329%; +7.374%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+1.288KB; +1.288KB] or [+27.843%; +27.854%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.323KB; +1.323KB] or [+107.037%; +107.053%]
  • 🟥 throughput [-271195.149op/s; -267726.570op/s] or [-27.690%; -27.336%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟥 allocated_mem [+487 bytes; +488 bytes] or [+39.863%; +39.872%]
  • 🟩 execution_time [-27.377ms; -22.518ms] or [-12.209%; -10.042%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 allocated_mem [+1.288KB; +1.288KB] or [+106.613%; +106.627%]
  • 🟥 throughput [-131565.640op/s; -115741.693op/s] or [-18.903%; -16.630%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0

  • 🟩 throughput [+8700.757op/s; +11639.024op/s] or [+5.536%; +7.406%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1

  • 🟩 throughput [+9579.751op/s; +12231.742op/s] or [+7.632%; +9.744%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 throughput [+463069.674op/s; +479131.539op/s] or [+15.441%; +15.976%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-19.376ms; -15.045ms] or [-8.932%; -6.935%]
  • 🟩 throughput [+179148.626op/s; +233156.702op/s] or [+7.111%; +9.255%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟥 execution_time [+299.813ms; +300.754ms] or [+149.807%; +150.276%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟥 execution_time [+299.567ms; +303.963ms] or [+151.072%; +153.289%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟥 execution_time [+297.745ms; +313.073ms] or [+149.981%; +157.702%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+295.389ms; +296.912ms] or [+145.083%; +145.832%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+295.632ms; +297.895ms] or [+144.524%; +145.630%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+299.524ms; +301.662ms] or [+149.702%; +150.770%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟥 execution_time [+24.495µs; +48.123µs] or [+7.820%; +15.363%]
  • 🟥 throughput [-446.044op/s; -247.236op/s] or [-13.905%; -7.707%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.926ms; +300.664ms] or [+149.694%; +150.062%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • unstable execution_time [+408.390ms; +419.300ms] or [+443.732%; +455.587%]
  • 🟩 throughput [+762.010op/s; +954.739op/s] or [+6.262%; +7.845%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • unstable execution_time [+296.868ms; +348.868ms] or [+225.409%; +264.892%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 allocated_mem [+2.938KB; +2.943KB] or [+5.219%; +5.229%]
  • unstable execution_time [+219.287ms; +301.115ms] or [+100.826%; +138.450%]
  • 🟥 throughput [-634.138op/s; -565.112op/s] or [-57.459%; -51.205%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • unstable execution_time [+206.994ms; +340.233ms] or [+88.212%; +144.993%]
  • 🟥 throughput [-672.236op/s; -588.556op/s] or [-44.838%; -39.257%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • unstable execution_time [+319.915ms; +340.995ms] or [+191.346%; +203.955%]
  • 🟥 throughput [-399.606op/s; -358.316op/s] or [-27.824%; -24.949%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-188.956µs; -128.293µs] or [-9.572%; -6.499%]
  • 🟩 throughput [+37.949op/s; +53.971op/s] or [+7.491%; +10.654%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1

  • 🟩 execution_time [-590.207µs; -214.397µs] or [-14.967%; -5.437%]
  • unstable throughput [+20.936op/s; +69.395op/s] or [+8.256%; +27.365%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+303.166ms; +305.063ms] or [+152.669%; +153.624%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • 🟥 execution_time [+298.887ms; +317.960ms] or [+149.773%; +159.330%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟥 execution_time [+303.109ms; +306.913ms] or [+152.269%; +154.180%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+302.401ms; +304.303ms] or [+151.856%; +152.811%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net6.0

  • 🟥 execution_time [+299.709ms; +302.832ms] or [+148.193%; +149.737%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 execution_time [+301.780ms; +305.436ms] or [+152.955%; +154.809%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+303.993ms; +306.766ms] or [+152.577%; +153.969%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 execution_time [+296.825ms; +315.452ms] or [+147.940%; +157.224%]
  • 🟩 throughput [+46305.539op/s; +60966.729op/s] or [+9.195%; +12.106%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟥 execution_time [+297.857ms; +300.891ms] or [+148.181%; +149.690%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟩 execution_time [-15.347ms; -11.684ms] or [-7.136%; -5.433%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [+5.268µs; +47.875µs] or [+1.301%; +11.825%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-19.984KB; -19.962KB] or [-7.290%; -7.282%]
  • unstable execution_time [+24.410µs; +124.257µs] or [+4.825%; +24.559%]
  • unstable throughput [-312.739op/s; -42.041op/s] or [-15.606%; -2.098%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark netcoreapp3.1

  • unstable execution_time [-45.319µs; +16.298µs] or [-7.853%; +2.824%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • unstable execution_time [+8.468µs; +13.379µs] or [+20.015%; +31.624%]
  • 🟥 throughput [-5718.736op/s; -3747.462op/s] or [-24.074%; -15.776%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • unstable execution_time [-13.848µs; -6.314µs] or [-21.485%; -9.796%]
  • 🟩 throughput [+1506.333op/s; +3130.958op/s] or [+9.242%; +19.209%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+302.164ms; +303.602ms] or [+152.731%; +153.457%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+302.055ms; +304.983ms] or [+153.745%; +155.235%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+300.158ms; +302.484ms] or [+150.266%; +151.431%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+299.364ms; +301.086ms] or [+149.206%; +150.064%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+298.176ms; +300.746ms] or [+149.730%; +151.020%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+303.095ms; +305.797ms] or [+153.710%; +155.081%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+300.858ms; +302.045ms] or [+150.070%; +150.662%]
  • 🟩 throughput [+61211961.550op/s; +61584273.797op/s] or [+44.578%; +44.849%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+417.917ms; +423.134ms] or [+519.754%; +526.243%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+299.497ms; +300.701ms] or [+149.382%; +149.983%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟩 throughput [+81851.057op/s; +96308.600op/s] or [+7.642%; +8.992%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟩 throughput [+49867.790op/s; +69995.679op/s] or [+5.772%; +8.102%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0

  • 🟩 throughput [+72883.494op/s; +103746.915op/s] or [+5.641%; +8.030%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1

  • 🟩 throughput [+80465.918op/s; +90765.676op/s] or [+7.992%; +9.014%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net6.0

  • 🟩 throughput [+47433.883op/s; +53536.243op/s] or [+8.613%; +9.721%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1

  • 🟩 throughput [+22782.738op/s; +33002.834op/s] or [+5.100%; +7.387%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟩 throughput [+77425.280op/s; +96654.755op/s] or [+8.650%; +10.799%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

daniel-romano-DD and others added 2 commits July 1, 2026 17:17
…erage

Consolidate the scattered ASP.NET Core WAF calls (basic request scan, path
params, request/response body) into a single request-phase scan (RunRequestScan)
plus the existing response-phase scan (CheckReturnedHeaders), keeping the WAF to
two runs per request on the happy path.

Hardening on top of the consolidation:
- Close the short-circuit coverage gap: when the request-phase scan never ran
  (e.g. an MVC request short-circuited by an authorization/resource filter before
  ActionResponseFilter.OnActionExecuting, with no end-pipeline fallback), fold the
  basic request addresses into the response-phase call so request rules still
  evaluate and can still block.
- Make RunRequestScan idempotent via RequestScanCompleted so it is safe to call
  from more than one hook (non-MVC route event and MVC/Razor action filter).
- Resolve the local-root span in ActionResponseFilter (InternalActiveScope.Root),
  consistent with FireOnStartCommon, instead of the innermost active scope.
- End-pipeline 404 fallback marks RequestScanCompleted to avoid the response-phase
  scan redundantly re-adding the basic request addresses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The consolidated request-phase scan routed the model-bound request body through
ActionResponseFilter (an IActionFilter), which ASP.NET Core does not run for Razor
Pages. As a result a Razor Page request body was stashed but never scanned, so body
attacks were neither detected nor blocked (returned 200 instead of 403).

Distinguish the two cases at the model-binding hook using RequestScanCompleted:
- MVC controller: the routing event skipped the request scan, so the body is stashed
  for ActionResponseFilter.OnActionExecuting (unchanged).
- Razor Page: the routing event already ran the request scan (no `controller` route
  value), and no action filter will consume a stashed body, so scan the freshly bound
  body immediately.

Also drop the RequestScanCompleted early-return in RunRequestScan: it prevented the
second (body) scan for Razor Pages. The method is meant to run once per MVC controller
but twice for a Razor Page (basic at routing, body at model binding).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@daniel-romano-DD daniel-romano-DD force-pushed the dani/aap/waf_call_refactor branch from 8d7e824 to 172f1ff Compare July 1, 2026 15:18
@daniel-romano-DD

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 172f1ff4c9

ℹ️ 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".

/// Stashes the extracted request body to be flushed in the next request-phase WAF call.
/// Called from the model-binding hook; consumed by ActionResponseFilter.OnActionExecuting.
/// </summary>
internal void SetPendingRequestBody(object body) => _pendingRequestBody = body;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Accumulate all pending request bodies

When MVC binds more than one top-level body/form value before the action filter (for example multiple [FromForm] parameters), DefaultModelBindingContext_SetResult_Integration calls this setter for each value, but this assignment overwrites the previous extraction and ActionResponseFilter later scans only the last one. Before this change each extracted value was passed to CheckBody immediately, so attacks in earlier form/body-bound parameters are no longer evaluated by AppSec; please accumulate or scan every pending body value.

Useful? React with 👍 / 👎.

Comment on lines +582 to +587
if (controllerName is null)
{
// Non-MVC endpoint (minimal API, Razor Pages, etc.) — run the consolidated request scan now.
// MVC controller endpoints defer to ActionResponseFilter.OnActionExecuting so the bound body
// is available and the scan runs immediately before the action executes.
_security.RunRequestScan(httpContext, rootSpan, routeValues, requestBody: null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve MVC route values in the request scan

For controller endpoints this branch now skips the routing-time scan and relies on ActionResponseFilter, but that filter rebuilds server.request.path_params only from action parameters. MVC routes can contain values that are not action method parameters (for example class-level or ambient route tokens read from RouteData), and those were previously included because the routing event passed the full RouteValueDictionary; after this change those values are missing from WAF input, so path-param rules will not fire for them. The same skip exists in the single-span observer.

Useful? React with 👍 / 👎.

// For normal matched requests, RequestScanCompleted is true and we skip to avoid a third WAF call
// (the two canonical calls are RunRequestScan in ActionResponseFilter.OnActionExecuting and
// CheckReturnedHeaders in FireOnStarting).
if (_endPipeline && security.AppsecEnabled)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep blocking outside user exception middleware

With this guard the middleware inserted at the start of the pipeline no longer performs the request WAF scan before invoking _next; the new request scans run later from MVC/endpoint hooks and block by throwing BlockException. In apps with catch-all exception-handling middleware registered inside _next, that middleware can catch the BlockException and turn it into a normal error response before this outer catch sees it, so AppSec blocking for headers/query/cookies/path/body can be bypassed; keep the blocking decision in this outer middleware path or write the block response before entering user middleware.

Useful? React with 👍 / 👎.

Comment on lines +57 to +59
var args = requestScanCompleted
? new Dictionary<string, object>()
: securityCoordinator.GetBasicRequestArgsForWaf();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include session id in the fallback scan

In the request-not-scanned fallback this only rebuilds the basic request arguments, while the removed route-matched path called CheckPathParamsAndSessionId and RunRequestScan still passes sessionId from ISessionFeature. For MVC requests short-circuited before ActionResponseFilter.OnActionExecuting, no request-phase scan now runs and this fallback never supplies usr.session_id, so rules or blocking decisions that depend on the ASP.NET Core session id are skipped; mirror the session lookup here before calling RunWaf.

Useful? React with 👍 / 👎.

Comment on lines +151 to +155
securityCoordinator.BlockAndReport(result);

if (appSecRequestContext is not null)
{
appSecRequestContext.RequestScanCompleted = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mark the request scan before blocking

When this WAF call returns a blocking result, BlockAndReport throws before RequestScanCompleted is set. The outer middleware then writes the blocking response, which invokes FireOnStarting; CheckReturnedHeaders still sees the request as unscanned and re-runs the WAF with request addresses while constructing the block response. For blocking requests this adds an extra WAF execution and can throw another BlockException out of WriteResponse; set the flag before throwing or in a finally.

Useful? React with 👍 / 👎.

Comment on lines +77 to +80
var extracted = ObjectExtractor.Extract(result.Value);
if (extracted is not null)
{
currentSpan.Context?.TraceContext?.AppSecRequestContext.SetPendingResponseBody(extracted);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scan response bodies when FireOnStarting is absent

This now only stashes the extracted response body and relies on CheckReturnedHeaders to consume it, but the only FireOnStarting integrations in this repo are for Kestrel and IIS (FireOnStartCommon). ASP.NET Core apps hosted on HttpSys or another server where that hook is not instrumented will never consume the pending body, so response-body AppSec rules silently stop running even though the previous CheckBody call executed directly from the MVC filter.

Useful? React with 👍 / 👎.

daniel-romano-DD and others added 2 commits July 1, 2026 23:46
When a WAF redirect action (redirect_request) triggered from within the pipeline
(RunRequestScan / CheckReturnedHeaders), it surfaced as a BlockException whose
BlockInfo property actually holds the RedirectInfo (BlockAndReport throws
`new BlockException(result, result.RedirectInfo ?? result.BlockInfo)`).

The outermost BlockingMiddleware catch built the action with
`GetBlockingAction(accept, blockException.BlockInfo, null)` — passing the redirect
dict as blockInfo and null as redirectInfo. GetBlockingAction then took the block
branch: it wrote a block body and set the status from the dict's status_code (302),
with IsRedirect=false. Result: HTTP 302 with a block-page body and no Location header.

Use the full result's block/redirect info (`blockException.Result.BlockInfo`,
`blockException.Result.RedirectInfo`) so redirects are written as redirects
(3xx + Location, no body), matching the end-pipeline path. Block actions are
unaffected (RedirectInfo is null for them).

Validated with AsmActionsConfiguration: redirect_request now returns 302 with
content-length 0; block_request still returns its body with the configured status.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

9 occurrences of :

-    Resource: GET /health/,
+    Resource: GET /health,
[...]
+      aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.HealthController.Index (Samples.Security.AspNetCore5),
+      aspnet_core.route: health,
[...]
+      http.endpoint: health,
[...]
+      http.route: health,

9 occurrences of :

+      _dd.appsec.fp.session: ssn----<SessionFp>,
[...]
+      _dd.code_origin.frames.0.index: 0,
+      _dd.code_origin.frames.0.method: Index,
+      _dd.code_origin.frames.0.type: Samples.Security.AspNetCore5.Controllers.HealthController,
+      _dd.code_origin.type: entry,

2 occurrences of :

-    Resource: GET /,
+    Resource: GET /home/index,
[...]
+      aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.HomeController.Index (Samples.Security.AspNetCore5),
+      aspnet_core.route: {controller=home}/{action=index}/{id?},
[...]
+      http.endpoint: {controller=home}/{action=index}/{id?},
[...]
+      http.route: {controller=home}/{action=index}/{id?},

2 occurrences of :

+      _dd.appsec.fp.session: ssn----<SessionFp>,
[...]
+      _dd.code_origin.frames.0.index: 0,
+      _dd.code_origin.frames.0.method: Index,
+      _dd.code_origin.frames.0.type: Samples.Security.AspNetCore5.Controllers.HomeController,
+      _dd.code_origin.type: entry,

daniel-romano-DD and others added 2 commits July 2, 2026 09:55
CheckReturnedHeaders (the response-phase scan, run from FireOnStarting) already guards
on !transport.IsBlocked so it can skip the response scan — and thus API-Security
response schema extraction (_dd.appsec.s.res.*) — for a blocked request. But when a
block was raised as a BlockException from within the pipeline (RunRequestScan /
CheckReturnedHeaders via BlockAndReport/ReportAndBlock), nothing marked the transport
blocked: MarkBlocked was only called on the end-pipeline 404 fallback. So IsBlocked was
still false when the block response was written, CheckReturnedHeaders ran, and
_dd.appsec.s.res.headers was emitted for blocked requests (res.body was already absent
since the action never produced a body).

Mark the request blocked at the moment we decide to block (before the BlockException
unwinds and the block response is written), so the existing !IsBlocked guard skips the
response-phase scan. Non-blocked requests are unaffected and still get res.body/res.headers.

Matches the API Security spec (no response schemas on a blocked request) and the
system-test Test_Schema_Response_on_Block.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant