Harden Prompty local image path handling - #48942
Open
Sydney Lister (slister1001) wants to merge 1 commit into
Open
Harden Prompty local image path handling#48942Sydney Lister (slister1001) wants to merge 1 commit into
Sydney Lister (slister1001) wants to merge 1 commit into
Conversation
Reject absolute, traversal, and symlink-escape image paths before reading local files, while preserving in-directory image support and graceful Markdown fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6fcc3b99-8914-4e38-9905-16829c362bd7
|
Azure Pipelines: Successfully started running 1 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Sydney Lister (slister1001)
September 10, 2026 18:55
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
File validation and reading remain separated by a symlink race that can bypass containment.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Hardens Prompty image resolution against directory traversal and symlink escapes.
Changes:
- Canonicalizes and validates local image paths.
- Preserves fallback behavior for invalid Markdown references.
- Adds traversal, symlink, and compatibility tests.
File summaries
| File | Description |
|---|---|
_utils.py |
Adds secure-path validation and fallback handling. |
test_inline_image_fallback.py |
Adds path-security regression coverage. |
CHANGELOG.md |
Documents the security hardening. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+386
to
+388
| if not path.is_file(): | ||
| raise InvalidInputError(f"Cannot find the image path '{path.as_posix()}'") | ||
| file_contents = path.read_bytes() |
Member
Author
|
/azp run |
|
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
Member
Author
|
/azp run python - pullrequest |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Harden
azure-ai-evaluationlocal Prompty image handling so rendered input cannot read files outside the Prompty directory.data:...;path:references as explicit invalid input.Validation
python -m pytest --confcutdir=tests\unittests tests\unittests\test_inline_image_fallback.py -q --tb=short— 25 passed, 1 skipped.git diff --checkpassed.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines