Skip to content

Python: fix for Incomplete URL substring sanitization - #2274

Merged
Evan Mattson (moonbox3) merged 4 commits into
mainfrom
alert-autofix-29
Nov 18, 2025
Merged

Python: fix for Incomplete URL substring sanitization#2274
Evan Mattson (moonbox3) merged 4 commits into
mainfrom
alert-autofix-29

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Potential fix for https://github.com/microsoft/agent-framework/security/code-scanning/29

To address this issue, the safest approach is to parse any URL present in the text line and check that its host is exactly or a subdomain of azurecontainerapps.io before sending the progress message.

Specifically, edit the block spanning line 470:

  • Instead of low-confidence substring matching, use a regular expression to extract URLs from the line.
  • For each URL found, use urllib.parse.urlparse to parse it.
  • If the parsed hostname matches azurecontainerapps.io or a subdomain (*.azurecontainerapps.io), then trigger the message.
  • To do this, you will need to import urlparse from urllib.parse and likely re for regex.

No change of existing behavior except making detection robust.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

@markwallace-microsoft Mark Wallace (markwallace-microsoft) added the python Usage: [Issues, PRs], Target: Python label Nov 17, 2025
@github-actions github-actions Bot changed the title Potential fix for code scanning alert no. 29: Incomplete URL substring sanitization Python: Potential fix for code scanning alert no. 29: Incomplete URL substring sanitization Nov 17, 2025
@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL14988220785% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
2039 127 💤 0 ❌ 0 🔥 40.834s ⏱️

@eavanvalkenburg

Copy link
Copy Markdown
Member Author

Copilot please have a look at the failures and fix them

Copilot AI commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Eduard van Valkenburg (@eavanvalkenburg) I've opened a new pull request, #2296, to work on those changes. Once the pull request is ready, I'll request review from you.

…g sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…progress detection (#2296)

* Initial plan

* Fix URL parsing to handle trailing punctuation correctly

Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a security code scanning alert (#29) related to incomplete URL substring sanitization in the Azure deployment module. The fix enhances security by properly parsing and validating URLs before triggering deployment notifications.

Key Changes:

  • Replaced naive substring matching ("https://" in line_text and ".azurecontainerapps.io" in line_text) with robust URL parsing and hostname validation
  • Uses regex to extract URLs and urlparse to validate that hostnames are exactly or subdomains of azurecontainerapps.io

Reviewed Changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
python/packages/devui/agent_framework_devui/_deployment.py Implements secure URL validation using regex extraction, URL parsing, and hostname verification to prevent URL spoofing attacks
python/uv.lock Version bump for agent-framework-ag-ui package from 1.0.0b251114 to 1.0.0b251117

@moonbox3 Evan Mattson (moonbox3) changed the title Python: Potential fix for code scanning alert no. 29: Incomplete URL substring sanitization Python: Potential fix for Incomplete URL substring sanitization Nov 18, 2025
@moonbox3 Evan Mattson (moonbox3) changed the title Python: Potential fix for Incomplete URL substring sanitization Python: fix for Incomplete URL substring sanitization Nov 18, 2025
@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Nov 18, 2025
Merged via the queue into main with commit 293abf5 Nov 18, 2025
23 checks passed
Aris Nguyen (arisng) pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
* Potential fix for code scanning alert no. 29: Incomplete URL substring sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Python: Fix URL parsing to handle trailing punctuation in deployment progress detection (microsoft#2296)

* Initial plan

* Fix URL parsing to handle trailing punctuation correctly

Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>

* updated lock

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Co-authored-by: Victor Dibia <chuvidi2003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants