@@ -229,6 +229,45 @@ void usesClientReachableAddressForProxiedUrlsWhenRemoteUrlProvided() {
229229 .isEqualTo ("ws://localhost:9999/session/" + session .getId () + "/se/vnc" );
230230 }
231231
232+ @ Test
233+ void ignoresRemoteUrlPathWhenBuildingProxiedUrls () {
234+ // The client's URL path (e.g. "/wd/hub") is its HTTP endpoint, not a Grid sub-path; folding it
235+ // into the proxied websocket URLs would produce routes the Node does not serve. Only the
236+ // origin (host/port) of se:remoteUrl is used.
237+ Capabilities request =
238+ new ImmutableCapabilities (
239+ "browserName" ,
240+ "cheese" ,
241+ "se:vncLocalAddress" ,
242+ "localhost:5900" ,
243+ "se:remoteUrl" ,
244+ "http://localhost:9999/wd/hub" );
245+
246+ Either <WebDriverException , CreateSessionResponse > response =
247+ local .newSession (createSessionRequest (request ));
248+ assertThatEither (response ).isRight ();
249+
250+ Session session = response .right ().getSession ();
251+ assertThat (String .valueOf (session .getCapabilities ().getCapability ("se:vnc" )))
252+ .isEqualTo ("ws://localhost:9999/session/" + session .getId () + "/se/vnc" );
253+ }
254+
255+ @ Test
256+ void doesNotReturnRemoteUrlInSessionCapabilities () {
257+ Capabilities request =
258+ new ImmutableCapabilities (
259+ "browserName" , "cheese" , "se:remoteUrl" , "http://user:secret@localhost:9999" );
260+
261+ Either <WebDriverException , CreateSessionResponse > response =
262+ local .newSession (createSessionRequest (request ));
263+ assertThatEither (response ).isRight ();
264+
265+ // se:remoteUrl is transport-only: it is consumed to build the proxied URLs and must not be
266+ // echoed back in the session capabilities, where its embedded credentials could leak.
267+ Session session = response .right ().getSession ();
268+ assertThat (session .getCapabilities ().getCapability ("se:remoteUrl" )).isNull ();
269+ }
270+
232271 @ Test
233272 void preservesCredentialsFromClientAdvertisedRemoteUrl () {
234273 Capabilities request =
0 commit comments