Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

BUG: HTTPTarget turns CRLF into LF in the request body

Cerrado
#3,353 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@nniiovoo ya está trabajando en esto.

Desde el 19/10/2026.

  • #3354 de @nniiovoo — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
api, backend

Línea de trabajo

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'.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
4.6k
Forks
962
Merge medio
2 d 15 h
PR fusionados (30 d)
398

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/PyRIT

Todos los issues de microsoft/PyRIT

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.