Warn when SKILL.md contains invisible characters - #6098
Open
fevziegeyurtsevenler wants to merge 1 commit into
Open
Warn when SKILL.md contains invisible characters#6098fevziegeyurtsevenler wants to merge 1 commit into
fevziegeyurtsevenler wants to merge 1 commit into
Conversation
collectWarnings already receives the raw SKILL.md bytes but only looks at formatting: comma-delimited allowed-tools and line count. Characters that render as nothing still reach the model as instruction text, so a skill can carry directions a reviewer reading the rendered file cannot see. Flag Unicode tag characters (U+E0000-E007F, a full invisible ASCII alphabet and the usual carrier), zero-width characters, invisible math operators, bidirectional overrides of Trojan Source fame, and variation selectors, naming the kind found and the first line it appears on. This is a warning rather than an error on purpose: ZWJ appears in ordinary emoji sequences and RTL marks appear in ordinary Arabic and Hebrew prose, so the call belongs to a human. Ordinary non-ASCII prose stays clean, which the tests cover alongside each flagged class. Signed-off-by: Fevzi Ege Yurtsevenler <egeyurtsevenler@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an invisible-character warning to skill validation.
Problem
collectWarningsinpkg/skills/validator.goalready receives the rawSKILL.mdbytes, but only inspects formatting — comma-delimitedallowed-toolsand line count. Nothing looks at the characters themselves.Characters that render as nothing still reach the model as instruction text. A skill can therefore carry directions that a reviewer reading the rendered file cannot see. The clearest case is the Unicode tag block (U+E0000–E007F), a complete ASCII alphabet that essentially every renderer draws as zero pixels:
Bidirectional overrides are the other well-known case — the rendered order of a line can differ from the byte order that gets read, which is Trojan Source / CVE-2021-42574.
Change
checkInvisibleRunesscans the content once and reports the classes found plus the first line they appear on:Why a warning and not an error
These codepoints have legitimate uses — ZWJ builds ordinary emoji sequences, and RTL marks appear throughout ordinary Arabic and Hebrew prose. Failing validation on them would break real skills, so this surfaces the finding and leaves the judgement to a human, consistent with how the existing warnings behave.
Ordinary non-ASCII prose stays clean; there is a test asserting that Turkish, Greek, Japanese and emoji content produces no warning, alongside one test per flagged class and one for the reported line number.
Verification
go test ./pkg/skills/... -count=1,go vet ./pkg/skills/andgofmt -l pkg/skills/are all clean locally. Commit is DCO signed-off.Context: I maintain uncloak, a scanner for this class of issue, and ran it across 3,168 public agent extensions — which is where the specific codepoint classes above come from.