Skip to content

Add CJK obfuscation transform family (cjk_lookalike/traditional/variant/punct/zwsp)#19

Open
demaxiya567 wants to merge 1 commit into
JailbrokenAI:mainfrom
demaxiya567:feat/cjk-obf
Open

Add CJK obfuscation transform family (cjk_lookalike/traditional/variant/punct/zwsp)#19
demaxiya567 wants to merge 1 commit into
JailbrokenAI:mainfrom
demaxiya567:feat/cjk-obf

Conversation

@demaxiya567

Copy link
Copy Markdown
Contributor

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.

Transform Channel Example
cjk_lookalike Kangxi-radical near-duplicates + classic pairs 人→U+2F08, 日→U+2F47, 已→己
cjk_traditional simplified→traditional script 绕过→繞过, 伪造→偽造
cjk_variant Japanese shinjitai / orthographic variants 对→対, 单→単
cjk_punct fullwidth punctuation mutation ,→U+201A, 。→ halfwidth
cjk_zwsp ZWSP between adjacent CJK ideographs only breaks Chinese word segmentation, ASCII untouched

Rationale: 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_zwsp complements the existing zero_width transform 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 transforms
  • wallbreaker/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 recommended cjk_traditional → cjk_zwsp chain
  • tests/test_cjk_obf.py — round-trips, table integrity (one-to-one / unique targets), ZWSP placement invariants, ASCII passthrough, chain round-trips

Testing

  • tests/test_cjk_obf.py + tests/test_transforms.py: 94 passed
  • Full suite vs origin/main baseline: zero new failures (remaining failures are pre-existing environment issues — missing locally-fetched corpora and pytest-asyncio)

…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.
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.

1 participant