Skip to content

security: verify content hash on LFS dedupe shortcut - #8333

Merged
unknwon merged 2 commits into
mainfrom
GHSA-6p9m-q3jp-47h4
Jun 7, 2026
Merged

unknwon merged 2 commits into
mainfrom
GHSA-6p9m-q3jp-47h4

Conversation

@unknwon

@unknwon unknwon commented Jun 7, 2026

Copy link
Copy Markdown
Member

Describe the pull request

The LFS upload handler took a shortcut when the on-disk object file already existed. It accepted the request, recorded the per-repository binding, and returned the existing file's size without checking that the request body actually hashed to the claimed OID.

A user with write access to one repository could bind their repository to an OID belonging to a private repository by sending a PUT containing any bytes, then read the original content back through their own download endpoint.

The dedupe path now hashes the request body and rejects the upload with ErrOIDMismatch when the content does not match the claimed OID, mirroring the verification the new-file path has always performed. Legitimate LFS client retries continue to work because they always replay the original bytes.

Refs GHSA-6p9m-q3jp-47h4.

Checklist

Test plan

  1. As one user, upload an LFS object to repository a/private so a file at <lfs-root>/<oid[0]>/<oid[1]>/<oid> exists.
  2. As a different user with write access only to b/scratch, send PUT /b/scratch.git/info/lfs/objects/basic/<oid> with arbitrary bytes.
  3. Before this change: response is 200 OK and the user can subsequently download the original a/private bytes via GET /b/scratch.git/info/lfs/objects/basic/<oid>.
  4. After this change: response is 400 Bad Request with content hash does not match OID and no per-repository binding is created for b/scratch.
  5. A legitimate retry of the same upload with the original bytes still succeeds and reuses the existing on-disk object.

@unknwon unknwon added this to the 0.14.3 milestone Jun 7, 2026
@unknwon
unknwon merged commit f35a767 into main Jun 7, 2026
8 checks passed
@unknwon
unknwon deleted the GHSA-6p9m-q3jp-47h4 branch June 7, 2026 03:03
unknwon added a commit that referenced this pull request Jun 7, 2026
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.

1 participant