Skip to content

Conversation

sezal98
Copy link
Contributor

@sezal98 sezal98 commented Apr 18, 2025

Why make this change?

Internal Issue Resolved

What is this change?

Created a check before creating the HttpClient where the URI would be validated
Conditions

  1. It ensures the URI is absolute.
  2. It checks for valid HTTP/HTTPS schemes.
  3. Disallow empty hostnames

Working as expected
Code QL resolution would be checked after merging and running the pipelines

@Copilot Copilot AI review requested due to automatic review settings April 18, 2025 08:54
Copy link
Contributor

@Copilot 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 resolves a potential SSRF vulnerability in the HealthCheck service by validating outbound URIs before creating an HttpClient.

  • Added inbound checks in ConfigureApiRoute to validate the URI using a new helper function.
  • Introduced the IsValidOutboundUri method to ensure the URI is absolute, employs HTTP/HTTPS schemes, and has a non-empty hostname.
Comments suppressed due to low confidence (1)

src/Service/HealthCheck/HttpUtilities.cs:105

  • [nitpick] Consider extracting the error message 'Blocked outbound request due to invalid or unsafe URI.' into a reusable constant to avoid duplication and ensure consistency.
LogTrace("Blocked outbound request due to invalid or unsafe URI.");

Copy link
Contributor

@aaronburtle aaronburtle left a comment

Choose a reason for hiding this comment

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

LGTM!

@aaronburtle
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@sezal98 sezal98 enabled auto-merge (squash) April 22, 2025 16:07
@sezal98 sezal98 changed the title [S360] Resolve SSRF in HealhCheck Resolve SSRF in HealhCheck Apr 22, 2025
@sezal98 sezal98 disabled auto-merge April 23, 2025 05:29
@sezal98
Copy link
Contributor Author

sezal98 commented Apr 28, 2025

/azp run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@sezal98 sezal98 requested a review from Aniruddh25 April 28, 2025 12:01
@sezal98
Copy link
Contributor Author

sezal98 commented Apr 28, 2025

/azp run

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@sezal98
Copy link
Contributor Author

sezal98 commented Apr 29, 2025

/azp run

@sezal98 sezal98 requested a review from Aniruddh25 April 29, 2025 00:42
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@sezal98 sezal98 merged commit db54a66 into main Apr 29, 2025
11 checks passed
@sezal98 sezal98 deleted the dev/sezalchug/ssrfUtilities branch April 29, 2025 06:28
@Aniruddh25 Aniruddh25 added this to the 1.5 milestone May 11, 2025
RubenCerna2079 pushed a commit that referenced this pull request May 16, 2025
## Why make this change?
Internal Issue Resolved

## What is this change?
Created a check before creating the HttpClient where the URI would be
validated
Conditions
1.  It ensures the URI is absolute.
2. It checks for valid HTTP/HTTPS schemes.
3. Disallow empty hostnames

Working as expected 
Code QL resolution would be checked after merging and running the
pipelines

---------

Co-authored-by: sezalchug <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
@sezal98 sezal98 self-assigned this May 21, 2025
RubenCerna2079 pushed a commit that referenced this pull request May 29, 2025
## Why make this change?
Internal Issue Resolved

## What is this change?
Created a check before creating the HttpClient where the URI would be
validated
Conditions
1.  It ensures the URI is absolute.
2. It checks for valid HTTP/HTTPS schemes.
3. Disallow empty hostnames

Working as expected
Code QL resolution would be checked after merging and running the
pipelines

---------

Co-authored-by: sezalchug <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
aaronburtle added a commit that referenced this pull request May 29, 2025
## Why make this change?

This change is made in order to add all of the commits for milestone 1.5
into its respective branch.

## What is this change?

This change cherry-picks all of the commits that were added after the
first release candidate.
Cherry-picked commits:
 - #2648 
#2657
#2617 
#2659 
#2655 
#2633 
#2667 
#2673 
#2650 
#2695 
#2702 
#2688

## How was this tested?

- [ ] Integration Tests
- [ ] Unit Tests

## Sample Request(s)

---------

Co-authored-by: Sezal Chug <[email protected]>
Co-authored-by: sezalchug <[email protected]>
Co-authored-by: Tommaso Stocchi <[email protected]>
Co-authored-by: Aaron Powell <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: Jerry Nixon <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Michael Staib <[email protected]>
Co-authored-by: souvikghosh04 <[email protected]>
Co-authored-by: Souvik Ghosh <[email protected]>
RubenCerna2079 pushed a commit that referenced this pull request May 29, 2025
Internal Issue Resolved

Created a check before creating the HttpClient where the URI would be
validated
Conditions
1.  It ensures the URI is absolute.
2. It checks for valid HTTP/HTTPS schemes.
3. Disallow empty hostnames

Working as expected
Code QL resolution would be checked after merging and running the
pipelines

---------

Co-authored-by: sezalchug <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
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