Skip to content

Bound symlink blob reads#18

Closed
elithrar wants to merge 3 commits intomainfrom
bound-readlink-blob
Closed

Bound symlink blob reads#18
elithrar wants to merge 3 commits intomainfrom
bound-readlink-blob

Conversation

@elithrar
Copy link
Copy Markdown
Collaborator

@elithrar elithrar commented May 5, 2026

Bounds symlink blob reads so readlink rejects 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.

  • Reject known oversized symlink blobs before any hydrator call.
  • Treat negative known symlink sizes as corrupt metadata.
  • Add bounded blob reads through hydrator/gitstore for unknown-size symlinks.
  • Preserve shared cache entries when caller-specific caps are exceeded, and cancel blocked cat-file reads 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 ./...

Nadav0077 and others added 3 commits April 19, 2026 00:16
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))
@elithrar elithrar mentioned this pull request May 6, 2026
@elithrar
Copy link
Copy Markdown
Collaborator Author

elithrar commented May 6, 2026

Superseded by #19, which uses a new branch under cloudflare/artifact-fs and includes the follow-up CodeQL allocation bound fix.

@elithrar elithrar closed this May 6, 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.

3 participants