Add CJK obfuscation transform family (cjk_lookalike/traditional/variant/punct/zwsp)#19
Open
demaxiya567 wants to merge 1 commit into
Open
Add CJK obfuscation transform family (cjk_lookalike/traditional/variant/punct/zwsp)#19demaxiya567 wants to merge 1 commit into
demaxiya567 wants to merge 1 commit into
Conversation
…nt/punct/zwsp) Safety classifiers for CJK-capable models lean on keyword regexes and word segmentation tuned for simplified-Chinese text; the existing transform catalog only covers Latin-alphabet channels. This adds a dedicated cjk_* family that keeps rendered text readable while moving the token sequence outside the classifier distribution: - cjk_lookalike: Kangxi-radical near-duplicates (人->U+2F08, 日->U+2F47) plus the classic 已->己/未->末/天->夭 pairs. Glyph-identical, distinct code points, distinct tokens. - cjk_traditional: simplified->traditional script. Classifier corpora are overwhelmingly simplified Chinese, so traditional-script keywords sit outside the learned refusal distribution -- the CJK analogue of low-resource-language jailbreaks (Yong et al., 2023). - cjk_variant: Japanese shinjitai/orthographic variants (对->対, 单->単). - cjk_punct: fullwidth punctuation mutation (,->U+201A etc.) breaking punctuation-anchored regexes. - cjk_zwsp: zero-width space between adjacent CJK ideographs only, breaking Chinese word segmentation while leaving ASCII words/URLs/code intact. All five are lossless (one-to-one maps with unique targets; ZWSP strip). Registered in the transform catalog, tagged in the taxonomy (homoglyph / zero_width families, OWASP LLM01 / ATLAS AML.T0051+T0054), and documented in the agent encoding doctrine with the recommended cjk_traditional->cjk_zwsp chain. tests/test_cjk_obf.py covers round-trips, table integrity (one-to-one/unique targets), ZWSP placement invariants, ASCII passthrough, and chain round-trips.
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.
What
Adds a dedicated
cjk_*transform family covering the CJK attack surface, which the current catalog (Latin homoglyph / zero-width / VS / tag / emoji / RTL channels) does not touch. Safety classifiers for CJK-capable models lean on keyword regexes and word segmentation tuned for simplified-Chinese text; these transforms keep the rendered text human- and model-readable while moving the token sequence outside that distribution.cjk_lookalikecjk_traditionalcjk_variantcjk_punctcjk_zwspRationale: classifier training corpora are overwhelmingly simplified Chinese, so traditional-script and variant-script keywords sit outside the learned refusal distribution — the CJK analogue of low-resource-language jailbreaks (Yong et al., 2023).
cjk_zwspcomplements the existingzero_widthtransform by inserting breaks only between CJK ideographs, so mixed Chinese/English payloads keep URLs and code tokens contiguous.Changes
wallbreaker/transforms/cjk_obf.py— new module, five lossless encode/decode pairs (one-to-one maps with unique targets; ZWSP strip)wallbreaker/transforms/__init__.py— register the five transformswallbreaker/taxonomy.py— alias into the homoglyph / zero_width families (OWASP LLM01, ATLAS AML.T0051 / AML.T0054)wallbreaker/prompts.py— agent encoding doctrine: when to reach for the CJK family + the recommendedcjk_traditional → cjk_zwspchaintests/test_cjk_obf.py— round-trips, table integrity (one-to-one / unique targets), ZWSP placement invariants, ASCII passthrough, chain round-tripsTesting
tests/test_cjk_obf.py+tests/test_transforms.py: 94 passedorigin/mainbaseline: zero new failures (remaining failures are pre-existing environment issues — missing locally-fetched corpora andpytest-asyncio)