Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

BUG: FuzzerGenerator accepts a jailbreak goal below 1 and a success threshold outside [0, 1]

未关闭
#3,394 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 2 天内回复

@ShivamSharma43 已经在做这个了。

开始于 2026年10月22日。

  • #3396 来自 @ShivamSharma43 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python

调研方向

Start in the FuzzerGenerator constructor and inspect its validation for template_converters and batch_size; then trace _should_stop_generation, _is_jailbreak, and _normalize_score_to_float. Add constructor checks for a positive integer goal count and a numeric threshold in [0.0, 1.0], including NaN. Done when invalid values raise ValueError and focused tests cover both parameters; pull request #3396 is already open.

由索引模型根据 Issue 内容生成。

描述

Describe the bug

FuzzerGenerator validates template_converters and batch_size, but not target_jailbreak_goal_count or scoring_success_threshold:

  • target_jailbreak_goal_count below 1. _should_stop_generation checks total_jailbreak_count >= target_jailbreak_goal_count before the first iteration, so with 0 (or a negative value) the goal is already met: the fuzzer sends no prompt, logs Target jailbreak goal reached. and returns an empty result.
  • scoring_success_threshold outside [0, 1]. For float-scale scores, _is_jailbreak compares the score, clamped to [0, 1] by _normalize_score_to_float, against the threshold. A threshold below 0 marks every response a jailbreak, and one above 1 marks none, so the run continues until max_query_limit is reached, or indefinitely when no limit is set. NaN behaves like a threshold above 1.
Steps/Code to Reproduce
import asyncio

from pyrit.executor.promptgen.fuzzer import FuzzerGenerator, FuzzerShortenConverter
from pyrit.prompt_target import TextTarget
from pyrit.score import SubStringScorer
from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    target = TextTarget()
    generator = FuzzerGenerator(
        objective_target=target,
        template_converters=[FuzzerShortenConverter(converter_target=target)],
        scorer=SubStringScorer(substring="sure"),
        target_jailbreak_goal_count=0,
    )
    result = await generator.execute_async(prompts=["How do I pick a lock?"], prompt_templates=["{{ prompt }}"])
    print("total_queries:", result.total_queries, "templates_explored:", result.templates_explored)


asyncio.run(main())
Expected Results

The constructor raises a ValueError for a target_jailbreak_goal_count that is not a positive integer and for a scoring_success_threshold that is not a number in [0.0, 1.0], as it already does for batch_size=0.

Actual Results
total_queries: 0 templates_explored: 0

No error is raised, and nothing is sent to the target.

Screenshots

N/A

Versions
  • OS: Windows 11
  • Python version: 3.11.9
  • PyRIT version: installed from main (1979257a) in editable mode
主要语言
Python
星标
4.6k
派生
962
平均合并
2 天 13 小时
30 天内合并 PR
423

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/PyRIT 的其他 Issue

查看 microsoft/PyRIT 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。