Skip to content

fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization - #14665

Merged
steipete merged 2 commits into
openclaw:mainfrom
sumleo:fix/unicode-homoglyph-sanitization
Feb 13, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
sumleo:fix/unicode-homoglyph-sanitization

Conversation

@sumleo

@sumleo sumleo commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The `foldMarkerChar()` function in `external-content.ts` sanitizes external content markers to prevent prompt injection boundary escapes.
  • Currently it only handles fullwidth ASCII characters (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).
  • Many visually similar Unicode characters bypass sanitization and could be used to craft fake boundary markers that an LLM might interpret as trusted content boundaries.

Fix

Add folding for additional Unicode angle bracket homoglyphs:

  • Mathematical angle brackets (U+27E8, U+27E9)
  • CJK angle brackets (U+3008, U+3009)
  • Left/right-pointing angle brackets (U+2329, U+232A)
  • Single angle quotation marks (U+2039, U+203A)
  • Small less-than/greater-than signs (U+FE64, U+FE65)

Also remove now-unused standalone constants in favor of the lookup map.

Test plan

  • Verify existing marker sanitization still works with fullwidth characters
  • Verify new homoglyph characters are correctly folded to ASCII equivalents
  • Verify normal content without homoglyphs is not affected

Greptile Overview

Greptile Summary

This change expands foldMarkerChar() / foldMarkerText() in src/security/external-content.ts to normalize additional Unicode “angle bracket” homoglyphs (e.g., U+2329/U+232A, U+2039/U+203A, U+27E8/U+27E9, U+3008/U+3009, U+FE64/U+FE65) into ASCII < / >.

That normalization feeds into replaceMarkers(), which looks for external-content boundary markers like <<<EXTERNAL_UNTRUSTED_CONTENT>>> after folding. By covering more lookalike bracket characters, the wrapper is harder to bypass with visually similar Unicode when trying to spoof/escape the trusted boundary markers.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is narrowly scoped to marker folding/sanitization and preserves the previous behavior while extending normalization to additional bracket homoglyphs; no call sites or boundary marker formats are altered.
  • No files require special attention

…content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)
@sumleo

sumleo commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

@cpojer Could you help review this PR? Thanks!

@steipete steipete self-assigned this Feb 13, 2026
@steipete
steipete merged commit 6c4c535 into openclaw:main Feb 13, 2026
4 of 9 checks passed
skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
…content sanitization (openclaw#14665)

* fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)

* test(security): add homoglyph marker coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
…content sanitization (openclaw#14665)

* fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)

* test(security): add homoglyph marker coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…content sanitization (openclaw#14665)

* fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)

* test(security): add homoglyph marker coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…content sanitization (openclaw#14665)

* fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)

* test(security): add homoglyph marker coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…content sanitization (openclaw#14665)

* fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)

* test(security): add homoglyph marker coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…content sanitization (openclaw#14665)

* fix(security): handle additional Unicode angle bracket homoglyphs in content sanitization

The foldMarkerChar function sanitizes external content markers to
prevent prompt injection boundary escapes, but only handles fullwidth
ASCII (U+FF21-FF5A) and fullwidth angle brackets (U+FF1C/FF1E).

Add handling for additional visually similar Unicode characters that
could be used to craft fake end markers:
- Mathematical angle brackets (U+27E8, U+27E9)
- CJK angle brackets (U+3008, U+3009)
- Left/right-pointing angle brackets (U+2329, U+232A)
- Single angle quotation marks (U+2039, U+203A)
- Small less-than/greater-than signs (U+FE64, U+FE65)

* test(security): add homoglyph marker coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants