SCAL-336249 Add whitelabled MCP server - #69
Open
shikharbsar wants to merge 1 commit into
Open
shikharbsar wants to merge 1 commit into
shikharbsar wants to merge 1 commit into
Conversation
⛔ Snyk checks have failed. 1 issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| } | ||
|
|
||
| const hasBody = !["GET", "HEAD"].includes(req.method); | ||
| const upstreamRes = await fetch(upstreamUrl, { |
There was a problem hiding this comment.
Server-Side Request Forgery (SSRF)
Unsanitized input from the request URL flows into fetch, where it is used as an URL to perform a request. This may result in a Server-Side Request Forgery vulnerability.
Line 147 | CWE-918 | Priority score 650 | Learn more about this vulnerability
Data flow: 9 steps
Step 1 - 7
Step 8 - 9
⚡ Refresh the page to see if a fix suggestion is available 🔄
There was a problem hiding this comment.
⚡ Snyk Agent Fix suggestion 1 of 1
The Server-Side Request Forgery (SSRF) vulnerability was fixed by validating that the constructed upstream URL's origin matches the trusted upstream base origin and then rebuilding the fetch target as a string from the trusted origin plus only the path and search components.
Code changes
--- mcp/node-proxy-trusted-auth/src/index.ts
+++ mcp/node-proxy-trusted-auth/src/index.ts
@@ -137,14 +137,20 @@
}
}
- const upstreamUrl = new URL(upstreamPath, upstreamBaseUrl);
+ const upstreamBase = new URL(upstreamBaseUrl);
+ const upstreamUrl = new URL(upstreamPath, upstreamBase);
const queryIndex = req.originalUrl.indexOf("?");
if (queryIndex !== -1) {
upstreamUrl.search = req.originalUrl.slice(queryIndex);
}
+ if (upstreamUrl.origin !== upstreamBase.origin) {
+ res.status(400).json({ error: "Invalid upstream URL" });
+ return;
+ }
+ const safeUpstreamUrl = `${upstreamBase.origin}${upstreamUrl.pathname}${upstreamUrl.search}`;
const hasBody = !["GET", "HEAD"].includes(req.method);
- const upstreamRes = await fetch(upstreamUrl, {
+ const upstreamRes = await fetch(safeUpstreamUrl, {
method: req.method,
headers: {
...forwardableRequestHeaders(req),
Content generated by AI, expires on 2026-09-17 22:24:08 UTC. Refresh the page after running Snyk commands.
Commands
- ✅ To apply this fix and create a commit - reply with
@snyk /apply 1
This branch has not been deployed
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.
No description provided.