[PM-30751] - add secure SSRF protection for internal IPs#7184
Open
jaasen-livefront wants to merge 1 commit intomainfrom
Open
[PM-30751] - add secure SSRF protection for internal IPs#7184jaasen-livefront wants to merge 1 commit intomainfrom
jaasen-livefront wants to merge 1 commit intomainfrom
Conversation
|
Contributor
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7184 +/- ##
==========================================
+ Coverage 57.08% 57.10% +0.02%
==========================================
Files 2028 2031 +3
Lines 88794 88855 +61
Branches 7914 7925 +11
==========================================
+ Hits 50684 50741 +57
Misses 36279 36279
- Partials 1831 1835 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.




🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-30751
📔 Objective
Adds centralized SSRF (Server-Side Request Forgery) protection to prevent server-initiated HTTP requests from reaching internal/private/reserved IP ranges when the destination URL is derived from external input.
Problem
SSRF protection logic existed only in the Icons project (
IPAddressExtension), and did not cover CGNAT ranges (RFC 6598). Multiple other HTTP clients accepting user-supplied or admin-configured URLs had no IP validation at all.Solution
Shared IP validation — Moved
IsInternal()logic fromIconsintoCore/Utilities/IPAddressExtensions.csso all projects can use it. Added CGNAT blocking (100.64.0.0/10).SsrfProtectionHandler— ADelegatingHandlerthat:SsrfProtectionExceptionif any resolved IP is internalHostheader for TLS SNIOne-line opt-in —
IHttpClientBuilder.AddSsrfProtection()extension method to wire the handler into any namedHttpClient.Protected clients
ChangePasswordUriServiceWebhookIntegrationHandlerDatadogIntegrationHandlerSlackServiceTeamsServiceIcons(fetch + redirect)Out-of-scope clients (server-configured URLs not from external input):
BaseIdentityClientService,SSOController,NotificationHubPushRegistrationService,AliveJob,HomeController.Changes
src/Core/Utilities/IPAddressExtensions.cs— shared IP blocklist with CGNATsrc/Core/Utilities/SsrfProtectionHandler.cs— DNS-resolving delegating handlersrc/Core/Utilities/HttpClientBuilderSsrfExtensions.cs—.AddSsrfProtection()extensionsrc/Icons/Util/IPAddressExtension.cs— delegates to shared Core implementationsrc/Icons/Util/ServiceCollectionExtension.cs— adds SSRF protection to Icons/ChangePasswordUri clientssrc/Core/Dirt/EventIntegrations/EventIntegrationsServiceCollectionExtensions.cs— adds SSRF protection to Webhook, Datadog, Slack, Teams clientstest/Core.Test/Utilities/IPAddressExtensionsTests.cs— 30 test cases covering all IP ranges + CGNAT boundariestest/Core.Test/Utilities/SsrfProtectionHandlerTests.cs— 21 test cases for handler behaviorFuture usage
Any new HTTP client that accepts external input can opt in with:
📸 Screenshots