Skip to content

Always index locally for prefetch packs #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

tyrielv
Copy link
Contributor

@tyrielv tyrielv commented Jun 13, 2025

The GVFS protocol includes an index file along with pack file in the prefetch workflow (primarily used on a new clone to fetch all commits and trees).

Currently, GVFS accepts that index file without any verification.

This pull request changes GVFS prefetch to discard the index sent by the server and always create an index locally. This provides improved security and verification of the pack file, at the expense of performance for the first clone of a repository with a new local cache.

The GVFS protocol includes an index file along with pack file in the prefetch
workflow (primarily used on a new clone to fetch all commits and trees).

Currently, GVFS blindly accepts that index file.

This pull request changes GVFS prefetch to discard the index sent by the
server and always create an index locally. This provides improved security
and verification of the pack file, at the expense of performance for the first
clone of a repository on a new drive.
@mjcheetham mjcheetham requested review from dscho and mjcheetham June 13, 2025 09:21
Copy link
Member

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

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

Thanks for being vigilant here! Of course this will result in a performance penalty, but security is more important.

Comment on lines +709 to +710
// We can't trust the index file from the server, so we will always build our own.
// We still need to consume and handle any exceptions from the index stream though.
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we may want to add an option to use the pack index as given by the server (default to ignore it of course) for performance critical scenarios where we can also trust the server.

For now let's just be safe and never trust the pack index, and can add this in the future if needed.

@mjcheetham mjcheetham merged commit 2b251c0 into microsoft:master Jun 13, 2025
5 checks passed
@mjcheetham mjcheetham mentioned this pull request Jun 13, 2025
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.

2 participants