Skip to content

Commit

Permalink
Sanitize unknown node types on load to prevent XSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Nov 5, 2023
1 parent 1ffa885 commit 02f062b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions web/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 02f062b

Please sign in to comment.