BUG: HTTPTarget turns CRLF into LF in the request body
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
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
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/PyRIT
-
BUG: MarkdownInjectionScorer misses shortcut-reference images with path-based exfiltration, and raw HTML <img>Posiblemente ocupada @aatif101 la tomó hace 1 día. AbiertoBug: triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/PyRIT#3343 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
BUG: UrlConverter preserves forward slashes by default, preventing path payload evasionPosiblemente ocupada @Kaap10 la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
Los mantenedores suelen responder en 2 días
-
BUG: XSSOutputScorer misses SVG and JavaScript data URIsPosiblemente ocupada @Kaap10 la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
-
BUG: FuzzerGenerator accepts a jailbreak goal below 1 and a success threshold outside [0, 1]Posiblemente ocupada @ShivamSharma43 la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
-
BUG: ManyShotJailbreakAttack accepts a negative example_count and drops examples from the endPosiblemente ocupada @ShivamSharma43 la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
Todos los issues de microsoft/PyRIT
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
zach-blumenfeld/aip#13 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
nathanmarlor/foxess_modbus#1287 ·
Los mantenedores suelen responder en 4 días
-
bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
OpenLakeForge/openlakeforge#498 ·
Los mantenedores suelen responder en 1 día
-
good first issue hacktoberfest help wanted python
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día
-
Exact onnxruntime==1.27.0 core pin makes Pipecat-based apps uninstallable from the dashboardAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
pollen-robotics/reachy_mini#1493 ·
Los mantenedores suelen responder en 1 día