Skip to content

Commit 182643c

Browse files
authored
security: prevent remote link in websocket (#3677)
1 parent 9eabc33 commit 182643c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class WebSocketBrowserServer {
8686
// Extract base URL and port for validation
8787
const baseUrl = cdpUrl.includes('/devtools/') ? cdpUrl.split('/devtools/')[0] : cdpUrl;
8888

89+
// Validate CDP URL to prevent SSRF - only allow localhost
90+
const parsed = new URL(baseUrl);
91+
if (!['localhost', '127.0.0.1'].includes(parsed.hostname)) {
92+
throw new Error('CDP URL must use localhost or 127.0.0.1');
93+
}
94+
8995
try {
9096
// Test if Chrome debug port is accessible and get page URL
9197
const response = await fetch(`${baseUrl}/json`);

0 commit comments

Comments
 (0)