Conversation
Git stores a symlink target as the raw blob body, so the size of the target is controlled by the repository. ReadSymlink was calling os.ReadFile on the hydrated blob with no cap, which means a single readlink(2) against a hostile repo could drive an arbitrarily large allocation (and on blobless clones, a large lazy fetch). Read through an io.LimitReader bounded at 4096 bytes (Linux PATH_MAX) and return ENAMETOOLONG past that. Tests cover the empty, short, at-limit, over-limit, far-over-limit, and missing-cache paths.
| if size > maxBytes { | ||
| return nil, model.ErrBlobTooLarge | ||
| } | ||
| data := make([]byte, int(size)) |
Merged
Collaborator
Author
|
Superseded by #19, which uses a new branch under cloudflare/artifact-fs and includes the follow-up CodeQL allocation bound fix. |
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.
Bounds symlink blob reads so
readlinkrejects oversized or corrupt targets before full hydration.This follows the size-validation gap identified while reviewing #14: signed and unknown sizes need to be handled before exposing data through FUSE.
cat-filereads by killing the batch process.Tests:
go build -o /var/folders/8z/p566f43s64s7slbbvbl1b3_00000gn/T/opencode/artifact-fs-review ./cmd/artifact-fs && go vet ./... && go test ./...