Skip to content

Taint propagation: String.Trim() (first instance-method target) #41

Description

@JVBotelho

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

  • Trim() on a tainted string produces a tainted result.
  • Trim() on an untainted string produces an untainted result.
  • Existing Concat propagation is unaffected.
  • Unit test added in Rasp.Core.Tests/Context/RaspTaintSensorTests.cs.
  • PR description notes that TrimStart(), TrimEnd(), ToUpperInvariant(), and ToLowerInvariant() can each reuse this exact pattern as their own follow-up issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .NET codeC++C++/Native codegood first issueGood for newcomershelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions