Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Billing and moderation hooks: warn when a bearer token travels over plain HTTP

Adarsh63720bcc73f1
diff --git a/src/server/hook-client.ts b/src/server/hook-client.ts
index 93cc5618..1fe2aacf 100644
--- a/src/server/hook-client.ts
+++ b/src/server/hook-client.ts
@@ -23,6 +23,14 @@ export class HookDown extends Error {
/** Where a service is: an http(s) base URL, or a Unix socket path. */
export type HookTarget = { kind: "url"; base: URL } | { kind: "socket"; path: string };
+const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
+function isLoopback(hostname: string): boolean {
+ if (LOOPBACK_HOSTS.has(hostname)) return true;
+ // 127.0.0.0/8
+ const parts = hostname.split(".");
+ return parts.length === 4 && parts[0] === "127" && parts.every((p) => /^\d{1,3}$/.test(p));
+}
+
/** Parse a hook address. `unix:/path.sock` (or `unix:///path.sock`) is a socket; anything else must be an http(s) URL. */
export function hookTarget(raw: string): HookTarget | null {
const v = raw.trim();
@@ -34,6 +42,12 @@ export function hookTarget(raw: string): HookTarget | null {
try {
const base = new URL(v);
if (base.protocol !== "http:" && base.protocol !== "https:") return null;
+ if (base.protocol === "http:" && !isLoopback(base.hostname)) {
+ console.warn(
+ `[hook] WARNING: ${v} is plain HTTP on a non-loopback address. ` +
+ `Bearer tokens and payloads will travel unencrypted. Use https: or a unix: socket.`,
+ );
+ }
return { kind: "url", base };
} catch {
return null;