FIX: give each QRCodeConverter conversion its own image file - #2668
Open
MinYi Xie (ppcvote) wants to merge 1 commit into
Open
MinYi Xie (ppcvote) wants to merge 1 commit into
MinYi Xie (ppcvote) wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
QRCodeConverterbuilds itsDataTypeSerializerin__init__(qr_code_converter.py:62).DataTypeSerializer.get_data_filename_asynccaches the file path after the first call (serializers.py:338-339), so everyconvert_asyncon that instance reuses the same path and segno overwrites the same PNG.Sharing one converter instance is the normal path:
AttackConverterConfigholds 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 withPromptSendingAttackover 3 objectives: atmax_concurrency=1all three stored conversations end up pointing at the last objective's QR code; atmax_concurrency=3the target itself receives the last objective's QR code for two of the three prompts. Nothing raises;incomplete_objectivesis 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_serializerattribute is removed.Tests and Documentation
segno.make_qr(prompt). Fails without the fix, passes with it.QRCodeConverterpass (199 passed, 2 skipped).ruff format --check,ruff checkandty check pyritpass.