Skip to content

Fix surrogate skips, Action injection, and hashing crashes - #118

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/repo-audit-fixes-cdf8
Sep 2, 2026
Merged

Fix surrogate skips, Action injection, and hashing crashes#118
cursor[bot] merged 2 commits into
mainfrom
cursor/repo-audit-fixes-cdf8

Conversation

@byte271

@byte271 byte271 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Repository audit of the defensive surfaces (lint, scan/clean, guard, normalize, clipboard, GitHub Action, local web API). Full pytest is green.

Bugs

  • fuckmark lint never fired surrogate. Strict UTF-8 cannot contain U+D800–U+DFFF, and CESU-8 / modified-UTF-8 encodings of those codepoints were skipped as “invalid UTF-8”, so the default security set advertised a category that could not fail a CI gate. Lint now decodes those bytes with utf-8 + surrogatepass and reports them. --fix writes with the same encoding so a --select bidi_control rewrite can keep leftover surrogates instead of crashing. --scan / --clean / guard / normalize use the same decoder; the mix path still rejects those files.
  • GitHub Action script injection. action.yml interpolated inputs.select, inputs.args, and inputs.paths into bash. Those values now enter the step through env: and are parsed with shlex.split. The existing workflow hygiene test is extended to action.yml.
  • Windows clipboard UTF-16LE ASCII became NULs. A\\x00B\\x00 is valid UTF-8 (A\\0B\\0), so UTF-8-first decoding inserted U+0000 controls between letters. BOM-less UTF-16LE is used only for PowerShell Get-Clipboard. pbpaste / wl-paste / xclip / xsel stay UTF-8, so a real NUL on Linux or macOS remains in the control category.
  • protect() / normalize_text() crashed on lone surrogates while hashing the receipt. sha256_text now uses surrogatepass (identical for every valid scalar value; frozen confirmation hashes are unchanged).
  • JSON with lone surrogates was not valid UTF-8. Encoding receipts with surrogatepass emitted WTF-8 (ED A0 80). Clients that decode application/json; charset=utf-8 strictly would fail. Responses and receipts now escape lone surrogates as \\uXXXX.
  • fuckmark web POST without Content-Length scanned {}. Missing header is now a 400 instead of a silent empty-body success.
  • build_real_measurement_calibration_corpus return annotation. MeasurementCalibrationCorpus is imported so typing.get_type_hints resolves.

Package version stays 0.4.1. Frozen confirmation files and hashes are untouched. Independent of #117.

Open in Web Open in Cursor 

@byte271
byte271 marked this pull request as ready for review September 2, 2026 04:27
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

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

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: f880cfb9-7a70-412a-80dd-0ac6588178ad


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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd152c8549

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fuckmark/clipboard_watch.py Outdated
return raw.decode("utf-16")
except UnicodeDecodeError as error:
raise ClipboardUnavailableError("clipboard bytes were not valid UTF-8 or UTF-16") from error
if b"\x00" in raw and len(raw) % 2 == 0:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve UTF-8 NUL controls during clipboard decoding

On Linux and macOS, the clipboard commands return UTF-8, but this branch globally interprets every even-length payload containing a NUL as UTF-16LE. For example, valid UTF-8 bytes b"A\x00" become just "A", so clipboard scan, watch, and clean miss the NUL even though it belongs to the default control category. Restrict the BOM-less UTF-16LE heuristic to the Windows PowerShell reader, or otherwise pass the reader's expected encoding into this function.

Useful? React with 👍 / 👎.

Comment thread fuckmark/web.py Outdated

def _json_response(self, status: int, payload: dict[str, object]) -> None:
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
body = json.dumps(payload, ensure_ascii=False).encode("utf-8", "surrogatepass")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Escape lone surrogates in UTF-8 JSON responses

When an endpoint returns an input lone surrogate—such as /api/guard with on_findings: "report" or a /api/remove-marks miss—surrogatepass emits its WTF-8 byte sequence even though the response declares UTF-8. Standard clients then fail UTF-8 decoding before they can parse the JSON, so this replaces the previous server-side exception with an unusable response. Serialize surrogates as JSON escapes, for example by retaining ensure_ascii=True, rather than writing invalid UTF-8 bytes.

Useful? React with 👍 / 👎.

cursoragent and others added 2 commits September 2, 2026 04:49
Lint and the scan/clean/guard/normalize paths now decode CESU-8 lone
surrogates instead of skipping or raising. The GitHub Action passes
inputs through env vars, clipboard UTF-16LE ASCII is not read as NULs,
and sha256_text no longer crashes on U+D800-U+DFFF.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
JSON receipts and the local web API now emit \uXXXX escapes instead of
WTF-8 so clients can decode the declared UTF-8. The UTF-16LE-without-BOM
clipboard heuristic is limited to PowerShell so Linux/macOS NULs stay in
the control category.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/repo-audit-fixes-cdf8 branch from 25dc86f to 672de39 Compare September 2, 2026 04:50
@cursor
cursor Bot merged commit 450d3c8 into main Sep 2, 2026
14 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.

2 participants