BUG: HTTPTarget turns CRLF into LF in the request body
Les mainteneurs répondent en général sous 2 jours
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 25/100
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
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
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/PyRIT
-
BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slashPeut-être pris @ShivamSharma43 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 2 jours
-
BUG: OpenAIImageTarget uploads edited images under a generated local path instead of their file namePeut-être pris @ShivamSharma43 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Les mainteneurs répondent en général sous 2 jours
-
BUG: PathTraversalOutputScorer misses canonical Windows target windows/win.ini and IIS web.configPeut-être pris @Kaap10 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 2 jours
-
BUG: XXEOutputScorer misses direct external DTD references and Java netdoc: / gopher: URI schemesPeut-être pris @Kaap10 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
BUG: StaticPromptInjectionScorer misses modern LLM chat template tokens (Meta Llama 3+, Google Gemma, Microsoft Phi-3/4)Peut-être pris @Kaap10 l’a pris aujourd’hui. Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de microsoft/PyRIT
Issues similaires
-
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
WLAN-Pi/wlanpi-profiler#341 ·
Les mainteneurs répondent en général sous 1 jour
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised throughPeut-être pris @Fire162 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
graphql-python/graphql-core#287 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
roman-corgi/ctc-dip#160 ·
Les mainteneurs répondent en général sous 1 jour
-
type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows hostPeut-être pris @Aaqibhafeezkhan l’a pris aujourd’hui. Ouvertebug good first issue mentored python size: XS up-for-grabs
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
dheerajjha/mcp-migrate#366 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour