Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 016f3f0

Browse files
committed
Merge pull request #550 from adobe/swmitra/LocalNodeConnection
Accept only local origin connection request
2 parents aeed22c + 44a6eeb commit 016f3f0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

appshell/node-core/Server.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,20 @@ maxerr: 50, node: true */
199199
stop();
200200
});
201201

202-
wsServer = new WebSocket.Server({server: httpServer});
202+
wsServer = new WebSocket.Server({
203+
server: httpServer,
204+
verifyClient : function (info, callback) {
205+
// Accept connections originated from local system only
206+
// Also do a loose check on user-agent to accept connection only from Brackets CEF shell
207+
if (info.origin === "file://" && info.req.headers["user-agent"].indexOf(" Brackets") !== -1) {
208+
callback(true);
209+
} else {
210+
// Reject the connection
211+
callback(false);
212+
}
213+
}
214+
});
215+
203216
wsServer.on("error", function () {
204217
Logger.error(
205218
"[Server] stopping due to WebSocket error",

0 commit comments

Comments
 (0)