Skip to content

Jenny D

Findings (FLT-359 Round 2 — Test Chunk Review)

  1. [HIGH] tests/Forge.Approvals.Tests/TwilioTests.cs:69-83, tests/Forge.Approvals.Tests/TwilioTests.cs:166-189 — Untrusted challengeId URI path-traversal/injection and per-request HTTP Basic Auth are untested.
  2. Problem: GetUsesPinnedIdentityAndReturnsBindings verifies percent-encoding of config-pinned Identity ("user/name" -> user%2Fname), and CreateDisplaysEntireCanonicalActionWithoutTruncation never asserts handler.Uri at all. Unlike ServiceSid and Identity, challengeId in GetDecisionAsync(request, challengeId) comes from caller-supplied ApprovalEvidence.ChallengeId. No test passes traversal/delimiter payloads ("../../Services", "../other/Challenges/YCfixture", "YCfixture?x=1", "YCfixture#frag", "", whitespace). If TwilioProvider interpolates challengeId without strict SID validation/escaping, System.Uri normalizes ../ segments before dispatch, turning the executor's Twilio credentials into an authenticated GET primitive across verify.twilio.com. In addition, FakeHandler never captures request.Headers.Authorization, leaving per-request Basic Auth vs thread-unsafe HttpClient.DefaultRequestHeaders mutation unverified.
  3. Fix: Add a [Theory] on TwilioProvider.GetDecisionAsync with "../../Services", "YC1/../../Entities/other", "YC1?status=approved", "YC1#frag", "", and " ", asserting ApprovalDecision.Invalid and handler.Calls == 0. Assert handler.Uri on CreateChallengeAsync and assert per-request request.Headers.Authorization on both GET and POST without mutating client.DefaultRequestHeaders.

  4. [HIGH] tests/Forge.Approvals.Tests/ExecutorVerifierTests.cs:27, tests/Forge.Approvals.Tests/ExecutorVerifierTests.cs:90-107, tests/Forge.Approvals.Tests/ExecutorVerifierTests.cs:214-218 — Action-substitution boundary (expectedActionHash != request.ActionHash), monotonic clock rollback failure (IApprovalClock.TryRecordAsync), and unknown/empty evidence are untested.

  5. Problem:
    1. Every enabled call to VerifyAsync passes request.ActionHash verbatim as the second argument (expectedActionHash). WrongProviderBindingCannotAuthorize only tampers ProviderResult.ActionHash, leaving action substitution (caller submits a valid ApprovalRequest + approved challenge for benign Action A while the executor checks expectedActionHash for destructive Action B, or submits a request whose Action does not canonical-hash to request.ActionHash) completely untested.
    2. FakeClock.TryRecordAsync unconditionally returns Task.FromResult(true) with no call counter. Clock rollback / persistence failure (TryRecordAsync returning false) is never exercised; deleting or inverting the TryRecordAsync check—or burning the replay Jti when TryRecordAsync fails—would pass all tests and survive Stryker.NET mutations.
    3. Enabled verification with an unknown PersonId (not in ApproverRegistry) or empty evidence ([]) has no test.
  6. Fix: Add tests asserting: (a) expectedActionHash != request.ActionHash and tampered request.Action fail closed (Invalid/Denied) with Calls == 0 and Replay.Calls == 0; (b) FakeClock.TryRecordAsync returning false fails closed without approving (and asserts whether TryRecordAsync was invoked and Replay left unconsumed); (c) unknown PersonId and empty evidence fail closed with Calls == 0.

  7. [HIGH] tests/Forge.Approvals.Tests/ExecutorVerifierTests.cs:38-72, tests/Forge.Approvals.Tests/ExecutorVerifierTests.cs:125-133, tests/Forge.Approvals.Tests/ExecutorVerifierTests.cs:198 — Multi-signer partial/mixed provider decisions, duplicate-person HTTP fan-out, and secondary factor enrollment are untested.

  8. Problem: Every multi-signer test reaching FakeVerifier returns Approved for all signers, while NonApprovalStaysDistinctAndNeverConsumes only tests 1-of-1. There is no test where Signer 1 returns Approved and Signer 2 returns Pending, ProviderUnavailable, Denied, or Invalid. This leaves two high-risk defects unguarded:
    1. Consuming Replay.TryConsumeAsync(request.Jti) before all m-of-n signers are verified, permanently burning the Jti while Signer 2 is still Pending.
    2. Skipping an Invalid (tampered binding) evidence entry when extra candidate evidence items are supplied instead of failing closed, or making outbound Twilio calls on duplicate PersonId entries (OnePersonCannotCoverReleaseAndDuplicateSignaturesNeverCount asserts Replay.Calls == 0 on line 58, not harness.Calls == 0, risking Twilio rate-limit DoS via repeated PersonIds). Additionally, Harness hardcodes person.FactorSids[0], never verifying approval via a secondary enrolled factor (FactorSids[1]).
  9. Fix: Add 2-of-3 / Release tests with mixed outcomes ([Approved, Pending], [Approved, ProviderUnavailable], [Invalid, Approved]) asserting Replay.Calls == 0 and deterministic fail-closed status precedence; assert harness.Calls == 0 on duplicate PersonId evidence; add a test approving with person.FactorSids[1].

  10. [MEDIUM] tests/Forge.Approvals.Tests/TwilioTests.cs:192-197, tests/Forge.Approvals.Tests/TwilioTests.cs:217-232 — Non-2xx HTTP status codes, corrupt/non-JSON responses, and HttpClient timeout (TaskCanceledException) vs caller cancellation are untested.

  11. Problem: FakeHandler only throws HttpRequestException or returns 200 OK with valid JSON. In .NET, HttpClient.SendAsync does not throw on 401/403/404/429/500/503 unless explicitly handled, and HttpClient.Timeout throws TaskCanceledException (OperationCanceledException), not HttpRequestException. If TwilioProvider only catches HttpRequestException, timeouts and JsonExceptions on HTML/empty error bodies throw unhandled exceptions; if it catches OperationCanceledException broadly without checking cancellationToken.IsCancellationRequested, caller cancellation is swallowed as ProviderUnavailable.
  12. Fix: Extend FakeHandler to configure status code, body, and exception/cancellation behavior. Add tests for 401/403/404 vs 429/500/503, malformed/empty/HTML response bodies (must fail closed without throwing JsonException), TaskCanceledException when caller token is not cancelled (ProviderUnavailable), and cancelled caller CancellationToken (OperationCanceledException propagated).

  13. [MEDIUM] tests/Forge.Approvals.Tests/TwilioTests.cs:38-39, tests/Forge.Approvals.Tests/TwilioTests.cs:103, tests/Forge.Approvals.Tests/TwilioTests.cs:127-163 — UTF-16 surrogate-pair splitting at 128-char chunk boundaries, slack length-limit boundary, extra echoed fields, and nested duplicate JSON keys.

  14. Problem:
    1. Payload slices canonical by 128 UTF-16 chars (Substring(offset, 128)). If TwilioProvider chunks identically and an OutwardMessage or HumanSummary places a 2-char UTF-16 surrogate pair (e.g., emoji/non-BMP rune) across offset 127..128, it emits lone surrogates that System.Text.Json / UTF-8 encoding replaces with U+FFFD or rejects, breaking echo verification (exact Twilio Verify Push Details.Fields UTF-8 byte vs code-point limit needs live-doc verification).
    2. OversizedCanonicalActionIsRejectedBeforeTransport sets EffectBinding = new string('a', 1281) (~1,480+ total canonical chars) without testing the exact max boundary (max allowed -> Pending, max + 1 -> Invalid).
    3. AlteredVisibleEchoDeniesCreateAndPoll tests "missing-field" (RemoveAt(0)) but not an appended "extra-field" in details.fields, and WrongProviderPinDenies tests a past expiration_date (2015-...) but not an extended future expiration_date > request.ExpiresUtc.
    4. DuplicateStatusDenies tests a duplicate key only on the root JSON object ("status"), not inside nested objects (hidden_details.actionHash or details.fields[0].value).
  15. Fix: Add tests for: (a) a non-BMP character straddling chunk index 127..128 (chunk on Rune/UTF-8 boundaries); (b) exact max canonical length succeeding and max + 1 returning Invalid; (c) appended trailing details.fields element and expiration_date > request.ExpiresUtc; (d) duplicate "actionHash" inside hidden_details.

Backend Concurrency & Cancellation Coverage Audit (Jenny Focus)

  • Parallel requests & locking: Not exercised. ApprovedRequestCannotReplay executes two sequential VerifyAsync calls, and FakeReplay uses an unsynchronized HashSet<Guid> and non-atomic Calls++.
  • Missing test: ConcurrentVerifySameJtiApprovesAtMostOnce (make FakeReplay thread-safe via ConcurrentDictionary<Guid, byte> + Interlocked.Increment, release 8+ parallel VerifyAsync tasks from a TaskCompletionSource barrier inside FakeVerifier.GetDecisionAsync, and assert Assert.Single(results, r => r.Decision == ApprovalDecision.Approved) with all peers returning Denied).
  • Rate limiters / outbound fan-out: Not exercised. Neither 429 Too Many Requests handling in TwilioProvider nor bounding outbound GetDecisionAsync calls against oversized/duplicate evidence arrays is tested.
  • Missing tests: RateLimitedTwilioResponseReturnsProviderUnavailable (429 status in TwilioTests) and ExcessiveOrDuplicateEvidenceDoesNotFanOutToProvider (asserting harness.Calls == 0 when evidence exceeds policy/registry bounds or repeats PersonId).
  • Retries & idempotency: Partially exercised (1-of-1 non-consumption on Pending/ProviderUnavailable at ExecutorVerifierTests.cs:125-133 and sequential post-approval replay denial at ExecutorVerifierTests.cs:150-158). Multi-step polling progression and partial m-of-n retries are missing.
  • Missing test: MultiSignerRetryAfterPendingAndTransientOutageApprovesOnceThenBlocksReplay (2-of-2 request transitioning [Approved, Pending] -> [Approved, ProviderUnavailable] -> [Approved, Approved] -> [Approved, Approved] replay Denied).
  • Cancellation flow: Not exercised. FakeVerifier, FakeReplay, FakeClock, and FakeHandler accept CancellationToken without testing pre-cancelled or mid-flight cancellation.
  • Missing tests: VerifyCancellationPropagatesAndNeverConsumesJti (cancel token during OnFetch, assert OperationCanceledException and Replay.Calls == 0) and TwilioDistinguishesCallerCancellationFromHttpClientTimeout.

Jira FLT-359 · Vikunja · BOARD.md