Skip to content

fix: hardening for tus signed - #1492

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/tus-signed
Oct 8, 2026
Merged

ferhatelmas merged 1 commit into
masterfrom
ferhat/tus-signed

Conversation

@ferhatelmas

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Signed resumable uploads derive their request context from URL string matching, which can lead to inconsistent handling and generated upload locations. Some early TUS responses also skip database connection cleanup.

What is the new behavior?

Track signed-upload context explicitly through the registered routes and upload lifecycle. Use that context when generating upload URLs, and release database connections when TUS responses close.

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas requested a review from a team as a code owner October 8, 2026 10:14
Copilot AI balanced review requested due to automatic review settings October 8, 2026 10:14

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ferhatelmas
ferhatelmas enabled auto-merge (squash) October 8, 2026 10:15
@ferhatelmas
ferhatelmas merged commit db42280 into master Oct 8, 2026
34 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/tus-signed branch October 8, 2026 10:21
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37762210411

Coverage increased (+0.07%) to 84.946%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 22 of 22 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14530
Covered Lines: 12795
Line Coverage: 88.06%
Relevant Branches: 8966
Covered Branches: 7164
Branch Coverage: 79.9%
Branches in Coverage %: Yes
Coverage Strength: 785.03 hits per line

💛 - Coveralls

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Beyond the bug hunter's ruled-out note, I checked that onIncomingRequest (which now calls verifySignedUploadRequest) always runs before onCreate in the @ tus/server POST/create lifecycle, so the unguarded findBucket in onCreate is still preceded by signature verification for signed uploads — consistent with the ruled-out finding. I also confirmed the new reply.raw.once('close', ...) dispose hook and the explicit verifySignedUploadRequest call in maxSize match their test coverage (index.test.ts, src/test/tus.test.ts).

Extended reasoning...

The diff reworks TUS signed-upload detection from URL-string matching to an explicit route-registered boolean threaded through request context, extracts signature verification into an idempotent helper now also invoked from the PATCH/maxSize path, and relocates DB-connection disposal to a single reply-level 'close' listener. It touches authentication/signature-verification logic for uploads, a security-sensitive surface, but the change is well-covered by updated/new tests (including an integration test exercising encoded-URL bypass attempts against the old string-matching approach) and the one candidate gap (onCreate lacking direct verification) is moot given onIncomingRequest always runs first in the tus-server lifecycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants