BUG: LetterBijectionConverter accepts a negative fixed_size and then leaves the prompt unchanged
维护者通常 2 天内回复
评估
调研方向
Start at LetterBijectionConverter and inspect how fixed_size is used to split the lowercase alphabet and build the identifier. Check the existing tests for fixed_size=0 and fixed_size=26, then add coverage for invalid values and verify they raise a ValueError naming fixed_size. A pull request is already open for this issue.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
LetterBijectionConverter(fixed_size=...) uses fixed_size as a slice bound on the 26 lowercase letters (letters[:fixed_size] stay fixed, letters[fixed_size:] are shuffled) but never validates it. A negative value is read from the end of the alphabet instead of being rejected:
fixed_size=-1keeps the first 25 letters fixed and "shuffles" onlyzwith itself, so the mapping is the identity and the converter sends the prompt to the target unchanged (attack at dawn->attack at dawn).fixed_size=-3keeps 23 letters fixed and shuffles onlyx,y,z, so most prompts also go out in plaintext.fixed_size=27is accepted (identity mapping, identifier says27),Trueis accepted as1(identifier saysTrue), and2.5fails withslice indices must be integers or None or have an __index__ method.
The identifier records the invalid value, so a run looks like a bijection attack in memory while the target actually received plaintext.
Steps/Code to Reproduce
import asyncio
from pyrit.converter import LetterBijectionConverter
async def main():
for fixed_size in (-1, -3, 27, True, 2.5):
try:
converter = LetterBijectionConverter(fixed_size=fixed_size, seed=1)
unchanged = sum(1 for k, v in converter.mapping.items() if k == v)
output = (await converter.convert_async(prompt="attack at dawn")).output_text
print(repr(fixed_size), "unchanged letters:", unchanged, "->", output)
except Exception as e:
print(repr(fixed_size), "->", type(e).__name__, e)
asyncio.run(main())
Expected Results
fixed_size must be an integer from 0 to 26 (both already used: fixed_size=0 shuffles every letter and fixed_size=26 is tested as the identity mapping). Anything else raises a ValueError naming fixed_size.
Actual Results
-1 unchanged letters: 26 -> attack at dawn
-3 unchanged letters: 24 -> attack at dawn
27 unchanged letters: 26 -> attack at dawn
True unchanged letters: 3 -> axxagu ax badp
2.5 -> TypeError slice indices must be integers or None or have an __index__ method
Screenshots
N/A
Versions
- OS: Windows 11
- Python version: 3.11.9
- PyRIT version: installed from main (ac196e57) in editable mode
- 主要语言
- Python
- 星标
- 4.6k
- 派生
- 962
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 417
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slash可能已有人在做 @ShivamSharma43 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
BUG: OpenAIImageTarget uploads edited images under a generated local path instead of their file name可能已有人在做 @ShivamSharma43 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 2 天内回复
-
BUG: PathTraversalOutputScorer misses canonical Windows target windows/win.ini and IIS web.config可能已有人在做 @Kaap10 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
BUG: XXEOutputScorer misses direct external DTD references and Java netdoc: / gopher: URI schemes可能已有人在做 @Kaap10 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
BUG: StaticPromptInjectionScorer misses modern LLM chat template tokens (Meta Llama 3+, Google Gemma, Microsoft Phi-3/4)可能已有人在做 @Kaap10 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 84/100
维护者通常 2 天内回复
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
fossasia/visdom-dev#77 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
aws-cloudformation/cfn-lint#4890 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
volcengine/OpenViking#6521 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
AstrBotDevs/AstrBot#10720 ·
维护者通常 1 天内回复