Skip to content

reference: keep get destinations inside the target - #2129

Merged
martindurant merged 1 commit into
fsspec:masterfrom
stanislavfort:reference-get-check-contained
Sep 11, 2026
Merged

reference: keep get destinations inside the target#2129
martindurant merged 1 commit into
fsspec:masterfrom
stanislavfort:reference-get-check-contained

Conversation

@stanislavfort

@stanislavfort stanislavfort commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

ReferenceFileSystem.get() allows reference keys containing .. to write outside the caller-provided destination. This can overwrite local files when materializing an untrusted reference specification.

#2103 added containment checks to the standard sync and async get() paths, but ReferenceFileSystem overrides get() and writes its targets directly, so it bypasses those checks.

This change applies the existing check_contained() helper before any reference data is fetched or written.

Tests

  • Rejects targets that resolve outside the destination.
  • Confirms an existing outside file is not overwritten.
  • Preserves .. paths that still resolve inside the destination.

Full ReferenceFS test module: 24 passed, 13 skipped.

Prevent reference-controlled paths from escaping the caller-selected local
destination, while preserving paths that normalize within it.
@stanislavfort
stanislavfort force-pushed the reference-get-check-contained branch from 0cc0c5e to 08c49cc Compare September 11, 2026 09:28
@martindurant
martindurant merged commit be32e2b into fsspec:master Sep 11, 2026
11 checks passed
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