Skip to content

fix: authenticate cached multipart completion replays - #242

Closed
perfloop[bot] wants to merge 7 commits into
mainfrom
perfloop-pr-open-ss5adtkn2d
Closed

perfloop[bot] wants to merge 7 commits into
mainfrom
perfloop-pr-open-ss5adtkn2d

Conversation

@perfloop

@perfloop perfloop Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Multipart-completion replays are now bound to the access key that completed the upload. Transparent mode rechecks that caller's bucket grant after the completion-cache read, so a revocation completed while the read is pending cannot authorize the cached response.

TAG stores the access key with each fully captured successful completion. Signing mode validates the replay's SigV4 signature; transparent mode binds the identity learned from a successful upstream response or a validated request-start snapshot, then checks the current grant. The exported cache helpers cache.GetCompletion and cache.PutCompletion now carry that caller identity. The exact bucket, object key, and upload ID still define the tuple, and delimiter-containing components are encoded to avoid collisions. The five-second TTL is unchanged, and no S3 route or configuration option was added.

TestCompleteMultipartUploadReplayAuthorization covers transparent and signing modes, same-principal and presigned retries, unbound entries, anonymous or invalid callers, different principals and buckets, delimiter aliases, and misses. Its revocation case blocks the completion-cache read while a concurrent request receives upstream 403 and revokes the grant; after release, the replay follows the normal upstream denial path. The expiry case waits for upstream entry and releases after the signature-age cutoff instead of using fixed sleeps. A fast cold-auth identity-learning case remains. The upstream is controlled; these tests do not establish live Tigris behavior or a deployment exploit.

The README and S3 compatibility guide document the replay rule. The multipart operation table stays concise; its duplicate note was removed. The single-node integration-cache fixture binds memberlist to loopback as test setup.

The assertion was violated on comparison revision 36d0c890b3efa8c19beeb1d56154a7a4f42d813a and satisfied on the final source. The recorded check was invoked with go run ./.perfloop_claim/completion_replay_claim.go.

Recorded proof ran with retained support that is not included in this pull request.

The recorded repository checks passed: make test, make lint-ci, make test-race, make test-coverage, make test-integration, and make lint.

Target CI also runs:

  • S3 Compatibility Tests / s3-compat-tests (default, tiered)
  • S3 Compatibility Tests (Cluster) / s3-compat-tests-cluster (default)
  • Lint PR Title / lint

Generated by Perfloop. Measurements and checks. Reproduce this comparison (tenant access required).


Note

High Risk
This changes authorization for a cache that can return successful completion bodies and ETags; a bug could leak completion metadata across principals.

Overview
Multipart completion replay is now authenticated and caller-scoped. TAG only caches a fully captured successful CompleteMultipartUpload when it can validate the caller at request start, stores the access key with the five-second entry, and replays only to that same principal for the exact bucket, key, and upload ID. Other callers are forwarded upstream; legacy entries without a saved identity are treated as misses.

cache.GetCompletion / PutCompletion now require an access key. MakeCompletionKey URL-encodes components that contain | so distinct tuples cannot collide. HandleCompleteMultipartUpload resolves the principal via completionPrincipal (including presigned completions via an UNSIGNED-PAYLOAD validation clone) and re-validates authorization after a slow completion-cache read so a revoked bucket grant cannot replay a cached success.

README and S3 compatibility docs describe the new replay rules. Unit, proxy, and a large integration suite cover cross-principal denial, presigned retry, delimiter aliases, cold transparent auth, and grant revocation during cache read. Integration test setup can inject a custom cache client and binds the embedded cache memberlist to loopback.

Reviewed by Cursor Bugbot for commit e2afe03. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

This PR binds cached multipart completion responses to the caller's access key.

  • TAG replays multipart completion responses only to the caller who completed the upload.
  • The integration cache binds its single-node cluster to loopback.

The three supplied previous threads are unnumbered, so they have no numbered ledger entries. The revoked-grant check now runs after the cache read. The repeated table note is gone. The expiry test waits for upstream entry before releasing the response after the signature cutoff; the cold-auth test has no delay.

The previous and current revisions have different merge bases with the target commit, so this review used the full PR diff. No runtime checks were run.

Reviews (3) · Last reviewed commit: "test(proxy): remove duplicate lockedLogB..." · Reviewed by Greptile

Comment thread proxy/service.go Resolved
Comment thread docs/s3-compatibility.md Resolved
@perfloop
perfloop Bot force-pushed the perfloop-pr-open-ss5adtkn2d branch from 36cf4d9 to dc07b3c Compare October 2, 2026 09:48
ovaistariq and others added 2 commits October 21, 2026 14:34
…replays

Resolve conflicts with #248 (read-only authz grants), #266 (presigned
validation), #245 (status recorder) and the other forwarder changes by
keeping main's forwarder, interceptor and signing-key learning code as-is,
and applying the principal binding only where it is load-bearing:

- cache.CompletionEntry records the access key that completed the upload;
  GetCompletion(.., accessKey) only hits for that key, PutCompletion refuses
  an empty key, and the delimiter-alias key fix is kept.
- HandleCompleteMultipartUpload identifies the caller once at request start
  through RequestForwarder.ValidateAndGetCredentials + auth.ParseAuthInfo
  (presigned POSTs get the UNSIGNED-PAYLOAD marker on a clone for
  validation), re-validates after the cache read before replaying so a grant
  revoked during a remote read cannot be replayed past, and binds the saved
  response to the request-start principal.

This drops the two forwarder interfaces, the callback-shaped GetCompletion,
the ResponseInterceptor signature change and the ResponseCapture field from
the PR; none are needed on main. With #248, a transparent-mode completion by
a principal without a bucket read grant is not cached (fewer replays, never
less safe); the cold-auth integration test now asserts that, and the
transparent subtest seeds the principal as if it had already read.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
#238 and #256 each added an identical lockedLogBuffer to the proxy test
package, so it no longer compiles on main. Keep the copy in
lifecycle_test.go.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6

@ovaistariq ovaistariq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: cached CompleteMultipartUpload replays are now bound to the validated principal (snapshot at request start, re-checked after the cache read) and forwarded upstream on any mismatch, closing the unauthenticated replay window. Rebased on main with the binding done through the existing ValidateAndGetCredentials and ParseAuthInfo, no new interfaces.

@ovaistariq ovaistariq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving after rebase review.

@ovaistariq

Copy link
Copy Markdown
Contributor

Closing: approved and green, but the branch ruleset requires signed commits and this PR's two original commits (36d0c89, dc07b3c) are unsigned, so the merge is blocked. The identical change, rebased on main and simplified onto the existing ValidateAndGetCredentials/ParseAuthInfo path, is re-submitted as a single signed commit on a fresh branch.

@ovaistariq ovaistariq closed this Oct 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants