-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ASM] iast: Tainting of DefaultInterpolatedStringHandler #6340
base: master
Are you sure you want to change the base?
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 462284 Passed, 3577 Skipped, 32h 53m 37.66s Total Time |
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: 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 shown in red. The following thresholds were used for comparing the execution times:
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). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6340) - mean (72ms) : 62, 82
. : milestone, 72,
master - mean (73ms) : 60, 86
. : milestone, 73,
section CallTarget+Inlining+NGEN
This PR (6340) - mean (985ms) : 952, 1018
. : milestone, 985,
master - mean (984ms) : 961, 1007
. : milestone, 984,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6340) - mean (108ms) : 106, 110
. : milestone, 108,
master - mean (108ms) : 106, 110
. : milestone, 108,
section CallTarget+Inlining+NGEN
This PR (6340) - mean (682ms) : 668, 697
. : milestone, 682,
master - mean (685ms) : 670, 699
. : milestone, 685,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6340) - mean (92ms) : 89, 95
. : milestone, 92,
master - mean (92ms) : 90, 94
. : milestone, 92,
section CallTarget+Inlining+NGEN
This PR (6340) - mean (639ms) : 620, 657
. : milestone, 639,
master - mean (637ms) : 623, 651
. : milestone, 637,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6340) - mean (191ms) : 185, 196
. : milestone, 191,
master - mean (192ms) : 185, 198
. : milestone, 192,
section CallTarget+Inlining+NGEN
This PR (6340) - mean (1,102ms) : 1073, 1131
. : milestone, 1102,
master - mean (1,098ms) : 1076, 1120
. : milestone, 1098,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6340) - mean (276ms) : 272, 279
. : milestone, 276,
master - mean (276ms) : 272, 280
. : milestone, 276,
section CallTarget+Inlining+NGEN
This PR (6340) - mean (880ms) : 845, 914
. : milestone, 880,
master - mean (872ms) : 847, 897
. : milestone, 872,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6340) - mean (265ms) : 261, 269
. : milestone, 265,
master - mean (265ms) : 260, 271
. : milestone, 265,
section CallTarget+Inlining+NGEN
This PR (6340) - mean (860ms) : 829, 892
. : milestone, 860,
master - mean (866ms) : 824, 907
. : milestone, 866,
|
Benchmarks Report for tracer 🐌Benchmarks for #6340 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Slower
|
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 | 1.119 | 592.18 | 662.74 |
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net472 | 1.127 | 940.88 | 834.76 | |
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 | 1.118 | 451.76 | 404.12 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 452ns | 0.363ns | 1.4ns | 0.00807 | 0 | 0 | 576 B |
master | StartFinishSpan |
netcoreapp3.1 | 588ns | 2.7ns | 10.1ns | 0.00773 | 0 | 0 | 576 B |
master | StartFinishSpan |
net472 | 663ns | 0.871ns | 3.26ns | 0.0916 | 0 | 0 | 578 B |
master | StartFinishScope |
net6.0 | 482ns | 1.05ns | 4.07ns | 0.00976 | 0 | 0 | 696 B |
master | StartFinishScope |
netcoreapp3.1 | 778ns | 1.41ns | 5.45ns | 0.00935 | 0 | 0 | 696 B |
master | StartFinishScope |
net472 | 939ns | 1.39ns | 5.37ns | 0.104 | 0 | 0 | 658 B |
#6340 | StartFinishSpan |
net6.0 | 404ns | 0.529ns | 2.05ns | 0.00806 | 0 | 0 | 576 B |
#6340 | StartFinishSpan |
netcoreapp3.1 | 660ns | 2.04ns | 7.9ns | 0.00786 | 0 | 0 | 576 B |
#6340 | StartFinishSpan |
net472 | 700ns | 1.73ns | 6.71ns | 0.0915 | 0 | 0 | 578 B |
#6340 | StartFinishScope |
net6.0 | 476ns | 0.654ns | 2.53ns | 0.0098 | 0 | 0 | 696 B |
#6340 | StartFinishScope |
netcoreapp3.1 | 753ns | 1.11ns | 4.32ns | 0.00939 | 0 | 0 | 696 B |
#6340 | StartFinishScope |
net472 | 832ns | 1.79ns | 6.93ns | 0.104 | 0 | 0 | 658 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #6340
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0
1.114
637.96
710.68
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 | 1.114 | 637.96 | 710.68 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | RunOnMethodBegin |
net6.0 | 636ns | 1.43ns | 5.55ns | 0.00977 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 982ns | 1.11ns | 4.29ns | 0.00935 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
net472 | 1.1μs | 2.46ns | 9.52ns | 0.104 | 0 | 0 | 658 B |
#6340 | RunOnMethodBegin |
net6.0 | 711ns | 0.772ns | 2.99ns | 0.00976 | 0 | 0 | 696 B |
#6340 | RunOnMethodBegin |
netcoreapp3.1 | 971ns | 2.09ns | 8.08ns | 0.00922 | 0 | 0 | 696 B |
#6340 | RunOnMethodBegin |
net472 | 1.09μs | 2.92ns | 11.3ns | 0.104 | 0 | 0 | 658 B |
Benchmarks Report for appsec 🐌Benchmarks for #6340 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Iast.StringAspectsBenchmark - Slower
|
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑netcoreapp3.1 | 1.216 | 53,700.00 | 65,300.00 | bimodal |
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 | 253.39 KB | 254.85 KB | 1.46 KB | 0.57% |
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 | 62.16 KB | 57.67 KB | -4.49 KB | -7.22% |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StringConcatBenchmark |
net6.0 | 58.9μs | 534ns | 5.34μs | 0 | 0 | 0 | 43.44 KB |
master | StringConcatBenchmark |
netcoreapp3.1 | 53.9μs | 170ns | 700ns | 0 | 0 | 0 | 42.64 KB |
master | StringConcatBenchmark |
net472 | 37.5μs | 169ns | 653ns | 0 | 0 | 0 | 62.16 KB |
master | StringConcatAspectBenchmark |
net6.0 | 299μs | 1.66μs | 10.8μs | 0 | 0 | 0 | 253.39 KB |
master | StringConcatAspectBenchmark |
netcoreapp3.1 | 344μs | 1.9μs | 16.6μs | 0 | 0 | 0 | 253.57 KB |
master | StringConcatAspectBenchmark |
net472 | 286μs | 5μs | 47.9μs | 0 | 0 | 0 | 278.53 KB |
#6340 | StringConcatBenchmark |
net6.0 | 62.2μs | 892ns | 8.92μs | 0 | 0 | 0 | 43.44 KB |
#6340 | StringConcatBenchmark |
netcoreapp3.1 | 66.3μs | 937ns | 9.32μs | 0 | 0 | 0 | 42.64 KB |
#6340 | StringConcatBenchmark |
net472 | 38.3μs | 111ns | 446ns | 0 | 0 | 0 | 57.67 KB |
#6340 | StringConcatAspectBenchmark |
net6.0 | 317μs | 1.58μs | 9.48μs | 0 | 0 | 0 | 254.85 KB |
#6340 | StringConcatAspectBenchmark |
netcoreapp3.1 | 326μs | 6.94μs | 68μs | 0 | 0 | 0 | 253.17 KB |
#6340 | StringConcatAspectBenchmark |
net472 | 302μs | 6.8μs | 67.3μs | 0 | 0 | 0 | 278.53 KB |
7758970
to
e09b3ff
Compare
e09b3ff
to
8b65a31
Compare
Summary of changes
This PR introduce the support of
DefaultInterpolatedStringHandler
for IAST.The resulting strings of
DefaultInterpolatedStringHandler
will now be tainted.Reason for change
Since the release of .NET Core 6, interpolated strings got a performance optimisation and now use DefaultInterpolatedStringHandler to build strings.
Some vulnerabilities couldn't be detected because strings built with
DefaultInterpolatedStringHandler
weren't tainted.Implementation details
As
DefaultInterpolatedStringHandler
is a ref struct, we call some IL to get it's own stack pointer value and taint it.We need to get that pointer value to track it and its tainted sources.
Test coverage
DefaultInterpolatedStringHandler
ref struct$""
) in various complex casesOther details
This PR don't handle the correct values for
start
andlength
of tainted Sources.