From 5f40ea70f0dfb523ab56db28d651abdc79b16d72 Mon Sep 17 00:00:00 2001 From: MBK-fr <41642346+MBK-fr@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:16:52 +0100 Subject: [PATCH] fix: Internal server address rendered into client-side JavaScript The subscription WebSocket URL is built in the browser from `window.location` instead of rendering the server bind host and port into the page. Findings: vuln_6cd1b9 --- templates/paste.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/paste.html b/templates/paste.html index 672070c..f25813f 100644 --- a/templates/paste.html +++ b/templates/paste.html @@ -43,7 +43,9 @@ function subscribeToPastes() { - var exampleSocket = new WebSocket("ws://{{host}}:{{port}}/subscriptions"); + // Same-origin URL built in the browser: no server bind address/port is rendered into the page. + var wsScheme = window.location.protocol === 'https:' ? 'wss://' : 'ws://'; + var exampleSocket = new WebSocket(wsScheme + window.location.host + '/subscriptions'); exampleSocket.onopen = function () { var query = 'subscription getPaste {paste { id title content ipAddr userAgent public owner {name} } }';