Skip to content

FIX harden HTTP target request and upload handling - #2405

Open
Roman Lutz (romanlutz) wants to merge 6 commits into
microsoft:mainfrom
romanlutz:romanlutz-harden-http-target-safeguards
Open

FIX harden HTTP target request and upload handling#2405
Roman Lutz (romanlutz) wants to merge 6 commits into
microsoft:mainfrom
romanlutz:romanlutz-harden-http-target-safeguards

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Finding by Roman Lutz (@romanlutz) and Microsoft Security FORGE Lab.

HTTP target prompt substitution could alter the configured destination, inject new request headers, follow redirects without explicit operator control, or cause HTTPXAPITarget to upload locally accessible files without containment. This change adds safeguards while preserving existing behavior for current callers.

  • Pin raw HTTP requests to the operator-configured scheme, host, and port after prompt substitution.
  • Add explicit follow_redirects control to HTTPTarget and HTTPXAPITarget, defaulting to the existing enabled behavior for compatibility.
  • Reject CR/LF prompt values when substituted into the request line or headers, while preserving multiline body prompts.
  • Add canonical upload containment through allowed_upload_directory.
  • Preserve uploads without an allowed directory and legacy implicit text-path uploads through 1.3.0 with deprecation warnings; path-typed message pieces use the hardened path flow immediately.
  • Validate canonical containment and file existence before validating whether the HTTP method supports uploads.

Tests and Documentation

Added focused unit coverage for destination changes, arbitrary operator-configured internal destinations, enabled and disabled redirects, CR/LF injection contexts, multiline request bodies, upload-directory containment, validation ordering, and deprecated compatibility paths. The combined HTTP-target suite passes with 48 tests.

Documentation was not changed because the affected constructor parameters and behavior are documented in their API docstrings. JupyText was not run because no documentation notebooks were modified.

Copilot AI added 4 commits August 17, 2026 12:02
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@hannahwestra25 hannahwestra25 self-assigned this Aug 18, 2026
Comment thread pyrit/prompt_target/http_target/httpx_api_target.py Outdated
Comment thread pyrit/prompt_target/http_target/httpx_api_target.py Outdated
Comment thread pyrit/prompt_target/http_target/httpx_api_target.py Outdated
Copilot AI added 2 commits August 18, 2026 16:18
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a5e26abb-1f6f-4138-8a23-4cfb10e1625f
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a5e26abb-1f6f-4138-8a23-4cfb10e1625f
@romanlutz Roman Lutz (romanlutz) changed the title [BREAKING] FIX harden HTTP target request and upload handling FIX harden HTTP target request and upload handling Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants