Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

BUG: HTTPTarget turns CRLF into LF in the request body

Đã đóng
#3,353 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@nniiovoo đang làm issue này rồi.

Từ ngày 19/10/2026.

  • #3354 của @nniiovoo — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, backend

Hướng nghiên cứu

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

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
4.6k
Fork
962
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
398

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/PyRIT

Tất cả issue của microsoft/PyRIT

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.