Repository navigation
Conversation
Co-authored-by: ithewei <26049660+ithewei@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SSRF vulnerability in HttpService::GetProxyUrl method
Prevent reverse-proxy SSRF via Oct 28, 2026
@ in sub-path of authority-only target
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Scheme-less proxy targets remain vulnerable to SSRF because an attacker-controlled path can determine the host selected by URL parsing.
1 open issue
What changed in this PR
This PR hardens libhv’s reverse-proxy URL construction against the authority-changing @ payload reported in #915.
Changes:
- Inserts
/before a nonempty, non-slash-prefixed request suffix when the configured backend has no path. - Preserves existing concatenation behavior for targets that already contain a path.
| File | Description |
|---|---|
http/server/HttpService.cpp |
Adds an authority/path separator check in GetProxyUrl(). |
Review effort: Balanced
Comment on lines
+202
to
+203
| size_t authority = url.find("://"); | ||
| authority = authority == std::string::npos ? 0 : authority + 3; |
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.

HttpService::GetProxyUrl()joins the configured backend URL and the stripped request path by plain string concatenation. If the backend has no path (e.g.Proxy("/api/", "http://127.0.0.1:18081")), a request likeGET /api/@169.254.169.254:80/latest/meta-data/produces******169.254.169.254:80/....HUrl::parse()reads the configured host as userinfo and the attacker-supplied one as the real host.connectProxy()only checks the host for forward proxies, so the reverse proxy fetches an arbitrary host and returns the response.GetProxyUrl()/, a/is inserted before appending it.@now ends up in the path, not the authority:http://host/v1/) are unchanged. An@after the first/can't change the host.connectProxy(). The/insertion closes the reported vector on its own.