Skip to content

fix: escape remote text in terminal output and refuse unsafe names on git export - #365

Merged
tonibergholm-codento merged 18 commits into
mainfrom
fix/sc-hygiene
Nov 20, 2026
Merged

tonibergholm-codento merged 18 commits into
mainfrom
fix/sc-hygiene

Conversation

@tonibergholm-codento

Copy link
Copy Markdown
Collaborator

An audit found five small ways untrusted repository content or remote text could misbehave once it left sc:

  1. Git export copied names unchecked. A hostile sc tree could produce Git entries named .git or .gitmodules, or names with /, \ or NUL. Export now checks names where it writes a new Git tree, using gix's own validator for the .git/.gitmodules HFS and NTFS aliases. The ref and the mirror push do not move on refusal.
    • Not re-checked: commits reused through marks are not rewritten, so they are not re-checked. Commits an older client already wrote into a mirror are pushed as they are, subject to the receiver's own fsck.
    • On refusal: export never removes a target, since another export may be writing into it. A later export adopts a bare, ref-less target with a symbolic HEAD and points that HEAD at the exported ref.
    • Symlinks: they export as Git symlinks, as before.
  2. Terminal escapes in remote text. Server error text, commit authors and messages in sc log, transcript rows and ref-name diagnostics can carry ANSI or OSC escapes and bidi controls. They are now escaped when displayed. One-line output also escapes \n, \r and \t, so a commit message cannot fake a signature-status line. Stored values and wire payloads stay raw; wire framing and error codes are unchanged.
  3. The serve token file was not owner-only. serve-tokens.toml is now written owner-only (0600) on create, rotate and remove.
  4. DEKs could reach Debug output. IndexEntry and BranchIndex in crates/crypto now have redacting Debug impls.
  5. Open identity files went unnoticed. On unix, sc warns once when an identity file is readable by group or others, as ssh does.

Also recorded in the threat model: sealed blobs use constant associated data, so a writer can move a sealed blob to another path or roll it back. Binding the path would force a reseal on every rename, so integrity of placement comes from signed commits.

Proof: tests for each item, several checked to fail without the fix:

  • export_refuses_hostile_name_before_any_ref_moves: refusal, then a clean retry to a non-default ref with readable HEAD, then a pre-existing repo left untouched.
  • only_snapshots_that_will_be_written_are_name_checked.
  • The CLI test network_push_checks_names_only_in_commits_the_server_lacks.
  • log_line_escapes_terminal_controls_from_author_and_message.
  • error_text_crosses_the_wire_raw_and_is_escaped_once_on_display.
  • token_file_is_owner_only_after_add_rotate_and_remove.
  • debug_output_never_contains_dek_bytes.

cargo test -p scl-gitio -p scl-core -p scl-repo -p scl-cli and workspace clippy pass.

Reviewed with sol-loop: 5 rounds with gpt-6.2-sol. Sol verdict: changes requested in round 5 (a failed export's cleanup could delete a concurrent export's branch). Fixed after the budget ended by removing the cleanup entirely, then checked by an independent Opus review, whose suggestions are applied.

Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: abfca6cd-13c5-40c2-9842-ae7c14d55e89
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T09:53:20.809889Z 4d412a0 New commits
🔒 Security Review ✅ Completed 2026-11-20T09:57:00.410905Z 4d412a0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tonibergholm tonibergholm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: sol-loop (5 rounds; last item fixed by removing export cleanup), independent Opus review of the final change, all checks green, Codex review has no findings.

@tonibergholm-codento
tonibergholm-codento merged commit 24178f3 into main Nov 20, 2026
11 checks passed
@tonibergholm-codento
tonibergholm-codento deleted the fix/sc-hygiene branch November 20, 2026 10:02
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.

2 participants