Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

BUG: HTTPTarget turns CRLF into LF in the request body

Fermée
#3,353 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@nniiovoo y travaille déjà.

Depuis le 19/10/2026.

  • #3354 par @nniiovoo — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
python
Domaine
api, backend

Piste de recherche

The issue identifies HTTPTarget.parse_raw_http_request and describes a reproducible multipart request that fails in Starlette. Read that method and reproduce the example to confirm the body loses its CRLF line endings. Done means the request preserves the multipart separators and the example returns server got prompt='hello'.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Describe the bug

HTTPTarget.parse_raw_http_request replaces every \r\n in the raw request with \n before it splits the headers from the body, so the body loses its CRLFs too. This changes multipart boundary separators. The local example below fails with Starlette's multipart parser, which returns Invalid multipart data. A prompt that contains \r\n is changed the same way.

The comment just above that line says body whitespace should be kept exactly as given.

Steps/Code to Reproduce
import asyncio

import httpx
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse
from starlette.routing import Route

from pyrit.models import Message
from pyrit.prompt_target import HTTPTarget
from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def upload(request):
    form = await request.form()
    return PlainTextResponse(f"server got prompt={form['prompt']!r}")


app = Starlette(routes=[Route("/upload", upload, methods=["POST"])])

# multipart request as copied from Burp (CRLF line endings)
raw_request = (
    "POST /upload HTTP/1.1\r\n"
    "Host: example.com\r\n"
    "Content-Type: multipart/form-data; boundary=XyZ\r\n"
    "\r\n"
    "--XyZ\r\n"
    'Content-Disposition: form-data; name="prompt"\r\n'
    "\r\n"
    "{PROMPT}\r\n"
    "--XyZ--\r\n"
)


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    client = httpx.AsyncClient(transport=httpx.ASGITransport(app=app))
    target = HTTPTarget(http_request=raw_request, prompt_regex_string="{PROMPT}", client=client)
    response = await target.send_prompt_async(message=Message.from_prompt(prompt="hello", role="user"))
    print(response[0].get_value())


asyncio.run(main())
Expected Results
server got prompt='hello'
Actual Results
Invalid multipart data.

The body that gets sent is --XyZ\nContent-Disposition: form-data; name="prompt"\n\nhello\n--XyZ--\n, with no CR left.

Versions
  • OS: macOS 26.4.1 (arm64)
  • Python 3.13.16
  • PyRIT 1.2.0.dev0, main (672a8fc5), editable install

I have a fix that splits off the body before normalizing the header line endings. Happy to open a PR if that sounds right.

Langage dominant
Python
Étoiles
4.6k
Forks
962
Merge moyen
2 j 13 h
PR mergées (30 j)
423

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/PyRIT

Toutes les issues de microsoft/PyRIT

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.