BUG: HTTPTarget turns CRLF into LF in the request body
Maintainer thường phản hồi trong vòng 2 ngày
Đá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
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
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/PyRIT
-
BUG: MarkdownInjectionScorer misses shortcut-reference images with path-based exfiltration, and raw HTML <img>Có thể đã có người làm @aatif101 đã nhận 1 ngày trước. Đang mởBug: triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/PyRIT#3343 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: UrlConverter preserves forward slashes by default, preventing path payload evasionCó thể đã có người làm @Kaap10 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: XSSOutputScorer misses SVG and JavaScript data URIsCó thể đã có người làm @Kaap10 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: FuzzerGenerator accepts a jailbreak goal below 1 and a success threshold outside [0, 1]Có thể đã có người làm @ShivamSharma43 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: ManyShotJailbreakAttack accepts a negative example_count and drops examples from the endCó thể đã có người làm @ShivamSharma43 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/PyRIT
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
521xueweihan/HelloGitHub#4063 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws-samples/sample-per-model-bedrock#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DuckDB 2.0 breaks to_pyarrow_batchesCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ibis-project/ibis#12196 ·
Maintainer thường phản hồi trong vòng 1 ngày