mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Gateway: ALLOWED_SERVERS ignored text after a bracketed host
stripPort("[allowed]evil.tld") returned "allowed", so the allowlist
accepted the host while the connector resolved and contacted evil.tld.
A bracketed host may now only be followed by :port.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
5f9950a96b
commit
512366bc94
2 files changed
+39
-2
No files matched your search
@@ -50,8 +50,10 @@ const allowedServers = () =>
|
||||
// as-is. Deliberately not full URL parsing - `host` here is never a URL.
|
||||
function stripPort(host: string): string {
|
||||
if (host.startsWith("[")) {
|
||||
const end = host.indexOf("]");
|
||||
return end === -1 ? host : host.slice(1, end);
|
||||
// Only "[v6]" or "[v6]:port"; anything after "]" would otherwise be
|
||||
// ignored here but still reach the connector ("[allowed]evil.tld").
|
||||
const m = /^\[([^\]]*)\](?::\d+)?$/.exec(host);
|
||||
return m ? m[1] : host;
|
||||
}
|
||||
const i = host.lastIndexOf(":");
|
||||
return i !== -1 && /^\d+$/.test(host.slice(i + 1)) ? host.slice(0, i) : host;
|
||||
|
||||
Reference in new issue
Block a user