Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Sanitize unknown node types on load to prevent XSS.

comfyanonymous02f062b5b7d8
diff --git a/web/scripts/app.js b/web/scripts/app.js
index 583310a27..638afd56c 100644
--- a/web/scripts/app.js
+++ b/web/scripts/app.js
@@ -5,6 +5,22 @@ import { api } from "./api.js";
import { defaultGraph } from "./defaultGraph.js";
import { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo.js";
+
+function sanitizeNodeName(string) {
+ let entityMap = {
+ '&': '',
+ '<': '',
+ '>': '',
+ '"': '',
+ "'": '',
+ '`': '',
+ '=': ''
+ };
+ return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
+ return entityMap[s];
+ });
+}
+
/**
* @typedef {import("types/comfy").ComfyExtension} ComfyExtension
*/
@@ -1480,6 +1496,7 @@ export class ComfyApp {
// Find missing node types
if (!(n.type in LiteGraph.registered_node_types)) {
+ n.type = sanitizeNodeName(n.type);
missingNodeTypes.push(n.type);
}
}