Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

BUG: LetterBijectionConverter accepts a negative fixed_size and then leaves the prompt unchanged

Geschlossen
#3,434 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@ShivamSharma43 arbeitet bereits daran.

Seit 22.10.2026.

  • #3436 von @ShivamSharma43 — gemerged

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
ai, security

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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=-1 keeps the first 25 letters fixed and "shuffles" only z with 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=-3 keeps 23 letters fixed and shuffles only x, y, z, so most prompts also go out in plaintext.
  • fixed_size=27 is accepted (identity mapping, identifier says 27), True is accepted as 1 (identifier says True), and 2.5 fails with slice 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
Vorherrschende Sprache
Python
Sterne
4.6k
Forks
962
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
417

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/PyRIT

Alle Issues in microsoft/PyRIT

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.