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.

Fuobe Connect: refuse every absolute path form and pin the inputs nodes read as files

Adarshb15445500fe7
diff --git a/docs/gpu-workers.md b/docs/gpu-workers.md
index f409580f..b98a6d3c 100644
--- a/docs/gpu-workers.md
+++ b/docs/gpu-workers.md
@@ -23,13 +23,24 @@ only at `127.0.0.1`, `::1` or `localhost`. Fuobe Connect checks each of its requ
page checked:
- a workflow runs only when every node type is on the list the pack ships (`fuobe_connect/allowed_nodes.json`, written
- by `node scripts/connect-nodes.mjs` from the same sources as the worker's list) or on the person's own list, no text
- input names a path or an address, and every loader reads a Fuobe input (`fuobe_<id>.<ext>`);
+ by `node scripts/connect-nodes.mjs` from the same sources as the worker's list) or on the person's own list, and:
+ - no text names a place: an absolute path in any form (`/x`, `\x`, `//host/share`, `\\?\C:\x`, `C:\x`, `D:x`), a
+ `..` step, a home folder (`~`, `~user`), an environment variable at the start, a URL, a folder tag, or a JSON key
+ that names a file, a folder or an address. Spaces and quotes in front don't hide one;
+ - an input that a listed node reads as a file or a folder holds the one value or form the studio's own graphs use,
+ written in the graph, never a link (`PATH_INPUTS` in `fuobe_connect/graph.py`);
+ - every loader reads a Fuobe input (`fuobe_<id>.<ext>`), and no node gets a JSON object except a 3D view's entries;
- an upload goes only into the input folder, under a Fuobe input name;
- the studio sees, cancels, stops and downloads only its own prompts and their results; the queue shows other prompts
- only as places in the line, and the node list hides the names of the person's input files.
+ only as places in the line, the node list hides the names of the person's input files, and the model lists leave
+ out `custom_nodes` and `configs`.
-It cannot reach the Manager's install calls, the person's user files, settings, input files or own results. Fuobe
+When a graph builder starts giving one of those inputs a new value, add its form to `PATH_INPUTS` and ship it with the
+next Fuobe Connect release (the pack's `tests/test_graph.py` runs every workflow in `workflows/comfyui` through the
+checks).
+
+It cannot reach the Manager's install calls, the person's user files or settings, a file of the person's in the input
+folder, or the person's own results, and its workflows cannot open a file of the person's by its path. Fuobe
Connect answers the CORS and Private Network Access preflights for the trusted origins only. Every other website still
meets ComfyUI's own check.
diff --git a/integrations/fuobe-connect/README.md b/integrations/fuobe-connect/README.md
index 61ecc41e..4a96faf9 100644
--- a/integrations/fuobe-connect/README.md
+++ b/integrations/fuobe-connect/README.md
@@ -30,27 +30,37 @@ must start with `https://` (`http://` only for a studio on this computer, such a
A trusted studio reaches this ComfyUI only at `127.0.0.1`, `::1` or `localhost`, never at a network address. Its page
can:
-- read ComfyUI's facts (`/system_stats`: version, GPU, memory, start options), its node list and its model lists. In
+- read ComfyUI's facts (`/system_stats`: version, GPU, memory, start options), its node list and the file lists of its
+ model folders, with each folder's place on disk (every folder ComfyUI lists, except `custom_nodes` and `configs`). In
the node list, the loaders show only Fuobe's own input files, not your file names;
- upload a run's input into the input folder, only under a name Fuobe gives (`fuobe_<id>.png` and similar), only as a
picture, clip, sound, 3D scene or data file. It can replace an earlier Fuobe input, never a file of yours;
- queue a workflow. Fuobe Connect checks every workflow here, in Python, before ComfyUI sees it:
- every node type must be on the list this pack ships (`fuobe_connect/allowed_nodes.json`: the nodes Fuobe's own
workflows use), or on your own list (below). A studio can't add to either list;
- - no text input may name a path or an address: an absolute path, a drive letter, a network share, a `..` step, a
- home folder, a URL, or a ComfyUI folder tag such as `name [output]`;
- - every file loader must read a Fuobe input (`fuobe_<id>.<ext>`), never a file of yours.
-
- A workflow that uses an installed node from the list can still do what that node does (for example, save into your
- output folder);
+ - no text may name a place: an absolute path in any form (`/x`, `\x`, `//host/share`, `\\?\C:\x`, `C:\x`, or a
+ drive with no slash such as `D:x`), a `..` step, a home folder (`~`, `~user`), an environment variable at the start
+ (`$HOME/`, `%USERPROFILE%\`), a URL, a ComfyUI folder tag such as `name [output]`, or a key in JSON that names a
+ file, a folder or an address (`"video_path": …`). Spaces and quotes in front don't hide one;
+ - an input that a listed node reads as a file or a folder takes only the one value or form that Fuobe's own
+ workflows use, written in the workflow itself and never worked out by another node. For example, the source
+ paths of `MiniMaxH3SourceTimeline` must be empty, and the subtitle file of `AILab_Qwen3ASRSubtitle` must be empty
+ or under `fuobe/` in your output folder. `PATH_INPUTS` in `fuobe_connect/graph.py` lists every one;
+ - every file loader must read a Fuobe input (`fuobe_<id>.<ext>`), never a file of yours;
+ - the workflow may not give a node a JSON object (ComfyUI passes one on unchecked), except a 3D view's entries.
+
+ A workflow that uses an installed node from the list can still do what that node does in ComfyUI's own folders: for
+ example, save into your output folder, or keep a node pack's own cache;
- see, follow, cancel, stop and remove only the prompts it queued (and a batch's later passes, which save under
`fuobe/<id>`). In the queue, your own prompts show only as places in the line. It can't clear the queue or stop
your own work;
- download only the results that its own prompts' history lists;
- open ComfyUI's live socket only under a Fuobe client id (`fuobe-…`), never your own ComfyUI tab's.
-A trusted studio can't reach the Manager's install calls, your user files, your settings, your input files or your
-own results. Every other website still meets ComfyUI's own check, unchanged. Nothing in ComfyUI's own files changes.
+A trusted studio can't reach the Manager's install calls, your user files or your settings. It can't read a file of
+yours in the input folder or download a result of yours, and its workflows can't open a file of yours by its path. Of
+ComfyUI's folder lists it can't read `custom_nodes` (every file of your node packs) or `configs`. Every other website
+still meets ComfyUI's own check, unchanged. Nothing in ComfyUI's own files changes.
If ComfyUI runs with `--enable-cors-header` (an older Fuobe setup), ComfyUI's own check is off. Fuobe Connect then also
turns away every website except ComfyUI's own page, the site that the setting names and the trusted studios. This is
diff --git a/integrations/fuobe-connect/fuobe_connect/graph.py b/integrations/fuobe-connect/fuobe_connect/graph.py
index 1b12a104..80fdeb29 100644
--- a/integrations/fuobe-connect/fuobe_connect/graph.py
+++ b/integrations/fuobe-connect/fuobe_connect/graph.py
@@ -4,10 +4,17 @@ A graph from a studio (a trusted page in direct mode, or the paired studio in pa
- every node type is on the list that ships inside this pack (allowed_nodes.json: the nodes Fuobe's own workflows use),
plus the types you list yourself in fuobe-connect-nodes.json in ComfyUI's user folder. A studio can never add to it;
-- no text input names a path or an address: an absolute path, a drive letter, a network share, a ".." step, a home
- folder, a URL, or one of ComfyUI's folder tags ("name [output]", "name [temp]");
+- no text names a place: an absolute path in any form ("/x", "\\x", "//host/share", "\\\\?\\C:\\x", "C:\\x", "C:x"), a
+ ".." step, a home folder ("~", "~user"), an environment variable at the start ("$HOME/", "%USERPROFILE%\\"), a URL,
+ one of ComfyUI's folder tags ("name [output]", "name [temp]"), or a JSON key that names a file, folder or address
+ ("video_path": ...). The check looks at the text after its leading spaces and quotes, as a node that trims it sees it;
+- every input that a listed node reads as a file or a folder (PATH_INPUTS) holds a value the graph writes itself, in the
+ one form Fuobe's own graphs use. It never takes a link: another node could work out any text;
- every file loader reads one of the files Fuobe sent for the run (named fuobe_<id>.<ext>), never a file of yours and
- never a value that another node works out.
+ never a value that another node works out;
+- a value the graph writes is never a JSON object, except a 3D view's entries: ComfyUI hands an object to a node
+ unchecked, and some nodes read a file's path from one;
+- a few inputs take only a link from one node type, or text of one shape (LINK_INPUTS, TEXT_INPUTS).
A result is downloaded only when this run's own history lists it. A model name is not checked here: ComfyUI itself
refuses a model name that isn't in your model folders.
@@ -54,22 +61,32 @@ FILE_LOADERS = {
"AUSBOSS_NODES_ImageCropRotatePad": ["image"],
# Any Angle's saved 3D view: the scene file, and the picture entries (checked one by one below).
"Load3D": ["model_file"],
+ # Hi3D's coarse mesh: any file in the input folder by name.
+ "Hi3DLoadMesh": ["mesh_file"],
+}
+# Loaders whose file is optional: "" (no file) or one of the run's own inputs.
+OPTIONAL_FILES = {
+ # A continuation history (.npz) read from the input folder.
+ "H3CharacterSwapShot": ["history_file"],
}
_FILEISH = re.compile(r"image|video|audio|file|path|directory", re.I)
_PATHLIKE = [
- re.compile(r"^[A-Za-z]:[\\/]"), # C:\ or C:/
- re.compile(r"^\\\\"), # \\server\share, \\?\C:\
- re.compile(r"^/(?!/)[^\s]*/"), # /etc/passwd
- re.compile(r"^/(?!/)\S+\Z"), # /secret.png
+ re.compile(r"^[\\/]"), # /etc/passwd, \Users\x, //host/share, //?/C:/x, \\host\share, \\?\C:\x, \/host/share
+ re.compile(r"^[A-Za-z]:(?![ \t])"), # C:\x, C:/x, and C:x or D:Users\x (a drive with no slash)
+ re.compile(r"^~(?!\s)"), # ~, ~/x, ~user/x
+ re.compile(r"^(?:\$\{?[A-Za-z_][A-Za-z0-9_]*\}?|%[A-Za-z_][A-Za-z0-9_]*%)(?:[\\/]|\Z)"), # $HOME/x, %USERPROFILE%\x
re.compile(r"(^|[\\/])\.\.([\\/]|\Z)"), # a ".." step
- re.compile(r"^~[\\/]"), # ~/
re.compile(r"^[A-Za-z][A-Za-z0-9+.-]*://"), # a URL
re.compile(r"^file:", re.I),
re.compile(r"^blake3:", re.I), # ComfyUI's asset names reach any registered file
re.compile(r"\x00"),
]
+# A key in JSON (or a Python dict) inside a text: "video_path": ..., 'output_folder': ...
+_KEY = re.compile(r"""["']([A-Za-z0-9_.-]{1,64})["']\s*:""")
+_PLACE_KEY = re.compile(r"(?:^|[_.-])(?:paths?|files?|file_?names?|file_?paths?|dirs?|directory|folders?|urls?|uris?|roots?|assets?|href|src)\Z", re.I)
_TAG = re.compile(r" \[(input|output|temp)\]\Z")
+_QUOTES = "\"'`"
def staged_name_ok(name) -> bool:
@@ -77,9 +94,106 @@ def staged_name_ok(name) -> bool:
return isinstance(name, str) and bool(INPUT_NAME.match(name)) and name.rsplit(".", 1)[1] in INPUT_EXTS
+def _trimmed(v: str) -> str:
+ """The text as a node that trims spaces and quotes from its start sees it."""
+ while True:
+ t = v.lstrip().lstrip(_QUOTES)
+ if t == v:
+ return t
+ v = t
+
+
def unsafe_text(v: str) -> bool:
- """A text input that names a path, an address or a folder tag."""
- return any(p.search(v) for p in _PATHLIKE)
+ """A text that names a path, an address, a folder tag, or a file inside JSON."""
+ t = _trimmed(v)
+ return any(p.search(t) for p in _PATHLIKE) or any(_PLACE_KEY.search(k) for k in _KEY.findall(v))
+
+
+# ---------------------------------------------------------------------------
+# Inputs with rules of their own
+
+
+_NAME = r"[A-Za-z0-9_][A-Za-z0-9_.-]{0,95}" # one file or folder name: it never starts with a dot, so it is never ".."
+_NONE = re.compile(r"") # only "": the node's own default, no file
+
+# Inputs that a listed node reads as a file or a folder. Each one takes only a value the graph writes itself, in the one
+# form Fuobe's own graphs use; never a link. Every text input of every node on the shipped list was read in that node's
+# source (at the commits Fuobe's workflows/comfyui/requirements.json pins); the others are words, numbers or data that
+# no node opens as a file, or names that the node itself keeps inside ComfyUI's own folders.
+PATH_INPUTS: dict[str, dict[str, re.Pattern]] = {
+ # Writes a subtitle file at this path (an absolute one as given, else under the output folder).
+ "AILab_Qwen3ASRSubtitle": {"output_path": re.compile(r"(?:fuobe(?:/[A-Za-z0-9_-]{1,64}){1,4})?")},
+ # Model files, with $VARS and ~ expanded; a relative path is under the pack's own folder.
+ "AuKModelLoader": {
+ "checkpoint_path": re.compile(rf"ckpts/{_NAME}/{_NAME}\.safetensors"),
+ "config_path": _NONE,
+ "qwen_path": re.compile(rf"(?:ckpts/{_NAME})?"),
+ },
+ # A model folder ("" is ComfyUI's models/Hi3D).
+ "Hi3DModelLoader": {"model_root": _NONE},
+ # Opens any video or sound file at these paths.
+ "MiniMaxH3SourceTimeline": {"video_path": _NONE, "audio_path": _NONE},
+ # The run's own folder under output/h3_chains: Fuobe's jobs are named fuobe_<id> (or come from the swap plan nodes).
+ "MiniMaxH3ChainPlanModern": {"run_name": re.compile(r"fuobe_[A-Za-z0-9_-]{0,60}[A-Za-z0-9]")},
+ # A latent saved in output/open_h3_latents: only one a Fuobe draft saved (fuobe_h3_<id>_00001), never "(newest)",
+ # which would be whatever was saved last, yours too.
+ "OpenH3LoadRefinedLatent": {"latent_file": re.compile(r"fuobe_[A-Za-z0-9_-]{1,96}_\d{5}\.safetensors")},
+ # A SAM model in models/sams, else a path from ComfyUI's working folder (loaded with torch).
+ "QWMRefineMask": {"sam_model": re.compile(r"sam_vit_[bhl][A-Za-z0-9_.-]{0,64}\.pth")},
+ # Writes every window's frames into this folder.
+ "WanVideoImageToVideoMultiTalk": {"output_path": _NONE},
+ # A model folder, the adapter file and the text encoder (a folder, or a Hugging Face id it downloads).
+ "ZenImage21AdapterLoader": {
+ "model_folder": _NONE,
+ "adapter_file": re.compile(rf"models/text_encoders/{_NAME}\.safetensors"),
+ "text_encoder": re.compile(rf"Qwen/Qwen3\.5-0\.8B|models/text_encoders/{_NAME}"),
+ },
+}
+
+# Inputs that may also (or only) take a link, but only from these node types.
+_SWAP_PLANS = frozenset({"H3AdvancedSwapPlan", "H3ObjectSwapPlan", "H3OneClickSwapPlan", "H3PictureSwapPlan", "H3SceneSwapPlan", "H3MontagePlan"})
+LINK_INPUTS: dict[str, dict[str, frozenset]] = {
+ # The swap plan nodes name their runs from a hash of their inputs.
+ "MiniMaxH3ChainPlanModern": {"run_name": _SWAP_PLANS},
+ # An SVG that ComfyUI saves into the output folder: only the vectorizer's own.
+ "TS_SVGStringToSVGBytesIO": {"SVG_String": frozenset({"TS_ImageToSVGStringColor_Vtracer"})},
+}
+
+# A replacement field that reads an attribute or an item ("{a.__class__}", "{a[0]}"): Python's format can reach a
+# module's globals (os.environ) through a node's object.
+_FIELD_ACCESS = re.compile(r"(?<!\{)(?:\{\{)*\{[^{}!:]*[.\[]")
+
+# Text inputs that must have one shape (a value the graph writes; never a link).
+TEXT_INPUTS: dict[str, dict] = {
+ "StringFormat": {"f_string": lambda s: not _FIELD_ACCESS.search(s)},
+}
+
+# The only inputs that take a JSON object the graph writes: a 3D view's entries (Load3D's are checked below).
+OBJECT_INPUTS = frozenset({("Load3D", "image"), ("Save3DAdvanced", "viewport_state")})
+
+
+def is_link(v) -> bool:
+ """[node id, output slot]: a value another node works out."""
+ return isinstance(v, list) and len(v) == 2 and isinstance(v[0], str) and isinstance(v[1], int) and not isinstance(v[1], bool)
+
+
+def input_problem(graph: dict, cls: str, key: str, v) -> str | None:
+ """What is wrong with one input under its node's own rule: 'unsafe-path', 'unsafe-graph', or None."""
+ if isinstance(v, dict) and (cls, key) not in OBJECT_INPUTS:
+ return "unsafe-graph"
+ links = LINK_INPUTS.get(cls, {}).get(key)
+ if is_link(v) and links is not None:
+ src = graph.get(v[0])
+ return None if isinstance(src, dict) and src.get("class_type") in links else "unsafe-graph"
+ form = PATH_INPUTS.get(cls, {}).get(key)
+ if form is not None:
+ return None if isinstance(v, str) and form.fullmatch(v) else "unsafe-path"
+ shape = TEXT_INPUTS.get(cls, {}).get(key)
+ if shape is not None:
+ return None if isinstance(v, str) and shape(v) else "unsafe-path"
+ if links is not None:
+ return "unsafe-graph"
+ return None
# ---------------------------------------------------------------------------
@@ -167,6 +281,12 @@ def graph_problem(graph, staged: list[str] | None) -> str | None:
continue
if not _staged(v, staged):
return f"Node {node_id} ({cls}) reads a file this run didn't send"
+ for k in OPTIONAL_FILES.get(cls, []):
+ v = inputs.get(k)
+ if v is None or v == "":
+ continue
+ if not _staged(v, staged):
+ return f"Node {node_id} ({cls}) reads a file this run didn't send"
if cls == "Load3D" and "image" in inputs:
pics = inputs["image"]
if isinstance(pics, dict):
@@ -182,7 +302,8 @@ def graph_problem(graph, staged: list[str] | None) -> str | None:
def vet_graph(graph, allowed: frozenset | set, staged: list[str] | None) -> str | None:
"""The first reason this graph may not run here, or None. The reasons are the worker program's
- ('unknown-node', 'unsafe-path') and 'unsafe-graph' for a loader that reads a file this run didn't send."""
+ ('unknown-node', 'unsafe-path') and 'unsafe-graph': a loader that reads a file this run didn't send, a JSON object
+ the graph writes, or a link from a node that may not feed that input."""
if not isinstance(graph, dict) or not graph or len(graph) > 5000:
return "unsafe-graph"
for node in graph.values():
@@ -194,10 +315,13 @@ def vet_graph(graph, allowed: frozenset | set, staged: list[str] | None) -> str
continue
if not isinstance(inputs, dict):
return "unsafe-graph"
- for v in inputs.values():
+ for k, v in inputs.items():
for s in _strings(v):
if unsafe_text(s) or (_TAG.search(s) and not _staged(s, staged)):
return "unsafe-path"
+ why = input_problem(graph, node["class_type"], k, v)
+ if why:
+ return why
if graph_problem(graph, staged):
return "unsafe-graph"
return None
diff --git a/integrations/fuobe-connect/fuobe_connect/middleware.py b/integrations/fuobe-connect/fuobe_connect/middleware.py
index 7179b7ca..dfcb0469 100644
--- a/integrations/fuobe-connect/fuobe_connect/middleware.py
+++ b/integrations/fuobe-connect/fuobe_connect/middleware.py
@@ -99,8 +99,8 @@ def _refuse(message: str, status: int = 403) -> web.Response:
# What a refused graph means, in words the studio shows the person.
REASONS = {
"unknown-node": "Fuobe Connect on this computer doesn't run one of this workflow's node types. Update Fuobe Connect in ComfyUI-Manager, then retry.",
- "unsafe-path": "Fuobe Connect refused this workflow: it names a folder, a file path or a web address on this computer.",
- "unsafe-graph": "Fuobe Connect refused this workflow: it reads a file Fuobe didn't send.",
+ "unsafe-path": "Fuobe Connect refused this workflow: it names a folder, a file path or a web address, or a node's file setting isn't one Fuobe uses.",
+ "unsafe-graph": "Fuobe Connect refused this workflow: it reads a file Fuobe didn't send, or gives a node a value Fuobe Connect can't check.",
}
_PROMPT_KEYS = {"prompt", "prompt_id", "client_id", "extra_data", "front"}
diff --git a/integrations/fuobe-connect/fuobe_connect/origins.py b/integrations/fuobe-connect/fuobe_connect/origins.py
index 7eec78b3..d5c0667a 100644
--- a/integrations/fuobe-connect/fuobe_connect/origins.py
+++ b/integrations/fuobe-connect/fuobe_connect/origins.py
@@ -139,11 +139,14 @@ def trusted_origins(env_value: str | None, configured: str | list | None) -> tup
# body or the answer of several of these (middleware.py).
_UUID = r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
+# A model folder's list. ComfyUI also answers for folders that hold no models: custom_nodes (every file of every node
+# pack) and configs.
+_MODELS = r"models(?:/(?!(?:custom_nodes|configs)\Z)[A-Za-z0-9_.-]{1,64})?"
_GET = re.compile(
r"/(?:"
- r"system_stats|object_info(?:/[^/]{1,128})?|models(?:/[A-Za-z0-9_.-]{1,64})?|embeddings|queue|features"
+ rf"system_stats|object_info(?:/[^/]{{1,128}})?|{_MODELS}|embeddings|queue|features"
rf"|history(?:/{_UUID})?|jobs(?:/{_UUID})?|view|ws"
- r"|experiment/models(?:/[A-Za-z0-9_.-]{1,64})?"
+ rf"|experiment/{_MODELS}"
r"|(?:v2/)?manager/(?:version|queue/status)|(?:v2/)?customnode/installed"
r"|fuobe/connect|fuobe/guard|fuobe/live"
r")"
diff --git a/integrations/fuobe-connect/fuobe_connect/runner.py b/integrations/fuobe-connect/fuobe_connect/runner.py
index f1bed54a..7779d1b1 100644
--- a/integrations/fuobe-connect/fuobe_connect/runner.py
+++ b/integrations/fuobe-connect/fuobe_connect/runner.py
@@ -6,8 +6,9 @@ upload the results the studio asks for. It decides nothing about a result. Only
picks them by the token, which belongs to one person.
Before a job runs, Fuobe Connect checks it here, whatever the studio says (graph.py): every node type is on the list
-this pack ships (plus your own fuobe-connect-nodes.json), no text input names a path or an address, the inputs have the
-names Fuobe gives its files, and every loader reads one of them. Every id the studio sends is checked before it goes
+this pack ships (plus your own fuobe-connect-nodes.json), no text names a path or an address, a node's file or folder
+setting holds only Fuobe's own form, the inputs have the names Fuobe gives its files, and every loader reads one of
+them. Every id the studio sends is checked before it goes
into an address. Only the prompts this runner queued are followed, taken off or read back, and a result is uploaded only
when this job's own prompt (or its batch's passes, under the job's own fuobe/<id> prefix) saved it. One job at a time.
Pausing (ComfyUI's Connect to Fuobe window) stops it taking new jobs.
diff --git a/integrations/fuobe-connect/tests/test_graph.py b/integrations/fuobe-connect/tests/test_graph.py
index ad7a5549..f88ab2bb 100644
--- a/integrations/fuobe-connect/tests/test_graph.py
+++ b/integrations/fuobe-connect/tests/test_graph.py
@@ -17,7 +17,12 @@ sys.path.insert(0, PACK)
from fuobe_connect import __version__ # noqa: E402
from fuobe_connect.graph import ( # noqa: E402
+ FILE_LOADERS,
+ LINK_INPUTS,
+ OPTIONAL_FILES,
OWN_NODES_FILE,
+ PATH_INPUTS,
+ TEXT_INPUTS,
NodeList,
graph_problem,
may_download,
@@ -65,6 +70,7 @@ class VetTest(unittest.TestCase):
B + B + "server" + B + "share",
"/etc/passwd",
"/secret.png",
+ "/",
"../../secret.png",
"fuobe/" + ".." + "/x",
"~/.ssh/id_rsa",
@@ -81,6 +87,62 @@ class VetTest(unittest.TestCase):
for v in ["a red door", "wait.. what?", "...", "fuobe/gen123abc", "flux/model.safetensors", "1/2 cup", "fuobe_abcdefgh12.png [input]"]:
self.assertIsNone(vet_graph(g(node("CLIPTextEncode", text=v)), NODES, STAGED), v)
+ def test_every_absolute_form(self):
+ """Every way Windows, Linux and macOS read a text as a place outside a node's own folder."""
+ for v in [
+ "//?/C:/Users/Public/x.srt", # a Win32 device path with forward slashes
+ "//attacker.example/share/x.srt", # a network share with forward slashes
+ B + B + "?" + B + "C:" + B + "x", # \\?\C:\x
+ B + B + "." + B + "PhysicalDrive0", # \\.\PhysicalDrive0
+ B + "Users" + B + "Public" + B + "x.srt", # \Users\...: the root of ComfyUI's drive
+ B + "/attacker.example/share/x.srt", # \/host/share: a share too
+ "D:Users" + B + "x.srt", # a drive with no slash: that drive's own working folder
+ "C:x.srt",
+ "C:",
+ "~",
+ "~admin/Videos/x.mp4", # another account's home
+ "~admin",
+ "$HOME/x",
+ "${HOME}/x",
+ "$HOME",
+ "%USERPROFILE%" + B + "x",
+ "%APPDATA%",
+ # What a node that trims its text sees.
+ " C:/Users/me",
+ "\t/etc/passwd",
+ "\u3000" + B + "Users",
+ '"C:/Users/me"',
+ "'//host/share'",
+ ' " ~/x',
+ ]:
+ self.assertEqual(vet_graph(g(node("CLIPTextEncode", text=v)), NODES, STAGED), "unsafe-path", repr(v))
+ # Words that start like one but aren't: a dialogue line, a mood, a price, a share of something.
+ for v in ["A: hello there", "B:\tok", "~ dreamy ~", "$5 bill", "$HOME is where the heart is", "50% off", "%d frames", "SPEAKER A: Test"]:
+ self.assertIsNone(vet_graph(g(node("CLIPTextEncode", text=v)), NODES, STAGED), repr(v))
+
+ def test_a_place_inside_json(self):
+ """A plan or a settings text that a node parses: no key that names a file, a folder or an address."""
+ for v in [
+ '{"shots": [{"id": "a", "lip_sync_source_asset": {"path": "x.wav"}}]}',
+ '{"video_path": "clip.mp4"}',
+ "{'output_folder': 'x'}",
+ '{"model_root": "models"}',
+ '{"config_file": "a.yaml"}',
+ '{"url": "x"}',
+ '{"src": "x"}',
+ '{"FileName": "x"}',
+ ]:
+ self.assertEqual(vet_graph(g(node("CLIPTextEncode", text=v)), NODES, STAGED), "unsafe-path", v)
+ # The JSON Fuobe's own graphs send: a lean picture prompt, boxes, a plan, touches.
+ for v in [
+ '{"high_level_description": "a red door", "elements": [{"type": "photo", "desc": "x", "bbox": [0, 0, 1, 1]}], "color_palette": ["#fff"]}',
+ '{"coordinate_space": "pixels", "boxes": []}',
+ '{"shots": [{"id": "intro", "prompt": "Describe the opening"}]}',
+ '{"items": [{"op": "add", "x": 1, "y": 2, "t": 0}]}',
+ "Profile: a file of notes, a folder of pictures",
+ ]:
+ self.assertIsNone(vet_graph(g(node("CLIPTextEncode", text=v)), NODES, STAGED), v)
+
def test_nodes_that_read_or_fetch(self):
"""Nodes from common packs that read any folder, fetch a URL or write anywhere: refused by the list, and by the
path check when the person added them to their own list."""
@@ -112,7 +174,8 @@ class VetTest(unittest.TestCase):
self.assertIsNotNone(graph_problem(g(node("LoadImage", image="my_photo.png")), None))
def test_studio_workflows_pass(self):
- """Every workflow Fuobe ships uses only listed nodes and no path-like text (when the pack is inside Fuobe)."""
+ """Every workflow Fuobe ships passes every check once its loaders name the files the studio sends (when the
+ pack is inside Fuobe): only listed nodes, no path-like text, every rule above."""
folder = os.path.join(PACK, "..", "..", "workflows", "comfyui")
files = [f for f in glob.glob(os.path.join(folder, "*.json")) if os.path.basename(f) not in ("requirements.json", "manifest.json", "object_info.subset.json")]
if not files:
@@ -125,11 +188,168 @@ class VetTest(unittest.TestCase):
if not isinstance(wf, dict) or not all(isinstance(n, dict) and "class_type" in n for n in wf.values()):
continue
checked += 1
- # Their loaders still name placeholder files (the studio stages the real ones), so only these two reasons.
- self.assertNotIn(vet_graph(wf, nodes, None), ("unknown-node", "unsafe-path"), os.path.basename(f))
+ self.assertIsNone(vet_graph(staged_like_the_studio(wf), nodes, None), os.path.basename(f))
self.assertGreater(checked, 50)
+def staged_like_the_studio(wf: dict) -> dict:
+ """The workflow as the studio sends it: each loader's placeholder file becomes a Fuobe input name, and a 2K finish
+ loads its own draft's latent (src/lib/catalog/regenerate.ts latentFileFor)."""
+ wf = json.loads(json.dumps(wf))
+ count = [0]
+
+ def staged(v):
+ if not isinstance(v, str) or not v or staged_name_ok(v):
+ return v
+ count[0] += 1
+ ext = v.rsplit(".", 1)[1].lower() if "." in v else "png"
+ return f"fuobe_placeholder{count[0]:04d}.{ext}"
+
+ for n in wf.values():
+ inputs = n.get("inputs") or {}
+ for k in FILE_LOADERS.get(n["class_type"], []) + OPTIONAL_FILES.get(n["class_type"], []):
+ inputs[k] = staged(inputs.get(k))
+ if n["class_type"] == "OpenH3LoadRefinedLatent":
+ inputs["latent_file"] = "fuobe_h3_gen123abc_00001.safetensors"
+ if n["class_type"] == "Load3D" and isinstance(inputs.get("image"), dict):
+ for k, v in inputs["image"].items():
+ if k != "camera_info":
+ inputs["image"][k] = staged(v)
+ return wf
+
+
+SHIPPED = shipped_nodes()
+
+
+def vet1(cls, staged=STAGED, **inputs):
+ """One node of the shipped list, with these inputs."""
+ return vet_graph(g(node(cls, **inputs)), SHIPPED, staged)
+
+
+class NodeRulesTest(unittest.TestCase):
+ """Inputs that a listed node reads as a file or a folder take only Fuobe's own form, and never a link."""
+
+ def test_rules_name_shipped_nodes(self):
+ for table in (PATH_INPUTS, LINK_INPUTS, TEXT_INPUTS, OPTIONAL_FILES):
+ for cls in table:
+ self.assertIn(cls, SHIPPED, cls)
+ self.assertIn("Hi3DLoadMesh", FILE_LOADERS)
+
+ def test_subtitle_file(self):
+ """AILab_Qwen3ASRSubtitle writes its file at output_path (an absolute path as given)."""
+ for ok in ["", "fuobe/captions", "fuobe/gen123/captions"]:
+ self.assertIsNone(vet1("AILab_Qwen3ASRSubtitle", output_path=ok, audio=["9", 0]), ok)
+ for bad in [
+ "//?/C:/Users/Public/x.srt",
+ "//attacker.example/share/x.srt",
+ B + "Users" + B + "Public" + B + "x.srt",
+ B + "/attacker.example/share/x.srt",
+ "D:Users" + B + "x.srt",
+ "C:/Users/Public/x.srt",
+ "captions", # anywhere in your output folder
+ "fuobe/x.bat",
+ "fuobe/../x",
+ "fuobe",
+ ]:
+ self.assertEqual(vet1("AILab_Qwen3ASRSubtitle", output_path=bad, audio=["9", 0]), "unsafe-path", repr(bad))
+ # A path another node works out: never.
+ self.assertEqual(vet_graph(g(node("PrimitiveStringMultiline", value="fuobe/captions"), node("AILab_Qwen3ASRSubtitle", output_path=["1", 0])), SHIPPED, STAGED), "unsafe-path")
+
+ def test_source_timeline_reads_no_file(self):
+ """MiniMaxH3SourceTimeline opens any file at video_path / audio_path: Fuobe's graphs leave them empty."""
+ self.assertIsNone(vet1("MiniMaxH3SourceTimeline", video_path="", audio_path="", source_audio=["2", 0]))
+ for bad in [
+ B + "Users" + B + "me" + B + "Videos" + B + "private.mp4",
+ "//?/D:/private/voice.wav",
+ "ComfyUI/input/my_private.mp4", # relative to ComfyUI's working folder: your own files
+ "ComfyUI/output/ComfyUI_00001_.mp4",
+ "~admin/Videos/x.mp4",
+ "fuobe_abcdefgh12.png",
+ ]:
+ self.assertEqual(vet1("MiniMaxH3SourceTimeline", video_path=bad, audio_path=""), "unsafe-path", bad)
+ self.assertEqual(vet1("MiniMaxH3SourceTimeline", video_path="", audio_path=bad), "unsafe-path", bad)
+ self.assertEqual(vet_graph(g(node("StringConcatenate", string_a="C", string_b="x", delimiter=":"), node("MiniMaxH3SourceTimeline", video_path=["1", 0], audio_path="")), SHIPPED, STAGED), "unsafe-path")
+
+ def test_model_paths(self):
+ self.assertIsNone(vet1("AuKModelLoader", checkpoint_path="ckpts/AuK-Flash/auk_flash.safetensors", config_path="", qwen_path="ckpts/Qwen2.5-Omni-3B", device="cuda:0", dtype="bf16"))
+ self.assertIsNone(vet1("AuKModelLoader", checkpoint_path="ckpts/AuK/auk_base.safetensors", config_path="", qwen_path=""))
+ for bad in [
+ {"checkpoint_path": "ckpts/../x.safetensors"},
+ {"checkpoint_path": "ckpts/AuK/x.ckpt"},
+ {"checkpoint_path": "input/fuobe_abcdefgh12.safetensors"},
+ {"config_path": "ckpts/AuK/config.yaml"},
+ {"qwen_path": "models"},
+ {"qwen_path": "ckpts/.hidden"},
+ ]:
+ inputs = {"checkpoint_path": "ckpts/AuK/auk_base.safetensors", "config_path": "", "qwen_path": "", **bad}
+ self.assertEqual(vet1("AuKModelLoader", **inputs), "unsafe-path", bad)
+ self.assertIsNone(vet1("Hi3DModelLoader", model_root="", attention="sdpa"))
+ self.assertEqual(vet1("Hi3DModelLoader", model_root="models"), "unsafe-path")
+ self.assertIsNone(vet1("QWMRefineMask", sam_model="sam_vit_b_01ec64.pth", boxes_json=["2", 0]))
+ for bad in ["input/fuobe_vit_b_12345678.bin", "fuobe_vit_b_12345678.bin", "sam_vit_b.bin", "x/sam_vit_b_01ec64.pth"]:
+ self.assertEqual(vet1("QWMRefineMask", sam_model=bad), "unsafe-path", bad)
+ self.assertIsNone(vet1("ZenImage21AdapterLoader", model_folder="", adapter_file="models/text_encoders/adapter_v12.safetensors", text_encoder="Qwen/Qwen3.5-0.8B"))
+ self.assertIsNone(vet1("ZenImage21AdapterLoader", model_folder="", adapter_file="models/text_encoders/adapter_v12.safetensors", text_encoder="models/text_encoders/qwen3.5_0.8b"))
+ for bad in [{"model_folder": "models"}, {"adapter_file": "input/fuobe_abcdefgh12.bin"}, {"text_encoder": "someone/other-model"}, {"text_encoder": "models/text_encoders/../x"}]:
+ inputs = {"model_folder": "", "adapter_file": "models/text_encoders/adapter_v12.safetensors", "text_encoder": "Qwen/Qwen3.5-0.8B", **bad}
+ self.assertEqual(vet1("ZenImage21AdapterLoader", **inputs), "unsafe-path", bad)
+
+ def test_folders_a_node_writes(self):
+ self.assertIsNone(vet1("WanVideoImageToVideoMultiTalk", output_path="", mode="infinitetalk"))
+ self.assertEqual(vet1("WanVideoImageToVideoMultiTalk", output_path="frames"), "unsafe-path")
+ self.assertIsNone(vet1("OpenH3LoadRefinedLatent", latent_file="fuobe_h3_gen123abc_00001.safetensors"))
+ for bad in ["(newest)", "my_latent_00001.safetensors", "open_h3_regen_00001.safetensors"]:
+ self.assertEqual(vet1("OpenH3LoadRefinedLatent", latent_file=bad), "unsafe-path", bad)
+
+ def test_run_folder(self):
+ """A Context Loop run's folder under output/h3_chains: a Fuobe job's own, or a swap plan's."""
+ self.assertIsNone(vet1("MiniMaxH3ChainPlanModern", run_name="fuobe_abc123XYZ"))
+ self.assertIsNone(vet1("MiniMaxH3ChainPlanModern", run_name="fuobe_job-x"))
+ for bad in ["my_film", "fuobe_", "fuobe_a/b", "h3_chain"]:
+ self.assertEqual(vet1("MiniMaxH3ChainPlanModern", run_name=bad), "unsafe-path", bad)
+ plan = node("H3AdvancedSwapPlan", roles="")
+ self.assertIsNone(vet_graph(g(plan, node("MiniMaxH3ChainPlanModern", run_name=["1", 3])), SHIPPED, STAGED))
+ self.assertEqual(vet_graph(g(node("PrimitiveStringMultiline", value="my_film"), node("MiniMaxH3ChainPlanModern", run_name=["1", 0])), SHIPPED, STAGED), "unsafe-graph")
+
+ def test_optional_history_file(self):
+ self.assertIsNone(vet1("H3CharacterSwapShot", shot_id="character-swap"))
+ self.assertIsNone(vet1("H3CharacterSwapShot", history_file=""))
+ self.assertIsNone(vet1("H3CharacterSwapShot", history_file="fuobe_abcdefgh56.npz", staged=["fuobe_abcdefgh56.npz"]))
+ for bad in ["history.npz", "fuobe_zzzzzzzz99.npz", ["2", 0]]:
+ self.assertEqual(vet1("H3CharacterSwapShot", history_file=bad), "unsafe-graph", bad)
+
+ def test_mesh_loader(self):
+ self.assertIsNone(vet1("Hi3DLoadMesh", mesh_file="fuobe_abcdefgh34.glb", staged=["fuobe_abcdefgh34.glb"]))
+ for bad in ["coarse.glb", "hi3d/mine.glb", ["2", 0]]:
+ self.assertEqual(vet1("Hi3DLoadMesh", mesh_file=bad), "unsafe-graph", bad)
+
+ def test_json_objects(self):
+ """ComfyUI passes an object the graph writes to a node unchecked (a LoRA list, a model path, a {"__value__"})."""
+ for bad in [
+ node("WanVideoModelLoader", extra_model={"path": "models/x.safetensors"}),
+ node("WanVideoModelLoader", lora={"__value__": [{"path": "loras/x.safetensors", "strength": 1}]}),
+ node("WanVideoModelLoader", compile_args={"backend": "inductor"}),
+ node("SaveGLB", mesh={"path": "x.glb"}),
+ ]:
+ self.assertEqual(vet_graph(g(bad), SHIPPED, STAGED), "unsafe-graph", bad)
+ # A 3D view's entries are the one object a graph writes.
+ self.assertIsNone(vet1("Save3DAdvanced", viewport_state={"image": "", "mask": "", "normal": "", "camera_info": {"position": {"x": 1, "y": 2, "z": 3}, "zoom": 1}}))
+ self.assertEqual(vet1("Save3DAdvanced", viewport_state={"image": "C:/x.png"}), "unsafe-path")
+
+ def test_svg_comes_from_the_vectorizer(self):
+ vector = node("TS_ImageToSVGStringColor_Vtracer", image=["9", 0])
+ self.assertIsNone(vet_graph(g(vector, node("TS_SVGStringToSVGBytesIO", SVG_String=["1", 0])), SHIPPED, STAGED))
+ self.assertEqual(vet1("TS_SVGStringToSVGBytesIO", SVG_String="<svg onload='x()'/>"), "unsafe-graph")
+ self.assertEqual(vet_graph(g(node("StringConcatenate", string_a="<svg", string_b="></svg>", delimiter=""), node("TS_SVGStringToSVGBytesIO", SVG_String=["1", 0])), SHIPPED, STAGED), "unsafe-graph")
+
+ def test_format_reads_no_attribute(self):
+ """Python's format reaches a module's globals through an object: "{a.__init__.__globals__[os].environ}"."""
+ for ok in ["Dress {a} in image 1 in {b}. Keep the rest.", '{{"width": {a}, "height": {b}, "coords": "relative-1000"}}', "{a:.2f} and {b!r}", "{{a.b}}"]:
+ self.assertIsNone(vet1("StringFormat", f_string=ok), ok)
+ for bad in ["{a.__init__.__globals__[os].environ}", "{a[0]}", "x {b.real}", "{{{a.x}}}", "{a:{b.__class__}}", ["2", 0]]:
+ self.assertEqual(vet1("StringFormat", f_string=bad), "unsafe-path", bad)
+
+
class NodeListTest(unittest.TestCase):
def test_shipped_and_own(self):
shipped = shipped_nodes()
diff --git a/integrations/fuobe-connect/tests/test_middleware.py b/integrations/fuobe-connect/tests/test_middleware.py
index 6dfb733c..9e0a564a 100644
--- a/integrations/fuobe-connect/tests/test_middleware.py
+++ b/integrations/fuobe-connect/tests/test_middleware.py
@@ -140,6 +140,13 @@ class OriginsTest(unittest.TestCase):
for m, p, q in [("GET", "/userdata/comfy.settings.json", ""), ("POST", "/v2/manager/queue/install", ""), ("POST", "/fuobe/connect/studios", ""), ("POST", "/fuobe/connect/pair", ""), ("DELETE", "/prompt", ""), ("GET", "/internal/logs", ""), ("GET", "/history", ""), ("GET", "/history", "max_items=64&offset=0"), ("GET", "/history/not-a-uuid", "")]:
self.assertFalse(allowed(m, p, q), p)
+ def test_model_lists_only(self):
+ # A model folder's list, yes; ComfyUI's lists of every node pack's files and of its configs, no.
+ for p in ["/models", "/models/loras", "/api/models/checkpoints", "/experiment/models", "/experiment/models/loras", "/models/custom_nodes_extra"]:
+ self.assertTrue(allowed("GET", p), p)
+ for p in ["/models/custom_nodes", "/api/models/custom_nodes", "/models/configs", "/experiment/models/custom_nodes", "/api/experiment/models/configs"]:
+ self.assertFalse(allowed("GET", p), p)
+
def test_paths_match_whole(self):
# Python's "$" also matches before a final newline: the lists match the whole path.
self.assertFalse(allowed("GET", "/system_stats\n"))
@@ -229,6 +236,12 @@ class DirectModeTest(unittest.TestCase):
"a node this pack doesn't ship": graph(**{"10": {"class_type": "Image Load", "inputs": {"image_path": "C:/Users/me/secret.png"}}}),
"an absolute path": graph(**{"10": {"class_type": "SaveImage", "inputs": {"filename_prefix": "/etc/cron.d/x", "images": ["8", 0]}}}),
"a Windows path": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "C:\\Users\\me\\x.png", "clip": ["4", 1]}}}),
+ "a share with forward slashes": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "//attacker.example/share/x", "clip": ["4", 1]}}}),
+ "a device path": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "//?/C:/Users/Public/x", "clip": ["4", 1]}}}),
+ "the drive's root": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "\\Users\\Public\\x", "clip": ["4", 1]}}}),
+ "a drive with no slash": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "D:Users\\x", "clip": ["4", 1]}}}),
+ "another account's home": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "~admin/x", "clip": ["4", 1]}}}),
+ "a JSON object": graph(**{"10": {"class_type": "SaveImage", "inputs": {"filename_prefix": {"__value__": ["x"]}, "images": ["8", 0]}}}),
"a URL": graph(**{"6": {"class_type": "CLIPTextEncode", "inputs": {"text": "http://192.168.1.1/admin", "clip": ["4", 1]}}}),
"a .. step": graph(**{"10": {"class_type": "SaveImage", "inputs": {"filename_prefix": "../../startup", "images": ["8", 0]}}}),
"a file of yours": graph(**{"10": {"class_type": "LoadImage", "inputs": {"image": "holiday.png"}}}),
diff --git a/integrations/fuobe-connect/tests/test_runner.py b/integrations/fuobe-connect/tests/test_runner.py
index 4cf7caaf..e5f8a11c 100644
--- a/integrations/fuobe-connect/tests/test_runner.py
+++ b/integrations/fuobe-connect/tests/test_runner.py
@@ -17,7 +17,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from fuobe_connect.net import Answer, TooBig # noqa: E402
from fuobe_connect.runner import SEND_TRIES, Runner, Stopped # noqa: E402
-NODES = frozenset({"LoadImage", "SaveImage", "CLIPTextEncode"})
+NODES = frozenset({"LoadImage", "SaveImage", "CLIPTextEncode", "AILab_Qwen3ASRSubtitle", "MiniMaxH3SourceTimeline", "WanVideoModelLoader"})
DATA = b"picture"
SHA = hashlib.sha256(DATA).hexdigest()
LEASE = "a" * 64
@@ -134,6 +134,10 @@ class VetTest(unittest.TestCase):
self.refused(task(graph={"1": {"class_type": "KJ_RunPython", "inputs": {"code": "x"}}}), "unknown-node")
self.refused(task(graph={"1": {"class_type": "CLIPTextEncode", "inputs": {"text": "C:/Users/me/x.png"}}}), "unsafe-path")
self.refused(task(graph={"1": {"class_type": "LoadImage", "inputs": {"image": "my_photo.png"}}}), "unsafe-graph")
+ # A node that writes or reads a file at a path it is given: only Fuobe's own form, in pairing mode too.
+ self.refused(task(graph={"1": {"class_type": "AILab_Qwen3ASRSubtitle", "inputs": {"output_path": "//?/C:/Users/Public/x.srt", "output_format": "srt"}}}), "unsafe-path")
+ self.refused(task(graph={"1": {"class_type": "MiniMaxH3SourceTimeline", "inputs": {"video_path": "ComfyUI/input/private.mp4", "audio_path": ""}}}), "unsafe-path")
+ self.refused(task(graph={"1": {"class_type": "WanVideoModelLoader", "inputs": {"extra_model": {"path": "x.safetensors"}}}}), "unsafe-graph")
# The studio's input names: only Fuobe's own, each once, with a file type a run sends.
for name in ["my_photo.png", "fuobe_abcdefgh12.html", "ComfyUI_00001_.png [output]"]:
t = task()