Skip to content

Reject invalid UTF-8 in trusted workflow blobs - #1614

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/1605-strict-workflow
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/1605-strict-workflow

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Reject invalid UTF-8 in trusted workflow blobs

Context and goal

  • Goal: Reject malformed bytes before any command runs.
  • Problem: A real Git fixture succeeded after replacing a byte inside a trusted command.
  • Context: Git still resolves the same trusted ref. Decoder failures report the existing source label.

Closes #1605

Acceptance

  • The explicit-file and trusted-Git forms must both identify the workflow source and reject invalid UTF-8.
  • Focused reproduction and existing surrounding cases pass.

Base

Base: 09fad5b

Validation

Recorded for 028e9d058d2e

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 028e9d0, approve

Architecture-Review: unchanged; Git still resolves the same trusted ref. Decoder failures report the existing source label.

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero primary review by claude on 028e9d058d2e649a73d4e69e82669764d12d205e, 15.9s: approve (0 critical, 0 important, 2 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/config.py
raise ConfigError(f"cannot read {source}. {hint}")
try:
data = tomllib.loads(shown.stdout)
data = tomllib.loads(shown.stdout.encode("utf-8", errors="surrogateescape").decode("utf-8"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Surrogateescape round-trip is roundabout

With preserve_newlines=True, _proc.run decodes stdout with errors="surrogateescape" (_proc.py:170). This change re-encodes that output to get the raw bytes back, then decodes it strictly. The result is correct: invalid bytes now raise instead of being silently replaced with U+FFFD as in the old text mode. But it depends on an internal detail of _proc.run's error handler, so it can break silently if that detail changes. The encoding is also passed in two places that must stay in sync. A simpler fix is to let _proc.run decode strictly or return raw bytes, then pass the bytes to tomllib.loads(raw.decode("utf-8")).

Comment thread src/loopzero/config.py
data = tomllib.loads(shown.stdout)
data = tomllib.loads(shown.stdout.encode("utf-8", errors="surrogateescape").decode("utf-8"))
except UnicodeDecodeError as exc:
raise ConfigError(f"{source}: {exc}") from exc

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Trusted-Git UTF-8 error omits the recovery hint

Every other error from _remote_workflow adds . {hint}, which tells the user to fetch the trusted base or supply --config. The new UnicodeDecodeError branch leaves it out, so a malformed trusted blob is the only trusted-source error without recovery guidance. Use raise ConfigError(f"{source}: {exc}. {hint}") from None to match the TOML branch next to it.

@eowca
eowca marked this pull request as ready for review November 26, 2026 07:47
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 21e712a at 07:53 UTC

5 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 07:47 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1669
  • ✅ Merged 07:53 · 21e712a · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 21e712a into main Nov 26, 2026
18 checks passed
@eowca
eowca deleted the lean178/1605-strict-workflow branch November 26, 2026 07:53
@mergify mergify Bot removed the queued label Nov 26, 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.

Reject invalid UTF-8 in trusted workflow blobs

1 participant