Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

BUG: HTTPTarget turns CRLF into LF in the request body

オープン
#3,353 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@nniiovoo がすでに取り組んでいます。

2026年10月19日 から。

  • #3354 @nniiovoo による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
api, backend

調査の方向性

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

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
4.6k
フォーク
962
平均マージ
2日 15時間
マージ済み PR(30日)
390

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/PyRIT のほかの issue

microsoft/PyRIT の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。