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): keep one-time secrets out of session replays (#15022)

Krzysztof Czerwinskid46580eaf457
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/legacy-builder/agent-run-draft-view.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/legacy-builder/agent-run-draft-view.tsx
index c4bf2a746e..bebd8006d6 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/legacy-builder/agent-run-draft-view.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/legacy-builder/agent-run-draft-view.tsx
@@ -656,7 +656,7 @@ export function AgentRunDraftView({
<div className="nodrag mt-5 flex flex-col gap-1">
Webhook URL:
<div className="flex gap-2 rounded-md bg-gray-50 p-2">
- <code className="select-all text-sm">
+ <code className="ph-no-capture select-all text-sm">
{agentPreset.webhook.url}
</code>
<Button
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/InfoCards.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/InfoCards.tsx
index 140db56d36..1d95b68dbf 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/InfoCards.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/InfoCards.tsx
@@ -257,7 +257,7 @@ export function TriggerSetupCard({ output }: OutputProps) {
</p>
{url && (
<div className="flex items-center gap-2 rounded-lg bg-zinc-50 p-2 ring-1 ring-zinc-200/70">
- <code className="min-w-0 flex-1 break-all text-xs text-zinc-600">
+ <code className="ph-no-capture min-w-0 flex-1 break-all text-xs text-zinc-600">
{url}
</code>
<button
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ResultCards.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ResultCards.tsx
index 6f5f7e1bd1..52a604971a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ResultCards.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ResultCards.tsx
@@ -35,6 +35,7 @@ interface LinkCardProps {
url: string;
title?: string;
meta?: string;
+ secret?: boolean;
}
export const CARD = "rounded-xl bg-white ring-1 ring-zinc-200/70";
@@ -122,11 +123,18 @@ export function ChipList({ label, items }: ChipListProps) {
);
}
-export function LinkCard({ url, title, meta }: LinkCardProps) {
+export function LinkCard({ url, title, meta, secret }: LinkCardProps) {
const domain = safeHostname(url) ?? url;
return (
- <div className={`${CARD} ${HALF} flex items-center gap-2.5 p-2.5`}>
+ <div
+ className={cn(
+ CARD,
+ HALF,
+ "flex items-center gap-2.5 p-2.5",
+ secret && "ph-no-capture",
+ )}
+ >
<div className="flex size-7 shrink-0 items-center justify-center rounded-full bg-zinc-100">
<Icon icon={GlobeIcon} size={15} className="shrink-0 text-zinc-400" />
</div>
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx
index 9291531229..fffd085bea 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/ToolResult.tsx
@@ -54,6 +54,7 @@ import {
asObject,
dictToOutputItems,
humanizeKey,
+ isWebhookIngressUrl,
str,
stripBaseFields,
} from "./resultHelpers";
@@ -139,6 +140,10 @@ function linkCard(
url={url}
title={str(output, "title", "issue_title") ?? undefined}
meta={meta}
+ secret={
+ isWebhookIngressUrl(url) ||
+ url === str(output, "webhook_url", "ingress_url")
+ }
/>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolResult.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolResult.test.tsx
index d8f6155995..f393233c06 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolResult.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/ToolResult.test.tsx
@@ -872,6 +872,46 @@ describe("ToolResult", () => {
expect(screen.getByLabelText("Open link").getAttribute("href")).toBe(
"https://example.com/page",
);
+ expect(
+ screen.getByLabelText("Open link").closest(".ph-no-capture"),
+ ).toBeNull();
+ });
+
+ it("keeps an update_preset webhook URL out of session replays", () => {
+ const url =
+ "https://backend.agpt.co/api/integrations/generic_webhook/webhooks/wh-1/ingress";
+ render(
+ <ToolResult
+ row={row(
+ {
+ type: "preset_updated",
+ message: "Preset updated",
+ preset_id: "p1",
+ name: "My Trigger",
+ is_active: true,
+ webhook_url: url,
+ },
+ "update_preset",
+ )}
+ />,
+ );
+
+ expect(screen.getByText(url).closest(".ph-no-capture")).not.toBeNull();
+ expect(
+ screen.getByLabelText("Open link").closest(".ph-no-capture"),
+ ).not.toBeNull();
+ });
+
+ it("blocks a webhook_url link card even off the ingress path", () => {
+ render(
+ <ToolResult
+ row={row({ webhook_url: "https://hooks.example.com/h1" })}
+ />,
+ );
+
+ expect(
+ screen.getByLabelText("Open link").closest(".ph-no-capture"),
+ ).not.toBeNull();
});
it("renders a size for link outputs reporting bytes", () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/resultHelpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/resultHelpers.test.ts
index 550c3de046..b9c6e3acfb 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/resultHelpers.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/__tests__/resultHelpers.test.ts
@@ -8,6 +8,7 @@ import {
humanizeKey,
inline,
integrationIconSrc,
+ isWebhookIngressUrl,
resultItemKey,
safeHostname,
str,
@@ -183,3 +184,22 @@ describe("result formatting", () => {
expect(inline(false)).toBe("false");
});
});
+
+describe("isWebhookIngressUrl", () => {
+ it("matches backend webhook ingress URLs", () => {
+ expect(
+ isWebhookIngressUrl(
+ "https://backend.agpt.co/api/integrations/generic_webhook/webhooks/wh-1/ingress",
+ ),
+ ).toBe(true);
+ });
+
+ it("ignores ordinary links", () => {
+ expect(isWebhookIngressUrl("https://example.com/webhooks/docs")).toBe(
+ false,
+ );
+ expect(
+ isWebhookIngressUrl("https://example.com/webhooks/wh-1/ingress-guide"),
+ ).toBe(false);
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/resultHelpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/resultHelpers.ts
index 9c34015710..b0869e7e51 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/resultHelpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolChain/resultHelpers.ts
@@ -16,6 +16,12 @@ export function asObject(value: unknown): Record<string, unknown> | null {
: null;
}
+// Anyone holding a webhook ingress URL can trigger the agent unless the
+// trigger sets a secret_token, so it is treated as a credential.
+export function isWebhookIngressUrl(url: string): boolean {
+ return /\/webhooks\/[^/?#]+\/ingress(?:[/?#]|$)/.test(url);
+}
+
export function safeHostname(url: string): string | null {
try {
return new URL(url).hostname.replace(/^www\./, "");
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/SetupTrigger.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/SetupTrigger.tsx
index 24fc6875fe..7a7996cce0 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/SetupTrigger.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/SetupTrigger.tsx
@@ -121,7 +121,7 @@ function TriggerSetupSuccessCard({ output }: { output: TriggerSetupOutput }) {
<ContentMessage>{output.message}</ContentMessage>
{output.manual_setup_required && output.webhook_url && (
<div className="flex items-center gap-2 rounded-xl border bg-muted/40 p-2">
- <code className="min-w-0 flex-1 break-all text-xs">
+ <code className="ph-no-capture min-w-0 flex-1 break-all text-xs">
{output.webhook_url}
</code>
<Button
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/__tests__/SetupTrigger.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/__tests__/SetupTrigger.test.tsx
index c3c6c045c4..42471841d5 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/__tests__/SetupTrigger.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/SetupTrigger/__tests__/SetupTrigger.test.tsx
@@ -105,7 +105,7 @@ describe("SetupTriggerTool", () => {
/>,
);
expect(screen.getByText("Webhook trigger ready.")).toBeDefined();
- expect(screen.getByText(url)).toBeDefined();
+ expect(screen.getByText(url).closest(".ph-no-capture")).not.toBeNull();
expect(screen.getByLabelText("Copy webhook URL")).toBeDefined();
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/WebhookTriggerSection.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/WebhookTriggerSection.tsx
index acbfefb4fc..b43f2e9cf0 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/WebhookTriggerSection.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/WebhookTriggerSection.tsx
@@ -66,7 +66,9 @@ export function WebhookTriggerSection({ preset, triggerSetupInfo }: Props) {
<div className="flex flex-col gap-1">
<Text variant="small-medium">Webhook URL:</Text>
<div className="flex gap-2 rounded-md bg-gray-50 p-2">
- <code className="flex-1 select-all text-sm">{webhook.url}</code>
+ <code className="ph-no-capture flex-1 select-all text-sm">
+ {webhook.url}
+ </code>
<Button
variant="outline"
size="icon"
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedTemplateView/components/WebhookTriggerCard.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedTemplateView/components/WebhookTriggerCard.tsx
index 4cfa0393e2..b63e0b6b72 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedTemplateView/components/WebhookTriggerCard.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedTemplateView/components/WebhookTriggerCard.tsx
@@ -66,7 +66,9 @@ export function WebhookTriggerCard({ template, triggerSetupInfo }: Props) {
<div className="flex flex-col gap-1">
<Text variant="body-medium">Webhook URL:</Text>
<div className="flex gap-2 rounded-md bg-gray-50 p-2">
- <code className="flex-1 select-all text-sm">{webhook.url}</code>
+ <code className="ph-no-capture flex-1 select-all text-sm">
+ {webhook.url}
+ </code>
<Button
variant="outline"
size="icon"
diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/__tests__/page.test.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/__tests__/page.test.tsx
index 404957e4c0..f9d8c2b139 100644
--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/__tests__/page.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/__tests__/page.test.tsx
@@ -111,6 +111,9 @@ describe("ApiKeysPage", () => {
await waitFor(() => {
expect(apiKeys[0]?.name).toBe("CLI Key");
});
+ expect(
+ screen.getByText("plain-text-key").closest(".ph-no-capture"),
+ ).not.toBeNull();
});
test("revokes an existing API key", async () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/components/APIKeysModals/APIKeysModals.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/components/APIKeysModals/APIKeysModals.tsx
index 878f32f61e..60cc5dd1a7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/components/APIKeysModals/APIKeysModals.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/api-keys/components/APIKeysModals/APIKeysModals.tsx
@@ -116,7 +116,7 @@ export const APIKeysModals = () => {
</DialogDescription>
</DialogHeader>
<div className="flex items-center space-x-2">
- <code className="flex-1 rounded-md bg-secondary p-2 text-sm">
+ <code className="ph-no-capture flex-1 rounded-md bg-secondary p-2 text-sm">
{keyState.newApiKey}
</code>
<Button size="icon" variant="outline" onClick={handleCopyKey}>
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsx
index 03c0fa60c1..2e7d44f52a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsx
@@ -332,6 +332,12 @@ describe("SettingsApiKeysPage - create flow", () => {
});
});
+ test("keeps the plaintext key out of session replays", async () => {
+ await submitUntilSuccessView();
+
+ expect(screen.getByText(plain).closest(".ph-no-capture")).not.toBeNull();
+ });
+
test("shows a destructive toast when the clipboard write fails", async () => {
writeTextSpy = vi.fn().mockRejectedValue(new Error("denied"));
installClipboard(writeTextSpy);
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsx
index 12b78c8c72..9ef528c81a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsx
@@ -31,7 +31,8 @@ export function CreateAPIKeySuccess({ plainTextKey, onClose }: Props) {
</Text>
<div className="flex items-center gap-2 rounded-md border border-zinc-200 bg-zinc-50 p-3">
- <code className="flex-1 break-all font-mono text-xs text-zinc-800">
+ {/* ph-no-capture keeps the one-time key out of PostHog session replays. */}
+ <code className="ph-no-capture flex-1 break-all font-mono text-xs text-zinc-800">
{plainTextKey}
</code>
<Button
diff --git a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx
index bf274886e0..64c2587d9c 100644
--- a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx
@@ -67,13 +67,14 @@ export function DeviceAuthConnectButton({
account.
</Text>
- <div className="flex flex-col gap-3 rounded-lg border border-zinc-200 bg-zinc-50 p-4">
+ {/* The code is a live authorization code and the link's href can carry
+ it too (verification_uri_complete), so PostHog skips the whole panel
+ and Sentry masks the code (unmask={false}). */}
+ <div className="ph-no-capture flex flex-col gap-3 rounded-lg border border-zinc-200 bg-zinc-50 p-4">
<div className="flex flex-col gap-1">
<Text variant="small" className="font-medium text-zinc-500">
Your code
</Text>
- {/* unmask={false}: Text unmasks for session replay by default, and
- this is a live authorization code — it must not be recorded. */}
<Text
variant="h3"
as="p"
diff --git a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx
index 49c2d79ba3..fb4b4406bd 100644
--- a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx
@@ -50,10 +50,16 @@ describe("DeviceAuthConnectButton", () => {
// code, so it must not be recorded. Regression test for that default.
state.phase = "polling";
state.userCode = "glow-relish-chaste-soft";
+ state.verificationUrl =
+ "https://app.link.com/device/setup?user_code=glow-relish-chaste-soft";
renderButton();
const code = screen.getByText("glow-relish-chaste-soft");
expect(code.className).not.toContain("sentry-unmask");
+ const blocked = code.closest(".ph-no-capture");
+ expect(blocked).not.toBeNull();
+ // verification_uri_complete carries the code in the link's href.
+ expect(blocked?.contains(screen.getByRole("link"))).toBe(true);
});
// Between clicking Connect and the initiate call returning there is no code