Repository navigation
Conversation
The TUS protocol spec requires the Upload-Checksum header value to be base64-encoded. The TusPhp client (used in acceptance tests) always sends base64. checkHash() was comparing the raw base64 string against hex.EncodeToString(), which never matches, so every upload that sent a checksum received HTTP 460 Checksum Mismatch. Decode from base64 first (using h.Size() to verify the decoded length matches the expected hash); if decoding succeeds, convert to hex before comparing. Plain hex values (from direct API callers) fall through unchanged, so backward compatibility is preserved. Relates to #879 (which re-enabled checksum validation but missed the encoding difference between TUS clients and the internal hex format). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Martin Mattel <github@diemattels.at>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This was referenced Dec 3, 2026
mmattel
added a commit
to owncloud/ocis
that referenced
this pull request
Dec 3, 2026
The TUS protocol spec requires the Upload-Checksum header value to be base64-encoded. The TusPhp client (used in acceptance tests) always sends base64. checkHash() was comparing the raw base64 string against hex.EncodeToString(), which never matched, so every upload that sent a checksum received HTTP 460 Checksum Mismatch. Decode from base64 first (using h.Size() to verify the decoded length matches the expected hash size); if decoding succeeds, convert to hex before comparing. Plain hex values fall through unchanged. Upstream fix: owncloud/reva#883 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Martin Mattel <github@diemattels.at>
This was referenced Dec 3, 2026
Open
For multi-chunk TUS uploads each PATCH carries the checksum of that chunk only, not the whole-file checksum. Storing a per-chunk checksum for FinishUpload whole-file validation caused every chunked upload with per-chunk checksums to fail with 460 Checksum Mismatch. Restrict SetChecksum() to single-chunk uploads: offset == 0 and Content-Length equals the declared upload size. For multi-chunk uploads the Upload-Checksum header is silently ignored, preserving the existing behaviour that tusd v2 established when it dropped per-chunk validation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Martin Mattel <github@diemattels.at>
mklos-kw
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Follows up on #879, which re-enabled
Upload-Checksumvalidation for TUS uploadsbut introduced a silent regression: the TUS spec requires the checksum value to be
base64-encoded, while
checkHash()compared it againsthex.EncodeToString().Since base64 ≠ hex the comparison always failed, returning HTTP 460 on every upload
that sent a checksum.
Root cause
TUSContext.php(the PHP acceptance-test client) callssetChecksumAlgorithm('sha1'),so every TUS upload sends
Upload-Checksum: sha1 <base64-sha1>.checkHash()callshex.EncodeToString(h.Sum(nil))and compares directly — base64 never equals hex, soevery upload failed with 460 Checksum Mismatch.
Failing test suites (detected via owncloud/ocis PR #13666):
apiSpaces/tusUpload.feature,apiSpaces/filePreviews.featurecoreApiWebdavUploadTUS/uploadToShare.feature,uploadFileMtimeShares.featureapiSearch1,natsJwt-events-stores-file,cliCommands/uploadSessions.featureFix
In
checkHash, trybase64.StdEncoding.DecodeString(expected)first. If itsucceeds and the decoded length matches
h.Size(), convert to hex beforecomparing. Plain hex values (legacy / direct API callers) fall through unchanged,
so backward compatibility is preserved.
References
🤖 Generated with Claude Code