Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): block prototype-polluting keys without schema + validate execution_id

Zamil Majdyca1577f3b1e7
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts
index dc7b9cba37..783f42930d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts
@@ -1409,3 +1409,62 @@ describe("useBuilderChatPanel – tool call detection", () => {
expect(onGraphEdited).toHaveBeenCalledOnce();
});
});
+
+describe("useBuilderChatPanel – prototype pollution blocklist (no-schema nodes)", () => {
+ it("rejects __proto__ even when node has no inputSchema", () => {
+ mockNodes.push({ id: "n-schema-less", data: { hardcodedValues: {} } });
+ const { result } = renderHook(() => useBuilderChatPanel());
+
+ act(() => {
+ result.current.handleApplyAction({
+ type: "update_node_input",
+ nodeId: "n-schema-less",
+ key: "__proto__",
+ value: "injected",
+ });
+ });
+
+ expect(mockSetNodes).not.toHaveBeenCalled();
+ expect(mockToast).toHaveBeenCalledWith(
+ expect.objectContaining({ variant: "destructive" }),
+ );
+ });
+
+ it("rejects constructor even when node has no inputSchema", () => {
+ mockNodes.push({ id: "n-ctor-no-schema", data: { hardcodedValues: {} } });
+ const { result } = renderHook(() => useBuilderChatPanel());
+
+ act(() => {
+ result.current.handleApplyAction({
+ type: "update_node_input",
+ nodeId: "n-ctor-no-schema",
+ key: "constructor",
+ value: "injected",
+ });
+ });
+
+ expect(mockSetNodes).not.toHaveBeenCalled();
+ expect(mockToast).toHaveBeenCalledWith(
+ expect.objectContaining({ variant: "destructive" }),
+ );
+ });
+
+ it("rejects prototype even when node has no inputSchema", () => {
+ mockNodes.push({ id: "n-proto-no-schema", data: { hardcodedValues: {} } });
+ const { result } = renderHook(() => useBuilderChatPanel());
+
+ act(() => {
+ result.current.handleApplyAction({
+ type: "update_node_input",
+ nodeId: "n-proto-no-schema",
+ key: "prototype",
+ value: "injected",
+ });
+ });
+
+ expect(mockSetNodes).not.toHaveBeenCalled();
+ expect(mockToast).toHaveBeenCalledWith(
+ expect.objectContaining({ variant: "destructive" }),
+ );
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
index d7685d5237..c5c2cdd320 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
@@ -282,7 +282,7 @@ export function useBuilderChatPanel({
} else if (dynPart.toolName === "run_agent") {
const output = dynPart.output as Record<string, unknown> | null;
const execId = output?.execution_id;
- if (typeof execId === "string" && execId) {
+ if (typeof execId === "string" && /^[\w-]+$/i.test(execId)) {
setQueryStates({ flowExecutionID: execId });
}
}
@@ -354,6 +354,18 @@ export function useBuilderChatPanel({
});
return;
}
+ // Block prototype-polluting keys regardless of schema presence.
+ // The schema check below uses hasOwnProperty so __proto__ is caught when
+ // schemaProps exists, but this guard handles the no-schema case.
+ const DANGEROUS_KEYS = ["__proto__", "constructor", "prototype"];
+ if (DANGEROUS_KEYS.includes(action.key)) {
+ toast({
+ title: "Cannot apply change",
+ description: `Field "${action.key}" is not a valid input.`,
+ variant: "destructive",
+ });
+ return;
+ }
// Reject keys not present in the node's input schema to prevent writing
// arbitrary fields that the block does not support.
const schemaProps = node.data.inputSchema?.properties;