Skip to content

Conversation

@ShireenMissi
Copy link
Contributor

Summary

This PR implements proper Stripe webhook signature verification by validating the Stripe-Signature
header against the webhook secret using HMAC-SHA256. This ensures webhook authenticity and follows
Stripe's recommended verification process for incoming webhook events.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-4018/missing-stripe-signature-verification

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@ShireenMissi ShireenMissi marked this pull request as draft December 4, 2025 16:43
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team node/improvement New feature or request labels Dec 4, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 2 files

Prompt for AI agents (all 4 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts">

<violation number="1" location="packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts:952">
P1: Rule violated: **Tests**

Add workflow or unit tests that cover both valid and invalid Stripe webhook signatures for the newly added verification logic to comply with the Community PR Guidelines testing requirement.</violation>

<violation number="2" location="packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts:955">
P1: Rule violated: **Prefer Typeguards over Type casting**

Avoid narrowing the Stripe signature header with `as`; validate the value with a type guard before using it to satisfy the “Prefer Typeguards over Type casting” rule.</violation>

<violation number="3" location="packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts:960">
P1: Rule violated: **Prefer Typeguards over Type casting**

Replace this `as` cast on the stored webhook secret with an explicit type guard so the secret is only treated as a string when it actually is one, per the “Prefer Typeguards over Type casting” rule.</violation>

<violation number="4" location="packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts:991">
P1: Rule violated: **Prefer Typeguards over Type casting**

Do not cast the `events` parameter to `string[]` with `as`; narrow it using a runtime guard (e.g., check that the parameter is an array of strings) to comply with the “Prefer Typeguards over Type casting” rule.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

return {};
}

const events = this.getNodeParameter('events', []) as string[];
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Rule violated: Prefer Typeguards over Type casting

Do not cast the events parameter to string[] with as; narrow it using a runtime guard (e.g., check that the parameter is an array of strings) to comply with the “Prefer Typeguards over Type casting” rule.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts, line 991:

<comment>Do not cast the `events` parameter to `string[]` with `as`; narrow it using a runtime guard (e.g., check that the parameter is an array of strings) to comply with the “Prefer Typeguards over Type casting” rule.</comment>

<file context>
@@ -948,9 +949,46 @@ export class StripeTrigger implements INodeType {
+			return {};
+		}
+
+		const events = this.getNodeParameter(&#39;events&#39;, []) as string[];
 		const eventType = bodyData.type as string | undefined;
 
</file context>
Fix with Cubic

return {};
}

const webhookSecret = webhookData.webhookSecret as string | undefined;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Rule violated: Prefer Typeguards over Type casting

Replace this as cast on the stored webhook secret with an explicit type guard so the secret is only treated as a string when it actually is one, per the “Prefer Typeguards over Type casting” rule.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts, line 960:

<comment>Replace this `as` cast on the stored webhook secret with an explicit type guard so the secret is only treated as a string when it actually is one, per the “Prefer Typeguards over Type casting” rule.</comment>

<file context>
@@ -948,9 +949,46 @@ export class StripeTrigger implements INodeType {
+			return {};
+		}
+
+		const webhookSecret = webhookData.webhookSecret as string | undefined;
+		if (!webhookSecret) {
+			return {};
</file context>
Fix with Cubic

const webhookData = this.getWorkflowStaticData('node');

const events = this.getNodeParameter('events', []) as string[];
const stripeSignature = headerData['stripe-signature'] as string | undefined;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Rule violated: Prefer Typeguards over Type casting

Avoid narrowing the Stripe signature header with as; validate the value with a type guard before using it to satisfy the “Prefer Typeguards over Type casting” rule.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts, line 955:

<comment>Avoid narrowing the Stripe signature header with `as`; validate the value with a type guard before using it to satisfy the “Prefer Typeguards over Type casting” rule.</comment>

<file context>
@@ -948,9 +949,46 @@ export class StripeTrigger implements INodeType {
+		const webhookData = this.getWorkflowStaticData(&#39;node&#39;);
 
-		const events = this.getNodeParameter(&#39;events&#39;, []) as string[];
+		const stripeSignature = headerData[&#39;stripe-signature&#39;] as string | undefined;
+		if (!stripeSignature) {
+			return {};
</file context>
Fix with Cubic

async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData();
const req = this.getRequestObject();
const headerData = this.getHeaderData();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Rule violated: Tests

Add workflow or unit tests that cover both valid and invalid Stripe webhook signatures for the newly added verification logic to comply with the Community PR Guidelines testing requirement.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts, line 952:

<comment>Add workflow or unit tests that cover both valid and invalid Stripe webhook signatures for the newly added verification logic to comply with the Community PR Guidelines testing requirement.</comment>

<file context>
@@ -948,9 +949,46 @@ export class StripeTrigger implements INodeType {
 	async webhook(this: IWebhookFunctions): Promise&lt;IWebhookResponseData&gt; {
 		const bodyData = this.getBodyData();
 		const req = this.getRequestObject();
+		const headerData = this.getHeaderData();
+		const webhookData = this.getWorkflowStaticData(&#39;node&#39;);
 
</file context>
Fix with Cubic

@currents-bot
Copy link

currents-bot bot commented Dec 4, 2025

E2E Tests: n8n tests failed after 10m 21.6s

🟢 598 · 🔴 1 · ⚪️ 39 · 🟣 2

View Run Details

Run Details

  • Project: n8n

  • Groups: 2

  • Framework: Playwright

  • Run Status: Failed

  • Commit: cd36b6d

  • Spec files: 108

  • Overall tests: 638

  • Duration: 10m 21.6s

  • Parallelization: 9

Failed Spec Files

Spec File Failures
tests/ui/7-workflow-actions.spec.ts 1

Groups

GroupId Results Spec Files Progress
multi-main:ui:isolated 🟢 54 · 🔴 0 · ⚪️ 0 8 / 8
multi-main:ui 🟢 544 · 🔴 1 · ⚪️ 39 · 🟣 2 100 / 100


This message was posted automatically by currents.dev | Integration Settings

@blacksmith-sh
Copy link

blacksmith-sh bot commented Dec 4, 2025

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
tests/ui/7-workflow-actions.spec.ts/
Workflow Actions › should be able to publish workflow when nodes with errors are disabl
ed
View Logs

Fix in Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team node/improvement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants