fix(security): remove open SSRF proxy and add endpoint validation#342
Open
aglichandrap wants to merge 1 commit into
Open
fix(security): remove open SSRF proxy and add endpoint validation#342aglichandrap wants to merge 1 commit into
aglichandrap wants to merge 1 commit into
Conversation
Fixes IntersectMBO/govtool#4168 Changes: - Remove the unrestricted forward() handler (POST /api/proxy) that allowed any unauthenticated user to make the server fetch arbitrary URLs - Remove the corresponding POST /proxy route - Add validateEndpoint() helper that rejects: absolute URLs, protocol-relative URLs, path traversal sequences (..), null bytes, and backslashes - Apply endpoint validation to getGovtoolData and postGovtoolData handlers - Add GOVTOOL_API_BASE_URL null check with proper error response - Enable Authorization header forwarding when GOVTOOL_API_TOKEN is configured - Fix govtool-proxy controller with same SSRF protections - Remove console.log(leaked URL) from govtool-proxy controller - Translate Serbian comments to English in govtool-proxy The generic POST /api/proxy endpoint was dead code - the frontend only uses /api/proxy/govtool/... routes. Removing it eliminates the critical SSRF vulnerability (CVSS 9.1) that allowed cloud credential theft, internal network traversal, and arbitrary request forgery.
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
Fixes IntersectMBO/govtool#4168 — Unauthenticated Open SSRF Proxy (CVSS 9.1 Critical)
Vulnerability
The
POST /api/proxyendpoint was a fully open, unauthenticated HTTP proxy. Any attacker could send a single POST request and make the server fetch any URL, controlling the HTTP method, headers, query parameters, and request body. This enabled:Changes
Critical fix — Remove open SSRF proxy:
forward()handler frombackend/src/api/proxy/controllers/proxy.jsPOST /proxyroute frombackend/src/api/proxy/routes/proxy.js/api/proxy/govtool/...routesHardening — Validate govtool proxy endpoints:
validateEndpoint()helper that rejects:http://,https://)//)..)getGovtoolDataandpostGovtoolDatahandlersGOVTOOL_API_BASE_URLnull check with proper error responseGOVTOOL_API_TOKENis configuredHardening — Fix govtool-proxy endpoint:
backend/src/api/govtool-proxy/controllers/govtool-proxy.jsconsole.log(fullUrl)that leaked URLs to server logsImpact
GOVTOOL_API_BASE_URLPOST /api/proxyaccepts arbitrary URLs..,\, null bytes, absolute URLs all rejectedGOVTOOL_API_TOKENforwarded when configuredTesting
The SSRF mitigation can be verified with these curl commands (should all return 400):
Fixes #4168