Skip to content

docs(protocol): audit Windows path separator wire encoding (#1905) - #3497

Merged
oferchen merged 1 commit into
masterfrom
fix/audit-windows-path-separator-encoding-1905
May 1, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/audit-windows-path-separator-encoding-1905

Conversation

@oferchen

@oferchen oferchen commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds docs/audits/windows-path-separator-encoding.md confirming that every sender-side wire-emit site for filenames and symlink targets routes through the path_bytes_to_wire helper, normalizing native \ separators to / on Windows before bytes leave the host.
  • Marks Finding F1 in docs/audits/windows-path-normalization.md as CLOSED with cross-references to the implementing PR (fix: normalise Windows backslash to forward slash in wire-encoded paths #3456) and this confirming audit.
  • Documents the central helper, the six wire-emit call sites, the four non-wire path-byte sites that intentionally do not normalize, and the per-platform regression test matrix.

This is the sender-side counterpart to PR #3496 (receiver-side rejection of Windows drive prefixes from untrusted senders). Together they cover the bidirectional Windows path-separator hazard surface.

Why docs-only

Investigation found the conversion is already correctly applied at every wire-emit call site:

  • crates/protocol/src/flist/entry/accessors.rs:131-135 (name_bytes()).
  • crates/protocol/src/flist/write/encoding.rs:115-124 (write_symlink_target).
  • crates/protocol/src/flist/write/mod.rs:376 (single bytes path into write_name).
  • crates/protocol/src/flist/batched_writer/writer.rs:216 (delegates to FileListWriter::write_entry).
  • crates/transfer/src/generator/protocol_io.rs:240,310 (initial flist + INC_RECURSE segments).
  • crates/engine/src/local_copy/executor/directory/recursive/batch.rs:152 (batch capture).

Test matrix verified in crates/protocol/src/flist/wire_path.rs:62-136, including windows_backslash_is_translated_to_forward_slash, windows_deep_path_is_translated, windows_already_forward_slash_borrows, and windows_mixed_separators_are_normalized.

Per upstream flist.c:send_file_entry() (lines 534-570 for filename, 660-670 for symlink target), filename bytes are written verbatim and the wire format requires POSIX / separators - upstream's only Windows port runs under Cygwin's POSIX layer, so upstream itself never normalizes.

Test plan

  • No code changes - documentation only.
  • CI fmt+clippy and Linux/macOS/Windows/Linux-musl matrices pass.
  • Existing path_bytes_to_wire regression tests continue to pass (no behaviour change).

Confirms that every sender-side wire-emit site for filenames and
symlink targets routes through `path_bytes_to_wire`, normalizing
native `\` to `/` on Windows. Retires Finding F1 from
`windows-path-normalization.md`. Receiver-side counterpart already
landed in PR #3496.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 1, 2026
@oferchen
oferchen merged commit 22d96d0 into master May 1, 2026
11 checks passed
@oferchen
oferchen deleted the fix/audit-windows-path-separator-encoding-1905 branch May 1, 2026 21:09
oferchen added a commit that referenced this pull request May 5, 2026
…3497)

Confirms that every sender-side wire-emit site for filenames and
symlink targets routes through `path_bytes_to_wire`, normalizing
native `\` to `/` on Windows. Retires Finding F1 from
`windows-path-normalization.md`. Receiver-side counterpart already
landed in PR #3496.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant