Summary
Add native taint propagation for String.Trim() — the first instance-method propagation
target (every existing/other-queued target so far is static). Establishes the pattern for
TrimStart(), TrimEnd(), ToUpperInvariant(), ToLowerInvariant() as follow-up issues.
Background
ADR 006
ships v1 taint propagation for String.Concat(string, string) only, a static method. Trim()
is an instance method with zero declared parameters — the only operand to forward is this.
What changes
RaspProfiler::IsV1PropagationTarget (src/Rasp.Native.Profiler/src/RaspProfiler.cpp:443-483):
add a signature match for Trim — 0 declared params, System.String return type, and
the calling-convention byte must test the IMAGE_CEE_CS_CALLCONV_HASTHIS bit (this is the
first target where that bit needs checking; Concat is static and never sets it).
RaspTaintSensor (src/Rasp.Core/Context/RaspTaintSensor.cs:85-96): add a
PropagateTaint(string? result, string? operand) two-argument overload — marks result
tainted if operand (the original this) was tainted.
RaspProfiler::DoJITCompilationStarted (RaspProfiler.cpp:606-648): resolve the new
overload's MemberRef and call RewritePropagationProbe with operand count 1 (just
ldarg.0, i.e. this).
Acceptance criteria
Summary
Add native taint propagation for
String.Trim()— the first instance-method propagationtarget (every existing/other-queued target so far is
static). Establishes the pattern forTrimStart(),TrimEnd(),ToUpperInvariant(),ToLowerInvariant()as follow-up issues.Background
ADR 006
ships v1 taint propagation for
String.Concat(string, string)only, a static method.Trim()is an instance method with zero declared parameters — the only operand to forward is
this.What changes
RaspProfiler::IsV1PropagationTarget(src/Rasp.Native.Profiler/src/RaspProfiler.cpp:443-483):add a signature match for
Trim— 0 declared params,System.Stringreturn type, andthe calling-convention byte must test the
IMAGE_CEE_CS_CALLCONV_HASTHISbit (this is thefirst target where that bit needs checking;
Concatis static and never sets it).RaspTaintSensor(src/Rasp.Core/Context/RaspTaintSensor.cs:85-96): add aPropagateTaint(string? result, string? operand)two-argument overload — marksresulttainted if
operand(the originalthis) was tainted.RaspProfiler::DoJITCompilationStarted(RaspProfiler.cpp:606-648): resolve the newoverload's
MemberRefand callRewritePropagationProbewith operand count 1 (justldarg.0, i.e.this).Acceptance criteria
Trim()on a tainted string produces a tainted result.Trim()on an untainted string produces an untainted result.Concatpropagation is unaffected.Rasp.Core.Tests/Context/RaspTaintSensorTests.cs.TrimStart(),TrimEnd(),ToUpperInvariant(), andToLowerInvariant()can each reuse this exact pattern as their own follow-up issue.