You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to update all LFS API requests to send the remote ref. This gives the servers opportunities to tweak how locks are stored or authorization is checked for repositories based on the ref being updated.
As of LFS v2.4.0, the client will always send a ref with API calls. Servers that want to support these fields in a future proof manner can look for the following requests:
// LFS 2.3 and below// absent 'ref' property// servers should retain existing behavior// POST locks/verify
{ "limit": 100 }
// LFS 2.4.0// valid 'ref'// servers should use ref in authz check// POST locks/verify
{ "ref": { "name": "master" }, "limit": 100 }
// LFS 2.4.0// empty 'ref', client had problems finding it// servers should retain existing behavior// POST locks/verify
{ "ref": null, "limit": 100 }
Open question: This is currently sending a relative ref name, like "master" or "feature-branch." Should it instead try to send an absolute ref name, like "refs/heads/feature-branch"?
EDIT: Yes, the client should send a full refspec to the LFS server 👍
I have a few questions that I think would be good to discuss before I work on fleshing the rest of this project out:
Should we expect implementations of the specification to trust the references that the client is sending with their API request? It is my understanding that if a malicious actor were to intercept the communication between Git LFS and a server (via a reverse proxy/modified client) they could send refs that they do/don't own and upload objects that the owner of a repository would otherwise not want.
I am not sure how to reconcile between things that are inherently "ref-oriented" and things that aren't. What I'm thinking of specifically is the difference between the locking API and the batch API. The locking API (today) locks files at revisions, meaning that it is "easy" to determine which references to send. The batch API is inherently "ref-agnostic" in that it sends a set of objects, not necessarily on a given ref. For instance, if we run git push origin master my-feature etc sending a single batch request would theoretically be possible if we did not also have to indicate which refs are being transferred. Git will send us each ref update as a single LF-terminated string over the pre-push hook, but sending each ref individually in the batch API request would force us to sometimes have to split up batch requests that would otherwise not have to be.
It is my understanding that if a malicious actor were to intercept the communication between Git LFS and a server (via a reverse proxy/modified client) they could send refs that they do/don't own and upload objects that the owner of a repository would otherwise not want.
They could also read your files, which I think would be the bigger risk of using a malicious proxy or client. I don't think there's a lot we can do about this. Our services all use HTTPS, and we provide a digitally signed client. Ref-based authentication in Git already exists in various Git hosts. Is there any other way to solve this?
You are correct that this change means the client may be making more Batch API requests than necessary. Batch API requests aren't a major bottleneck with LFS transfers, and most Git pushes only update a single ref. The vast majority of the problems have been related to the storage layer, or authentication issues with the LFS API.
It is my understanding that if a malicious actor were to intercept the communication between Git LFS and a server (via a reverse proxy/modified client) they could send refs that they do/don't own and upload objects that the owner of a repository would otherwise not want.
They could also read your files, which I think would be the bigger risk of using a malicious proxy or client. I don't think there's a lot we can do about this.
Agreed. I don't know if there is a whole lot we can do about it either, and this isn't really a "new" problem so to speak, so I think leaving it as-is is fine.
EDIT:
You are correct that this change means the client may be making more Batch API requests than necessary. Batch API requests aren't a major bottleneck with LFS transfers, and most Git pushes only update a single ref.
Ah, I hadn't thought of this. I suppose that there is a non-zero amount of time introduced in executing another batch API request, but the 1-ref update case is vastly more common than the n-ref case, at least I would bet so.
Another thing to keep in mind is that the uploadContext is still tracking unique object OIDs. If you're pushing 5 refs to a new remote, the 2nd-5th refs will only attempt to transfer objects unique to that ref. If the first commit ever added an LFS object, it won't be added to a transfer queue 5 times.
This change is not currently on my roadmap, so I am going to close it for now. If anyone is interested in picking this change up before then, please let me know here and I would be more than happy to point people in the right direction.
Activity
ttaylorr commentedon Dec 18, 2017
I have a few questions that I think would be good to discuss before I work on fleshing the rest of this project out:
Should we expect implementations of the specification to trust the references that the client is sending with their API request? It is my understanding that if a malicious actor were to intercept the communication between Git LFS and a server (via a reverse proxy/modified client) they could send refs that they do/don't own and upload objects that the owner of a repository would otherwise not want.
I am not sure how to reconcile between things that are inherently "ref-oriented" and things that aren't. What I'm thinking of specifically is the difference between the locking API and the batch API. The locking API (today) locks files at revisions, meaning that it is "easy" to determine which references to send. The batch API is inherently "ref-agnostic" in that it sends a set of objects, not necessarily on a given ref. For instance, if we run
git push origin master my-feature etcsending a single batch request would theoretically be possible if we did not also have to indicate which refs are being transferred. Git will send us each ref update as a single LF-terminated string over thepre-pushhook, but sending each ref individually in the batch API request would force us to sometimes have to split up batch requests that would otherwise not have to be.technoweenie commentedon Jan 2, 2018
They could also read your files, which I think would be the bigger risk of using a malicious proxy or client. I don't think there's a lot we can do about this. Our services all use HTTPS, and we provide a digitally signed client. Ref-based authentication in Git already exists in various Git hosts. Is there any other way to solve this?
You are correct that this change means the client may be making more Batch API requests than necessary. Batch API requests aren't a major bottleneck with LFS transfers, and most Git pushes only update a single ref. The vast majority of the problems have been related to the storage layer, or authentication issues with the LFS API.
ttaylorr commentedon Jan 3, 2018
Agreed. I don't know if there is a whole lot we can do about it either, and this isn't really a "new" problem so to speak, so I think leaving it as-is is fine.
EDIT:
Ah, I hadn't thought of this. I suppose that there is a non-zero amount of time introduced in executing another batch API request, but the 1-ref update case is vastly more common than the n-ref case, at least I would bet so.
technoweenie commentedon Jan 4, 2018
Another thing to keep in mind is that the
uploadContextis still tracking unique object OIDs. If you're pushing 5 refs to a new remote, the 2nd-5th refs will only attempt to transfer objects unique to that ref. If the first commit ever added an LFS object, it won't be added to a transfer queue 5 times.ttaylorr commentedon Mar 3, 2018
This change is not currently on my roadmap, so I am going to close it for now. If anyone is interested in picking this change up before then, please let me know here and I would be more than happy to point people in the right direction.