BUG: CodeChameleonConverter custom functions do not reach its identifier
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
Read codechameleon_converter.py, especially _build_identifier and the custom encryption/decryption handling at the referenced lines. Review the two strict xfail tests proposed in #3477 and settle whether identity should come from a caller-provided stable identifier or a fingerprint of the effective functions and rendered decrypt source. Done means converters using different custom functions have distinct identifiers, with tests covering the chosen behavior.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
With encrypt_type="custom", CodeChameleonConverter._build_identifier records only encrypt_type (codechameleon_converter.py:113). The encryption function decides the encoded prompt, and the decryption function's source is rendered into the prompt the model sees (source read at :150, rendered at :140-142), so converters built with different functions share one hash. As discussed in #3477, a qualified name is not enough either: two functions can share it with different code, closures or configuration.
Steps/Code to Reproduce
Run on main at 791e12c6e. Save as a file, since inspect.getsource needs one.
import asyncio
from pyrit.converter import CodeChameleonConverter
from pyrit.setup import IN_MEMORY, initialize_pyrit_async
def reverse_text(text):
return text[::-1]
def upper_text(text):
return text.upper()
async def main() -> None:
await initialize_pyrit_async(memory_db_type=IN_MEMORY, silent=True)
for function in (reverse_text, upper_text):
converter = CodeChameleonConverter(encrypt_type="custom", encrypt_function=function, decrypt_function=function)
result = await converter.convert_async(prompt="hello world")
line = next(line for line in result.output_text.splitlines() if "need to solve" in line)
print(line.strip(), converter.get_identifier().unique_name)
asyncio.run(main())
Expected Results
Different functions, different identifiers.
Actual Results
The encrypted_problem you need to solve is: dlrow olleh CodeChameleonConverter::505647f9
The encrypted_problem you need to solve is: HELLO WORLD CodeChameleonConverter::505647f9
Versions
- OS: Windows 11
- Python version: 3.12.0
- PyRIT version: source checkout of
mainat791e12c6e
System:
python: 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
executable: C:\dev\pyr-main\Scripts\python.exe
machine: Windows-11-10.0.26300-SP0
Python dependencies:
pyrit: 1.2.0.dev0
Cython: None
numpy: 2.4.6
openai: 2.54.0
packaging: 26.3
pip: 23.2.1
scipy: 1.17.1
setuptools: 84.2.1
sqlite3: None
torch: None
transformers: 5.20.2
Possible directions from #3477: a stable identifier passed by the caller, or a fingerprint of the effective function and rendered decrypt source. The test proposed in #3477 marks both settings as strict xfail linked to this issue. I can take this one once the direction is settled.
- 主要语言
- Python
- 星标
- 4.7k
- 派生
- 1k
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 439
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
Description-only preset edits split comma-containing exact goals into separate goals可能已有人在做 @MRX-72 于 1 天前认领。 未关闭help wanted
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
GUI rejects valid empty-string SearchReplaceConverter settings, preventing deletion converters可能已有人在做 @Darshika140 于 1 天前认领。 未关闭help wanted
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/PyRIT#3749 · 1 条评论 ·
维护者通常 2 天内回复
-
HTML scenario export replaces an intentionally empty converted message with the original text可能已有人在做 @VISHNU0906 于 1 天前认领。 未关闭help wanted
难度 2/5 1-3 小时 新手友好度 77/100
microsoft/PyRIT#3741 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
help wanted
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
Development toolchain includes an audited vulnerable Zod version可能已有人在做 @ppcvote 今天认领。 未关闭help wanted
难度 2/5 1-3 小时 新手友好度 70/100
microsoft/PyRIT#3725 · 1 条评论 ·
维护者通常 2 天内回复
相似的 Issue
-
area:scripts area:tests bug priority:later
难度 2/5 1-3 小时 新手友好度 72/100
Ikalus1988/MisakaNet#4358 ·
维护者通常 1 天内回复
-
Discovered ports from service discovery are never propagated to modules in Module.load()可能已有人在做 @vishalmore90 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
OWASP/Nettacker#1828 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
aws-samples/sample-per-model-bedrock#708 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 75/100
sjkim1127/Reversecore_MCP#365 ·
维护者通常 1 天内回复