Skip to content

FIX: give each QRCodeConverter conversion its own image file - #2668

Open
MinYi Xie (ppcvote) wants to merge 1 commit into
microsoft:mainfrom
ppcvote:fix/qr-converter-unique-file
Open

MinYi Xie (ppcvote) wants to merge 1 commit into
microsoft:mainfrom
ppcvote:fix/qr-converter-unique-file

Conversation

@ppcvote

Copy link
Copy Markdown
Contributor

Description

QRCodeConverter builds its DataTypeSerializer in __init__ (qr_code_converter.py:62). DataTypeSerializer.get_data_filename_async caches the file path after the first call (serializers.py:338-339), so every convert_async on that instance reuses the same path and segno overwrites the same PNG.

Sharing one converter instance is the normal path: AttackConverterConfig holds a single converter list, and PyRIT's own scenario tests build attacks this way (test_multilingual.py:65, test_attack_technique_factory.py:203). Reproduced with PromptSendingAttack over 3 objectives: at max_concurrency=1 all three stored conversations end up pointing at the last objective's QR code; at max_concurrency=3 the target itself receives the last objective's QR code for two of the three prompts. Nothing raises; incomplete_objectives is empty.

Fix: build the serializer inside convert_async, matching every other file-producing converter (add_text_image_converter.py:143, transparency_attack_converter.py:275). Same timestamp-based filename scheme as those converters, not a stronger uniqueness guarantee. No public API change; only the private _img_serializer attribute is removed.

Tests and Documentation

  • New test: two calls on one converter must return different paths and each file must match segno.make_qr(prompt). Fails without the fix, passes with it.
  • Module tests (6) and all converter/setup/scenario tests that construct a QRCodeConverter pass (199 passed, 2 skipped).
  • ruff format --check, ruff check and ty check pyrit pass.
  • JupyText not run: no notebook changed; the single-call usage the docs demonstrate is unaffected.
  • No open PR or issue covers this: checked all 41 open PRs' changed files and searched issues for QRCodeConverter, qr_code_converter, _img_serializer and get_data_filename_async.

QRCodeConverter created its DataTypeSerializer in __init__. A serializer
caches its file path after the first get_data_filename_async call, so every
convert_async on the same instance returned the same path and segno
overwrote that one PNG. Create the serializer inside convert_async, as the
other file-producing converters already do.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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