fix: prevent SSRF in /api/detect-favicon by blocking private/internal IPs#298
Closed
tranquac wants to merge 1 commit intoNotifuse:mainfrom
Closed
fix: prevent SSRF in /api/detect-favicon by blocking private/internal IPs#298tranquac wants to merge 1 commit intoNotifuse:mainfrom
tranquac wants to merge 1 commit intoNotifuse:mainfrom
Conversation
… IPs Signed-off-by: tranquac <tranquac@users.noreply.github.com>
Contributor
|
Hi @tranquac , thanks for the report, I'll implement a fix in the next release. |
Contributor
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.
Summary
Prevent Server-Side Request Forgery (SSRF) in the
/api/detect-faviconendpoint by validating that user-supplied URLs do not resolve to private or internal IP addresses.Problem
The
HandleDetectFaviconendpoint accepts a user-supplied URL and fetches it server-side usinghttp.Get()without validating that the target is not an internal resource:An attacker can use this to:
POST /api/detect-favicon {"url": "http://169.254.169.254/latest/meta-data/"}— leaks IAM credentials on AWS/GCP/AzureThe
findManifestIconhelper also makes follow-up HTTP requests to URLs extracted from the fetched page, enabling chained SSRF where the initial page redirects to an internal target.Fix
Added IP validation before any outbound HTTP request in the favicon detection flow:
validateExternalURL(): Resolves the URL's hostname and checks all resolved IPs against a blocklistisPrivateOrReservedIP(): Blocks RFC 1918 private ranges, loopback, link-local (including cloud metadata169.254.169.254), and IPv6 equivalentsBlocked ranges:
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16(private)127.0.0.0/8(loopback)169.254.0.0/16(link-local / cloud metadata)::1/128,fc00::/7,fe80::/10(IPv6 equivalents)Impact
POST /api/detect-favicon