Skip to content

Python: fix for Incomplete URL substring sanitization#2274

Merged
moonbox3 merged 4 commits intomainfrom
alert-autofix-29
Nov 18, 2025
Merged

Python: fix for Incomplete URL substring sanitization#2274
moonbox3 merged 4 commits intomainfrom
alert-autofix-29

Conversation

@eavanvalkenburg
Copy link
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.

@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
Copy link
Member

markwallace-microsoft commented Nov 17, 2025

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
Member Author

@copilot please have a look at the failures and fix them

Copy link
Contributor

Copilot AI commented Nov 18, 2025

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

eavanvalkenburg and others added 2 commits November 18, 2025 11:38
…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>
@eavanvalkenburg eavanvalkenburg marked this pull request as ready for review November 18, 2025 11:01
Copilot AI review requested due to automatic review settings November 18, 2025 11:01
Copy link
Contributor

Copilot AI left a comment

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 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 moonbox3 changed the title Python: Potential fix for Incomplete URL substring sanitization Python: fix for Incomplete URL substring sanitization Nov 18, 2025
@moonbox3 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
@eavanvalkenburg eavanvalkenburg deleted the alert-autofix-29 branch November 19, 2025 07:36
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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants