Skip to content

No mechanism separates platform-neutral URIs from platform-native paths #547

Closed

Description

@David-Noble-at-work

There is no mechanism. Each site decides for itself whether it is in the neutral world or the native
one, usually with a comment explaining the local reasoning, and the decisions are made on heuristics like
"this is planning, so use slash separators because the path might be used on any operating system."

That framing is wrong-headed. Whether separators are neutral is not a function of when the code runs.
It is a function of what the value is: identity, or access. Planning-versus-execution is a proxy that
happens to correlate, and proxies drift — which is why this defect keeps being rediscovered one site at a
time rather than fixed once.

The evidence: the same bug, found five separate times

Found as Site Disposition
#377 fsroot.Path.Rel() returned OS-native separators, making serialized documents and checksums platform-dependent fixed
#395 file.Find's matcher was not slash-native fixed
2026-08-18 Provider.Name / Parent / Join used filepath, so Name("/") answered \ on Windows fixed
2026-08-18 commonAncestor split on filepath.Separator, answering \home\user for two /home/user inputs fixed
2026-08-18 the file resource's identity was "file://" + Abs(), putting backslashes inside a URI fixed

Five discoveries, five local fixes, no shared rule. The sixth is waiting.

What the shape of a fix looks like (not a design — a constraint on one)

  • Identity is neutral by construction, not by remembering. A URI carrying a backslash should be
    impossible to build, not merely discouraged — the same argument as Slice accessors alias the graph's internal storage #532 and Pointers to mutable containers escape the package boundary #533 for graph mutation.
  • Normalization happens on fetch, for use. A provider method performing an action asks for the path and
    gets it native. Nothing else converts.
  • fsroot.Path already holds both forms — Rel() canonical slash, Abs() native — so the type is the
    natural place for the distinction to become enforceable rather than conventional. Note String() returns
    abs, so any %s of a Path is native, including inside anything that later gets serialized.

Not being designed here. This records the defect and the rule so the next instance is recognized as the
same bug rather than filed as a new one.

Activity

  1. David-Noble-at-work commented on Aug 18, 2026

    @David-Noble-at-work
    ContributorAuthor

    Where the transform belongs (ruled 2026-08-18)

    At resource construction, not along the way. The resource owns the transform.

    Passing an absolute path — say from fsroot.Path.String() — to build a file resource is the moment of
    normalization. From then on the resource answers two questions with two forms, and no caller has to know
    which world it is in:

    Ask for Get
    the path what fsroot.Path.String() returned — platform-native, ready for the filesystem
    the URI specific part the platform-neutral form — slashes, never backslashes

    That is strictly better than the framing I filed, and #548 proved it the expensive way.

    Demonstrated 2026-08-18

    I normalized identity at one site — "file://" + ToSlash(Abs()) in buildCandidateAs — and four
    consumers broke
    , because they key on the native form: TestBuildReport_Classifications,
    TestWalkTree_ReducerError_StackHoldsCompletedReceipts, TestExecute_RedeployFlowsUnderDefault, and
    TestExecute_StaleSourceRegeneratesFreely. The last is the instructive one: drift detection stopped
    seeing a stale file, so a partial normalization did not merely fail a comparison — it silently changed
    behavior
    .

    Reverted, with the reason recorded at the site. It is the "along the way" fix this bug exists to prevent,
    and it cannot work until the resource owns both forms.

  2. added 2 commits that reference this issue on Aug 18, 2026
    f0a061e
    1c34ce7
  3. David-Noble-at-work commented on Aug 19, 2026

    @David-Noble-at-work
    ContributorAuthor

    The sixth, and the first that is a security defect rather than a correctness one.

    containedLinkTarget in the archive provider asks filepath.IsAbs whether an archive entry's symlink
    target is absolute. On Windows a POSIX-absolute target is rooted but not absolute, so the guard returns
    nil and the link is materialized verbatim, pointing outside the extraction root.

    It belongs in this issue's table because it is the same defect, not a relative of it: a string carrying
    archive-format syntax evaluated under the extracting host's rules, with no resource owning the transform
    between the two worlds.

    Worth noting for the argument this issue already makes -- that local fixes keep rediscovering it -- the
    previous five were wrong answers. This one is an unenforced containment boundary, found only because a test
    happened to run on windows.

    Filed separately with the construction rule as its scope.

  4. David-Noble-at-work commented on Aug 21, 2026

    @David-Noble-at-work
    ContributorAuthor

    The sixth discovery, found and fixed (2026-08-21). The rel-identity mint (#584 PR 1, #596) put rels
    inside identity, and its foreign-scheme pin immediately caught the next instance on Windows:
    fsroot.makePath's rel half was not platform-neutral. Windows filepath.Clean guards a first segment
    containing a colon with a leading ./ (the CVE-2022-41722 drive-relative disambiguation), so the same
    input produced rel ./https:/example.com/x on Windows and https:/example.com/x elsewhere — an OS guard
    riding into identity.

    Found as Site Disposition
    #596 CI fsroot.makePath rel half used OS-form Clean, so Windows' ./ colon guard entered the rel fixed

    Fixed per this issue's own rule — in the type, not at a call site: fsroot.canonicalRel (slash-path Clean
    after separator normalization) now renders every rel in both makePath branches and fsroot.NewPath, with
    a platform-neutrality pin (TestRoot_NewPath_ColonSegmentRelIsPlatformNeutral) that runs on all three CI
    platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions