Skip to content

Implement vulnerability remediation for Issue #86 and ICM ticket#2

Merged
jorgelevy merged 2 commits intojorgelevy:mainfrom
Azure-Samples:main
Mar 31, 2026
Merged

Implement vulnerability remediation for Issue #86 and ICM ticket#2
jorgelevy merged 2 commits intojorgelevy:mainfrom
Azure-Samples:main

Conversation

@jorgelevy
Copy link
Copy Markdown
Owner

No description provided.

Antonio Claudio Michejevs Padilha and others added 2 commits November 29, 2025 11:45
implementing vulnerability remediation for Issue #86 and ICM ticket. Both vulnerabilities have been addressed.
Copilot AI review requested due to automatic review settings March 31, 2026 00:46
@jorgelevy jorgelevy merged commit 415d2fc into jorgelevy:main Mar 31, 2026
2 checks passed
Copy link
Copy Markdown

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 aims to remediate a vulnerability (Issue Azure-Samples#86 / ICM) in the PromptFlow demo by removing unsafe input parsing and reducing SQL injection risk in the customer lookup tool.

Changes:

  • Replaced eval(inputs) with json.loads(inputs) for string inputs.
  • Switched from string-interpolated SQL to a parameterized pyodbc query.
  • Refactored name fields into local variables before executing the query.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 19 to +23
if inputs_dict['MiddleName'] == "":
sqlQuery = f"""select * from [SalesLT].[Customer] WHERE FirstName='{inputs_dict['FirstName']}' and MiddleName is NULL and LastName='{inputs_dict['LastName']}'"""
middle_name = "NULL"
else:
sqlQuery = f"""select * from [SalesLT].[Customer] WHERE FirstName='{inputs_dict['FirstName']}' and MiddleName='{inputs_dict['MiddleName']}' and LastName='{inputs_dict['LastName']}'"""
middle_name = inputs_dict['MiddleName']
sqlQuery = f"""select * from [SalesLT].[Customer] WHERE FirstName=? and MiddleName=? and LastName=?"""
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Null middle-name handling is now broken: when MiddleName is empty you set middle_name = "NULL" and still run MiddleName = ?. In SQL Server, MiddleName = NULL never matches (and the literal string "NULL" is not SQL NULL), so customers with a NULL MiddleName will not be returned. Suggest using None for the parameter and switching the WHERE clause to MiddleName IS NULL for that branch (or using a predicate that correctly matches NULLs).

Copilot uses AI. Check for mistakes.
else:
sqlQuery = f"""select * from [SalesLT].[Customer] WHERE FirstName='{inputs_dict['FirstName']}' and MiddleName='{inputs_dict['MiddleName']}' and LastName='{inputs_dict['LastName']}'"""
middle_name = inputs_dict['MiddleName']
sqlQuery = f"""select * from [SalesLT].[Customer] WHERE FirstName=? and MiddleName=? and LastName=?"""
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The query still uses select * on SalesLT.Customer, and the flow sample output includes sensitive fields like PasswordHash and PasswordSalt. Returning these values (especially into an LLM-driven flow) is a data-exposure risk. Please select only the needed columns and explicitly exclude credential-related fields.

Suggested change
sqlQuery = f"""select * from [SalesLT].[Customer] WHERE FirstName=? and MiddleName=? and LastName=?"""
sqlQuery = """
SELECT
CustomerID,
NameStyle,
Title,
FirstName,
MiddleName,
LastName,
Suffix,
CompanyName,
SalesPerson,
EmailAddress,
Phone,
rowguid,
ModifiedDate
FROM [SalesLT].[Customer]
WHERE FirstName=? AND MiddleName=? AND LastName=?
"""

Copilot uses AI. Check for mistakes.
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