Skip to content

Jenny B

Findings (FLT-359, Round 2 — Jenny)

  1. HIGH — src/Forge.Approvals.Notify/Notifications.cs:36-40 (and :49-53)
  2. Problem: PavlokNotifier checks Path.IsPathFullyQualified(executablePath) and executablePath.StartsWith(@"\\", StringComparison.Ordinal) before Path.GetFullPath(executablePath). On Windows .NET, / is Path.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") pass IsPathFullyQualified, bypass StartsWith(@"\\"), and are then normalized by Path.GetFullPath on line 40 into \\attacker.example\share\pavlok.exe (or \\?\UNC\...), allowing remote SMB execution and NTLMv2 credential leak. In NotifyAsync, ProcessStartInfo.WorkingDirectory is also left unset (inheriting the caller/agent's untrusted workspace CWD, enabling Windows CWD DLL/config search hijacking), and start.Environment.Clear() strips SystemRoot on Windows (which causes Winsock WSAStartup to fail with 10106 WSAEPROVIDERFAILEDINIT if the pinned Pavlok binary makes network/HTTPS calls — needs verification with the real Windows binary).
  3. Fix: Normalize first (var fullPath = Path.GetFullPath(executablePath);), then reject fullPath.StartsWith(@"\\", StringComparison.Ordinal) or new Uri(fullPath).IsUnc (on Windows, require an explicit local drive root char.IsAsciiLetter(fullPath[0]) && fullPath[1] == ':' && fullPath[2] == '\\'). Set start.WorkingDirectory = Path.GetDirectoryName(this.executablePath). If the Windows Pavlok binary uses sockets, seed only a trusted SystemRoot (Environment.GetFolderPath(Environment.SpecialFolder.Windows)) after Environment.Clear().

  4. HIGH — .github/workflows/ci.yml:11 and :18

  5. Problem:
    1. Workflow-global env: Approvals__Enabled: 'false' injects an environment-variable override into every dotnet test and dotnet-stryker run. If the unconfigured default ever regresses from false to true (violating "inert by default"), tests using standard Microsoft.Extensions.Configuration (AddEnvironmentVariables()) will still pass in CI, and tests configuring Approvals:Enabled=true via lower-precedence providers get overridden.
    2. CI runs exclusively on ubuntu-latest. On Linux, Path.IsPathFullyQualified(@"\\server\share\pavlok.exe") returns false before StartsWith(@"\\") is even evaluated, leaving Windows path validation, Process.Kill(entireProcessTree: true), and FileShare.None locking untested on Windows (the fleet's target OS).
  6. Fix: Remove Approvals__Enabled: 'false' from workflow-global env: during dotnet test / dotnet-stryker, and run build-test across [ubuntu-latest, windows-latest].

  7. HIGH — src/Forge.Approvals.Twilio/TwilioProvider.cs:135-138

  8. Problem: TwilioProvider requires "a challenge-read-only credential that cannot enroll factors" (a scoped Twilio API Key), but SendAsync computes useApiKey = !string.IsNullOrWhiteSpace(options.ApiKeySid) && !string.IsNullOrWhiteSpace(options.ApiKeySecret) and silently falls back to master AccountSid:AuthToken (which can enroll factors and mutate Verify services) if either API key field is missing while account credentials exist in config/environment. Also, username is not checked against containing :, which corrupts HTTP Basic auth framing.
  9. Fix: Fail closed if partial API key config is present (!string.IsNullOrWhiteSpace(options.ApiKeySid) ^ !string.IsNullOrWhiteSpace(options.ApiKeySecret)), forbid master AuthToken on the verifier adapter (or disallow fallback when ApiKeySid is configured), and reject : in username.

  10. MEDIUM — src/Forge.Approvals.Twilio/TwilioProvider.cs:41, :58-65, and :83-96

  11. Problem:
    1. In ChallengeAsync (:58-62), untrusted challengeId is only checked with IsNullOrWhiteSpace and passed to Uri.EscapeDataString. Because . is RFC 3986 unreserved, "." and ".." are not escaped, so new Uri(Origin, path) resolves dot-segments to /Challenges/ or /Entities/{identity} (rejected later by ParseChallenge, but still issues authenticated requests to unintended Twilio endpoints).
    2. ParseChallenge (:83-96) is public static and checks pins.HasPinnedApprover rather than pins.IsComplete, without verifying !string.IsNullOrWhiteSpace(service) / identity / factor; if pins.ServiceSid is null or "", string.Equals(service, pins.ServiceSid, StringComparison.Ordinal) matches "service_sid": null (null == null).
    3. DisplayFields (:41) does not guard request.Action.HumanSummary against null (NullReferenceException escapes CreateChallengeAsync, which has no try/catch around DisplayFields) or empty/whitespace (which Twilio rejects with HTTP 400). Line 64 maps all non-2xx responses—including HTTP 400/404 for forged or wrong-entity challengeId—to ProviderUnavailable instead of Invalid, inviting transient retries on invalid challenges.
    4. Line 65 (ReadAsStringAsync) buffers an unbounded HTTP response body into a UTF-16 string, which JsonDocument.Parse(string) then transcodes back into a temporary UTF-8 buffer.
  12. Fix: Validate challengeId against ^YC[0-9a-fA-F]{32}$ before making HTTP calls; reject string.IsNullOrWhiteSpace(request.Action.HumanSummary) in DisplayFields; explicitly check !string.IsNullOrWhiteSpace(service) && !string.IsNullOrWhiteSpace(identity) && !string.IsNullOrWhiteSpace(factor) in ParseChallenge; map HTTP 400/404 challenge responses to Invalid(request) (reserving ProviderUnavailable for 408/429/5xx/auth/transport failures); and use HttpCompletionOption.ResponseHeadersRead with a byte-capped UTF-8 stream (e.g., 64 KB) directly into JsonDocument.Parse.

  13. MEDIUM — src/Forge.Approvals.Notify/Notifications.cs:21-22, :83-85, :113-122, :128-144 and src/Forge.Approvals.Twilio/TwilioProvider.cs:68-71

  14. Problem:
    1. HiddenProcessRunner.RunAsync (Notifications.cs:22) runs if (!process.HasExited) process.Kill(entireProcessTree: true); unprotected inside catch. If the process or a child exits concurrently and HasExited/Kill throws (Win32Exception/AggregateException/InvalidOperationException), it replaces the OperationCanceledException, breaking PavlokNotifier's timeout handler at :59.
    2. FileNotificationOutbox.NotifyAsync (Notifications.cs:130-143) does not check cancellationToken.ThrowIfCancellationRequested() before creating {Jti}.notified and catches all Exceptions (including OperationCanceledException) inside its foreach loop—permanently burning the at-most-once marker on a pre-canceled token and continuing to invoke remaining notifiers after cancellation.
    3. TwilioProvider.ChallengeAsync (TwilioProvider.cs:68-71) swallows OperationCanceledException even when cancellationToken.IsCancellationRequested is true (and has no per-request deadline CTS, relying on HttpClient's 100s default timeout).
    4. SmtpEmailSender.SendAsync (Notifications.cs:84) hardcodes a 10s CancelAfter, silently overriding EmailNotifier's configurable up-to-30s timeout, while EmailNotifier.NotifyAsync (:121) lets internal timeout OperationCanceledException escape when caller cancellationToken was not canceled. Lines 113-114 also run Select(...).ToArray() across the full untrusted summary before [..80] truncation (unbounded allocation on large payloads) and can split a UTF-16 surrogate pair at index 79.
  15. Fix: Wrap process.Kill(entireProcessTree: true) in a best-effort try/catch inside HiddenProcessRunner; call cancellationToken.ThrowIfCancellationRequested() at entry in FileNotificationOutbox.NotifyAsync and rethrow OperationCanceledException when cancellationToken.IsCancellationRequested in both FileNotificationOutbox and TwilioProvider (adding an explicit per-request timeout CTS to TwilioProvider); remove the hardcoded 10s deadline inside SmtpEmailSender and handle internal timeout consistently in EmailNotifier; slice summary to <= 80 chars (decrementing if char.IsHighSurrogate) before sanitizing characters.

  16. MEDIUM — .github/workflows/ci.yml:21-22, :48, :66-68

  17. Problem: Third-party GitHub Actions (@v4), security container images (zricethezav/gitleaks:v8.24.3, semgrep/semgrep:1.117.0), and dotnet-stryker --version '4.*' are unpinned to immutable commit SHAs, @sha256 digests, or a committed .config/dotnet-tools.json manifest. In addition, semgrep scan --config=p/csharp --error --strict --metrics=off fetches a floating remote ruleset on every CI run, and recent Semgrep CLI versions reject registry (p/...) downloads when --metrics=off is passed (needs live-doc verification against semgrep/semgrep:1.117.0).
  18. Fix: Pin Actions to full commit SHAs, pin Docker images by @sha256 digest, commit a .config/dotnet-tools.json manifest (dotnet tool restore), and vendor/pin the Semgrep ruleset in-repo (or verify --config=p/csharp with --metrics=off on 1.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.

Jira FLT-359 · Vikunja · BOARD.md