Jenny B
Findings (FLT-359, Round 2 — Jenny)¶
- HIGH —
src/Forge.Approvals.Notify/Notifications.cs:36-40(and:49-53) - Problem:
PavlokNotifierchecksPath.IsPathFullyQualified(executablePath)andexecutablePath.StartsWith(@"\\", StringComparison.Ordinal)beforePath.GetFullPath(executablePath). On Windows .NET,/isPath.AltDirectorySeparatorChar, so forward-slash and mixed-slash UNC or Win32 device paths (e.g.,"//attacker.example/share/pavlok.exe",@"/\attacker.example\share\pavlok.exe","//?/UNC/attacker.example/share/pavlok.exe") passIsPathFullyQualified, bypassStartsWith(@"\\"), and are then normalized byPath.GetFullPathon line 40 into\\attacker.example\share\pavlok.exe(or\\?\UNC\...), allowing remote SMB execution and NTLMv2 credential leak. InNotifyAsync,ProcessStartInfo.WorkingDirectoryis also left unset (inheriting the caller/agent's untrusted workspace CWD, enabling Windows CWD DLL/config search hijacking), andstart.Environment.Clear()stripsSystemRooton Windows (which causes WinsockWSAStartupto fail with10106 WSAEPROVIDERFAILEDINITif the pinned Pavlok binary makes network/HTTPS calls — needs verification with the real Windows binary). -
Fix: Normalize first (
var fullPath = Path.GetFullPath(executablePath);), then rejectfullPath.StartsWith(@"\\", StringComparison.Ordinal)ornew Uri(fullPath).IsUnc(on Windows, require an explicit local drive rootchar.IsAsciiLetter(fullPath[0]) && fullPath[1] == ':' && fullPath[2] == '\\'). Setstart.WorkingDirectory = Path.GetDirectoryName(this.executablePath). If the Windows Pavlok binary uses sockets, seed only a trustedSystemRoot(Environment.GetFolderPath(Environment.SpecialFolder.Windows)) afterEnvironment.Clear(). -
HIGH —
.github/workflows/ci.yml:11and:18 - Problem:
- Workflow-global
env: Approvals__Enabled: 'false'injects an environment-variable override into everydotnet testanddotnet-strykerrun. If the unconfigured default ever regresses fromfalsetotrue(violating "inert by default"), tests using standardMicrosoft.Extensions.Configuration(AddEnvironmentVariables()) will still pass in CI, and tests configuringApprovals:Enabled=truevia lower-precedence providers get overridden. - CI runs exclusively on
ubuntu-latest. On Linux,Path.IsPathFullyQualified(@"\\server\share\pavlok.exe")returnsfalsebeforeStartsWith(@"\\")is even evaluated, leaving Windows path validation,Process.Kill(entireProcessTree: true), andFileShare.Nonelocking untested on Windows (the fleet's target OS).
- Workflow-global
-
Fix: Remove
Approvals__Enabled: 'false'from workflow-globalenv:duringdotnet test/dotnet-stryker, and runbuild-testacross[ubuntu-latest, windows-latest]. -
HIGH —
src/Forge.Approvals.Twilio/TwilioProvider.cs:135-138 - Problem:
TwilioProviderrequires "a challenge-read-only credential that cannot enroll factors" (a scoped Twilio API Key), butSendAsynccomputesuseApiKey = !string.IsNullOrWhiteSpace(options.ApiKeySid) && !string.IsNullOrWhiteSpace(options.ApiKeySecret)and silently falls back to masterAccountSid:AuthToken(which can enroll factors and mutate Verify services) if either API key field is missing while account credentials exist in config/environment. Also,usernameis not checked against containing:, which corrupts HTTP Basic auth framing. -
Fix: Fail closed if partial API key config is present (
!string.IsNullOrWhiteSpace(options.ApiKeySid) ^ !string.IsNullOrWhiteSpace(options.ApiKeySecret)), forbid masterAuthTokenon the verifier adapter (or disallow fallback whenApiKeySidis configured), and reject:inusername. -
MEDIUM —
src/Forge.Approvals.Twilio/TwilioProvider.cs:41,:58-65, and:83-96 - Problem:
- In
ChallengeAsync(:58-62), untrustedchallengeIdis only checked withIsNullOrWhiteSpaceand passed toUri.EscapeDataString. Because.is RFC 3986 unreserved,"."and".."are not escaped, sonew Uri(Origin, path)resolves dot-segments to/Challenges/or/Entities/{identity}(rejected later byParseChallenge, but still issues authenticated requests to unintended Twilio endpoints). ParseChallenge(:83-96) ispublic staticand checkspins.HasPinnedApproverrather thanpins.IsComplete, without verifying!string.IsNullOrWhiteSpace(service)/identity/factor; ifpins.ServiceSidisnullor"",string.Equals(service, pins.ServiceSid, StringComparison.Ordinal)matches"service_sid": null(null == null).DisplayFields(:41) does not guardrequest.Action.HumanSummaryagainstnull(NullReferenceExceptionescapesCreateChallengeAsync, which has notry/catcharoundDisplayFields) or empty/whitespace (which Twilio rejects with HTTP 400). Line 64 maps all non-2xx responses—including HTTP 400/404 for forged or wrong-entitychallengeId—toProviderUnavailableinstead ofInvalid, inviting transient retries on invalid challenges.- Line 65 (
ReadAsStringAsync) buffers an unbounded HTTP response body into a UTF-16string, whichJsonDocument.Parse(string)then transcodes back into a temporary UTF-8 buffer.
- In
-
Fix: Validate
challengeIdagainst^YC[0-9a-fA-F]{32}$before making HTTP calls; rejectstring.IsNullOrWhiteSpace(request.Action.HumanSummary)inDisplayFields; explicitly check!string.IsNullOrWhiteSpace(service) && !string.IsNullOrWhiteSpace(identity) && !string.IsNullOrWhiteSpace(factor)inParseChallenge; map HTTP 400/404 challenge responses toInvalid(request)(reservingProviderUnavailablefor 408/429/5xx/auth/transport failures); and useHttpCompletionOption.ResponseHeadersReadwith a byte-capped UTF-8 stream (e.g., 64 KB) directly intoJsonDocument.Parse. -
MEDIUM —
src/Forge.Approvals.Notify/Notifications.cs:21-22,:83-85,:113-122,:128-144andsrc/Forge.Approvals.Twilio/TwilioProvider.cs:68-71 - Problem:
HiddenProcessRunner.RunAsync(Notifications.cs:22) runsif (!process.HasExited) process.Kill(entireProcessTree: true);unprotected insidecatch. If the process or a child exits concurrently andHasExited/Killthrows (Win32Exception/AggregateException/InvalidOperationException), it replaces theOperationCanceledException, breakingPavlokNotifier's timeout handler at:59.FileNotificationOutbox.NotifyAsync(Notifications.cs:130-143) does not checkcancellationToken.ThrowIfCancellationRequested()before creating{Jti}.notifiedand catches allExceptions (includingOperationCanceledException) inside itsforeachloop—permanently burning the at-most-once marker on a pre-canceled token and continuing to invoke remaining notifiers after cancellation.TwilioProvider.ChallengeAsync(TwilioProvider.cs:68-71) swallowsOperationCanceledExceptioneven whencancellationToken.IsCancellationRequestedistrue(and has no per-request deadline CTS, relying onHttpClient's 100s default timeout).SmtpEmailSender.SendAsync(Notifications.cs:84) hardcodes a 10sCancelAfter, silently overridingEmailNotifier's configurable up-to-30stimeout, whileEmailNotifier.NotifyAsync(:121) lets internal timeoutOperationCanceledExceptionescape when callercancellationTokenwas not canceled. Lines113-114also runSelect(...).ToArray()across the full untrustedsummarybefore[..80]truncation (unbounded allocation on large payloads) and can split a UTF-16 surrogate pair at index 79.
-
Fix: Wrap
process.Kill(entireProcessTree: true)in a best-efforttry/catchinsideHiddenProcessRunner; callcancellationToken.ThrowIfCancellationRequested()at entry inFileNotificationOutbox.NotifyAsyncand rethrowOperationCanceledExceptionwhencancellationToken.IsCancellationRequestedin bothFileNotificationOutboxandTwilioProvider(adding an explicit per-request timeout CTS toTwilioProvider); remove the hardcoded 10s deadline insideSmtpEmailSenderand handle internal timeout consistently inEmailNotifier; slicesummaryto<= 80chars (decrementing ifchar.IsHighSurrogate) before sanitizing characters. -
MEDIUM —
.github/workflows/ci.yml:21-22,:48,:66-68 - Problem: Third-party GitHub Actions (
@v4), security container images (zricethezav/gitleaks:v8.24.3,semgrep/semgrep:1.117.0), anddotnet-stryker --version '4.*'are unpinned to immutable commit SHAs,@sha256digests, or a committed.config/dotnet-tools.jsonmanifest. In addition,semgrep scan --config=p/csharp --error --strict --metrics=offfetches a floating remote ruleset on every CI run, and recent Semgrep CLI versions reject registry (p/...) downloads when--metrics=offis passed (needs live-doc verification againstsemgrep/semgrep:1.117.0). - Fix: Pin Actions to full commit SHAs, pin Docker images by
@sha256digest, commit a.config/dotnet-tools.jsonmanifest (dotnet tool restore), and vendor/pin the Semgrep ruleset in-repo (or verify--config=p/csharpwith--metrics=offon1.117.0).
Backend Concurrency & Resilience Test Verification¶
This chunk includes only the static fixture tests/Forge.Approvals.Tests/Fixtures/twilio-push-challenge.json; verify the test suite includes these explicit concurrency, idempotency, and cancellation tests (add any that are missing):
- FileNotificationOutbox_ConcurrentSameJti_DispatchesAtMostOnce: Task.WhenAll across N parallel NotifyAsync calls with the same Jti on both Linux and Windows, asserting downstream IApprovalNotifier executes exactly once under FileMode.CreateNew + FileShare.None contention.
- FileNotificationOutbox_PreCanceledAndMidLoopCancel_HonorsCancellation: Asserts a pre-canceled CancellationToken throws OperationCanceledException without creating {Jti}.notified, and mid-loop cancellation stops subsequent notifiers from running.
- HiddenProcessRunner_TimeoutWhenKillThrows_PreservesOperationCanceledException: Exercises child-tree termination races during WaitForExitAsync cancellation so PavlokNotifier still handles timeouts cleanly.
- TwilioProvider_CallerCancellationVsTimeout: Asserts caller CancellationToken cancellation propagates OperationCanceledException while internal HTTP timeout / 5xx returns ProviderUnavailable and 400/404/dot-segment challengeId returns Invalid.
- PavlokNotifier_WindowsForwardSlashUncAndDevicePaths_ThrowsArgumentException: Exercises //server/share/pavlok.exe, /\server\share\pavlok.exe, and //?/UNC/server/share/pavlok.exe on windows-latest.
- ApprovalsOptions_UnsetEnvironment_DefaultsToDisabled: Runs without Approvals__Enabled in the process environment to prove default-inert behavior independently of CI env vars.