superred-optimizer-code-chameleon
A CodeChameleon jailbreak optimizer for the superred red-teaming framework.
Community port — not an official implementation. This module is an unofficial re-implementation of CodeChameleon (Lv et al.) for superred. It is not affiliated with, endorsed by, or maintained by the original authors. See ASSUMPTIONS.md for every deliberate deviation from the paper and reference code.
CodeChameleon hides the unsafe request by encrypting it, then hands the target a
matching decryption function and asks it to complete a ProblemSolver class.
Because the harmful text never appears in plain form, the target's refusal
training — trained on plain English — tends to miss it, and a capable model
decrypts and answers inside the code-completion frame.
Reference: Lv et al., "CodeChameleon: Personalized Encryption Framework for
Jailbreaking Large Language Models,"
arXiv:2402.16717 (Feb 2024). Official
implementation:
huizhang-L/CodeChameleon.
See ASSUMPTIONS.md for the full paper-to-code mapping and every
deliberate departure.
Install
pip install superred-optimizer-code-chameleon
Usage
from code_chameleon_optimizer import CodeChameleonOptimizer
# Default: one attempt with the `binary_tree` rule and the code-style template
# (the official README example, and the strongest average rule in the paper).
optimizer = CodeChameleonOptimizer()
# Stage several official encryption rules, one per run.
optimizer = CodeChameleonOptimizer(encrypt_rules=["reverse", "odd_even", "length"])
Wire it into a Controller like any other superred optimizer — see the
framework's architecture overview and a
target's README (e.g. superred-target-chatbot) for a full Controller.run() example.
License
MIT for this port's code (see LICENSE). The upstream reference
implementation,
huizhang-L/CodeChameleon, is MIT
licensed. The prompt templates, encryption rules, and judge prompt ported from it
are credited in NOTICE, and its MIT copyright notice is preserved in
LICENSES/CodeChameleon-MIT.txt.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superred_optimizer_code_chameleon-0.1.0.tar.gz.
File metadata
- Download URL: superred_optimizer_code_chameleon-0.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaa7e66b07c074f00d961928ecbdf67ddf9eb3bb473bf875988bca9062f1aec5
|
|
| MD5 |
880cb8aa2f55fe6996239cc0bd3d11b3
|
|
| BLAKE2b-256 |
2af1444f3872d386338db311853e6593f840c5f01f84bc2f3b4d0ce5e9d9a82a
|
Provenance
The following attestation bundles were made for superred_optimizer_code_chameleon-0.1.0.tar.gz:
Publisher:
release.yml on RoldSI/superred-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superred_optimizer_code_chameleon-0.1.0.tar.gz -
Subject digest:
aaa7e66b07c074f00d961928ecbdf67ddf9eb3bb473bf875988bca9062f1aec5 - Sigstore transparency entry: 2519552392
- Sigstore integration time:
-
Permalink:
RoldSI/superred-modules@1c1cbc87f3969cd4417cb4ecbd685252ad82c185 -
Branch / Tag:
refs/tags/superred-optimizer-code-chameleon-v0.1.0 - Owner: https://github.com/RoldSI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c1cbc87f3969cd4417cb4ecbd685252ad82c185 -
Trigger Event:
push
-
Statement type:
File details
Details for the file superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0400b5c65f927ed395253e993a52cd86087b1a0d047b8dea85c387b901b71299
|
|
| MD5 |
a4adb21c68596db4f2349efadb9cb1d5
|
|
| BLAKE2b-256 |
8a3b02431a4c25fdc9d4b6556630c3b102341611dc8225d94d7e438e5e3a1ed8
|
Provenance
The following attestation bundles were made for superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl:
Publisher:
release.yml on RoldSI/superred-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl -
Subject digest:
0400b5c65f927ed395253e993a52cd86087b1a0d047b8dea85c387b901b71299 - Sigstore transparency entry: 2519552709
- Sigstore integration time:
-
Permalink:
RoldSI/superred-modules@1c1cbc87f3969cd4417cb4ecbd685252ad82c185 -
Branch / Tag:
refs/tags/superred-optimizer-code-chameleon-v0.1.0 - Owner: https://github.com/RoldSI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c1cbc87f3969cd4417cb4ecbd685252ad82c185 -
Trigger Event:
push
-
Statement type: