Jenny D
Findings (FLT-359 Round 2 — Test Chunk Review)¶
- [HIGH] tests/Forge.Approvals.Tests/TwilioTests.cs:69-83, tests/Forge.Approvals.Tests/TwilioTests.cs:166-189 — Untrusted
challengeIdURI path-traversal/injection and per-request HTTP Basic Auth are untested. - Problem:
GetUsesPinnedIdentityAndReturnsBindingsverifies percent-encoding of config-pinnedIdentity("user/name"->user%2Fname), andCreateDisplaysEntireCanonicalActionWithoutTruncationnever assertshandler.Uriat all. UnlikeServiceSidandIdentity,challengeIdinGetDecisionAsync(request, challengeId)comes from caller-suppliedApprovalEvidence.ChallengeId. No test passes traversal/delimiter payloads ("../../Services","../other/Challenges/YCfixture","YCfixture?x=1","YCfixture#frag","", whitespace). IfTwilioProviderinterpolateschallengeIdwithout strict SID validation/escaping,System.Urinormalizes../segments before dispatch, turning the executor's Twilio credentials into an authenticated GET primitive acrossverify.twilio.com. In addition,FakeHandlernever capturesrequest.Headers.Authorization, leaving per-request Basic Auth vs thread-unsafeHttpClient.DefaultRequestHeadersmutation unverified. -
Fix: Add a
[Theory]onTwilioProvider.GetDecisionAsyncwith"../../Services","YC1/../../Entities/other","YC1?status=approved","YC1#frag","", and" ", assertingApprovalDecision.Invalidandhandler.Calls == 0. Asserthandler.UrionCreateChallengeAsyncand assert per-requestrequest.Headers.Authorizationon both GET and POST without mutatingclient.DefaultRequestHeaders. -
[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. - Problem:
- Every enabled call to
VerifyAsyncpassesrequest.ActionHashverbatim as the second argument (expectedActionHash).WrongProviderBindingCannotAuthorizeonly tampersProviderResult.ActionHash, leaving action substitution (caller submits a validApprovalRequest+ approved challenge for benign Action A while the executor checksexpectedActionHashfor destructive Action B, or submits arequestwhoseActiondoes not canonical-hash torequest.ActionHash) completely untested. FakeClock.TryRecordAsyncunconditionally returnsTask.FromResult(true)with no call counter. Clock rollback / persistence failure (TryRecordAsyncreturningfalse) is never exercised; deleting or inverting theTryRecordAsynccheck—or burning the replayJtiwhenTryRecordAsyncfails—would pass all tests and survive Stryker.NET mutations.- Enabled verification with an unknown
PersonId(not inApproverRegistry) or emptyevidence([]) has no test.
- Every enabled call to
-
Fix: Add tests asserting: (a)
expectedActionHash != request.ActionHashand tamperedrequest.Actionfail closed (Invalid/Denied) withCalls == 0andReplay.Calls == 0; (b)FakeClock.TryRecordAsyncreturningfalsefails closed without approving (and asserts whetherTryRecordAsyncwas invoked andReplayleft unconsumed); (c) unknownPersonIdand emptyevidencefail closed withCalls == 0. -
[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.
- Problem: Every multi-signer test reaching
FakeVerifierreturnsApprovedfor all signers, whileNonApprovalStaysDistinctAndNeverConsumesonly tests 1-of-1. There is no test where Signer 1 returnsApprovedand Signer 2 returnsPending,ProviderUnavailable,Denied, orInvalid. This leaves two high-risk defects unguarded:- Consuming
Replay.TryConsumeAsync(request.Jti)before all m-of-n signers are verified, permanently burning theJtiwhile Signer 2 is stillPending. - Skipping an
Invalid(tampered binding) evidence entry when extra candidate evidence items are supplied instead of failing closed, or making outbound Twilio calls on duplicatePersonIdentries (OnePersonCannotCoverReleaseAndDuplicateSignaturesNeverCountassertsReplay.Calls == 0on line 58, notharness.Calls == 0, risking Twilio rate-limit DoS via repeatedPersonIds). Additionally,Harnesshardcodesperson.FactorSids[0], never verifying approval via a secondary enrolled factor (FactorSids[1]).
- Consuming
-
Fix: Add 2-of-3 /
Releasetests with mixed outcomes ([Approved, Pending],[Approved, ProviderUnavailable],[Invalid, Approved]) assertingReplay.Calls == 0and deterministic fail-closed status precedence; assertharness.Calls == 0on duplicatePersonIdevidence; add a test approving withperson.FactorSids[1]. -
[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
HttpClienttimeout (TaskCanceledException) vs caller cancellation are untested. - Problem:
FakeHandleronly throwsHttpRequestExceptionor returns200 OKwith valid JSON. In .NET,HttpClient.SendAsyncdoes not throw on401/403/404/429/500/503unless explicitly handled, andHttpClient.TimeoutthrowsTaskCanceledException(OperationCanceledException), notHttpRequestException. IfTwilioProvideronly catchesHttpRequestException, timeouts andJsonExceptions on HTML/empty error bodies throw unhandled exceptions; if it catchesOperationCanceledExceptionbroadly without checkingcancellationToken.IsCancellationRequested, caller cancellation is swallowed asProviderUnavailable. -
Fix: Extend
FakeHandlerto configure status code, body, and exception/cancellation behavior. Add tests for401/403/404vs429/500/503, malformed/empty/HTML response bodies (must fail closed without throwingJsonException),TaskCanceledExceptionwhen caller token is not cancelled (ProviderUnavailable), and cancelled callerCancellationToken(OperationCanceledExceptionpropagated). -
[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-
charchunk boundaries, slack length-limit boundary, extra echoed fields, and nested duplicate JSON keys. - Problem:
Payloadslicescanonicalby 128 UTF-16chars (Substring(offset, 128)). IfTwilioProviderchunks identically and anOutwardMessageorHumanSummaryplaces a 2-charUTF-16 surrogate pair (e.g., emoji/non-BMP rune) across offset127..128, it emits lone surrogates thatSystem.Text.Json/ UTF-8 encoding replaces withU+FFFDor rejects, breaking echo verification (exact Twilio Verify PushDetails.FieldsUTF-8 byte vs code-point limit needs live-doc verification).OversizedCanonicalActionIsRejectedBeforeTransportsetsEffectBinding = new string('a', 1281)(~1,480+ total canonical chars) without testing the exact max boundary (maxallowed ->Pending,max + 1->Invalid).AlteredVisibleEchoDeniesCreateAndPolltests"missing-field"(RemoveAt(0)) but not an appended"extra-field"indetails.fields, andWrongProviderPinDeniestests a pastexpiration_date(2015-...) but not an extended futureexpiration_date > request.ExpiresUtc.DuplicateStatusDeniestests a duplicate key only on the root JSON object ("status"), not inside nested objects (hidden_details.actionHashordetails.fields[0].value).
- Fix: Add tests for: (a) a non-BMP character straddling chunk index
127..128(chunk onRune/UTF-8 boundaries); (b) exactmaxcanonical length succeeding andmax + 1returningInvalid; (c) appended trailingdetails.fieldselement andexpiration_date > request.ExpiresUtc; (d) duplicate"actionHash"insidehidden_details.
Backend Concurrency & Cancellation Coverage Audit (Jenny Focus)¶
- Parallel requests & locking: Not exercised.
ApprovedRequestCannotReplayexecutes two sequentialVerifyAsynccalls, andFakeReplayuses an unsynchronizedHashSet<Guid>and non-atomicCalls++. - Missing test:
ConcurrentVerifySameJtiApprovesAtMostOnce(makeFakeReplaythread-safe viaConcurrentDictionary<Guid, byte>+Interlocked.Increment, release 8+ parallelVerifyAsynctasks from aTaskCompletionSourcebarrier insideFakeVerifier.GetDecisionAsync, and assertAssert.Single(results, r => r.Decision == ApprovalDecision.Approved)with all peers returningDenied). - Rate limiters / outbound fan-out: Not exercised. Neither
429 Too Many Requestshandling inTwilioProvidernor bounding outboundGetDecisionAsynccalls against oversized/duplicateevidencearrays is tested. - Missing tests:
RateLimitedTwilioResponseReturnsProviderUnavailable(429status inTwilioTests) andExcessiveOrDuplicateEvidenceDoesNotFanOutToProvider(assertingharness.Calls == 0whenevidenceexceeds policy/registry bounds or repeatsPersonId). - Retries & idempotency: Partially exercised (1-of-1 non-consumption on
Pending/ProviderUnavailableat 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]replayDenied). - Cancellation flow: Not exercised.
FakeVerifier,FakeReplay,FakeClock, andFakeHandleracceptCancellationTokenwithout testing pre-cancelled or mid-flight cancellation. - Missing tests:
VerifyCancellationPropagatesAndNeverConsumesJti(cancel token duringOnFetch, assertOperationCanceledExceptionandReplay.Calls == 0) andTwilioDistinguishesCallerCancellationFromHttpClientTimeout.