Skip to content

fix: OpenNode callback accepts unauthenticated requests - #454

Merged
cameri merged 14 commits into
cameri:mainfrom
Anshumancanrock:fix/opennode-webhook-validation
Apr 18, 2026
Merged

fix: OpenNode callback accepts unauthenticated requests#454
cameri merged 14 commits into
cameri:mainfrom
Anshumancanrock:fix/opennode-webhook-validation

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Description

Two bugs in the OpenNode callback handler

  1. No signature verification. The controller accepted any request unconditionally. An attacker could POST to /callbacks/opennode and flip an invoice's status to COMPLETED in the database.

  2. Body was never parsed. OpenNode sends application/x-www-form-urlencoded payloads, but the route only registered json() middleware. So request.body was always {} , the handler was running on empty input every time.

This PR fixes both.

Closes#453

Testing

Added unit tests covering:

  • wrong processor will throw 403
  • missing/malformed body fields will thow 400
  • invalid signature will thow 403
  • valid signed request = invoice processed

And a route-level test confirming the form-encoded body is actually parsed before hitting the controller.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the code style of this project.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes the OpenNode webhook callback so it correctly parses OpenNode’s form-encoded payloads and rejects unauthenticated/forged requests.

Changes:

  • Adds urlencoded() middleware to /callbacks/opennode so application/x-www-form-urlencoded bodies are parsed.
  • Implements OpenNode webhook authentication by verifying hashed_order against an HMAC of the invoice/charge id.
  • Adds unit tests for OpenNode callback controller authorization/validation, plus a parsing-focused route test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

FileDescription
test/unit/routes/callbacks.spec.tsAdds a test intended to verify form-urlencoded bodies are parsed.
test/unit/controllers/callbacks/opennode-callback-controller.spec.tsAdds unit coverage for OpenNode callback validation and processing.
src/routes/callbacks/index.tsUpdates the OpenNode callback route to include urlencoded() parsing.
src/controllers/callbacks/opennode-callback-controller.tsAdds payment-processor gating and HMAC signature verification for OpenNode callbacks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated
Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts
Comment threadtest/unit/routes/callbacks.spec.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated
Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts
Comment threadtest/unit/controllers/callbacks/opennode-callback-controller.spec.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated
Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts
Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated
Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Anshumancanrock

Copy link
Copy Markdown
CollaboratorAuthor

hi @cameri , could you please review this PR? Thank you !

@cameri

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

Anshumancanrockand others added 2 commits April 18, 2026 18:31
…ennode-webhook-validation
# Conflicts:
#	src/controllers/callbacks/opennode-callback-controller.ts
@camericameri self-assigned this Apr 18, 2026
@Anshumancanrock

Copy link
Copy Markdown
CollaboratorAuthor

hii @cameri , I’ve resolved the merge conflicts. Please take another look when you get a chance.

Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated
Comment threadsrc/controllers/callbacks/opennode-callback-controller.ts Outdated
@cameri

Copy link
Copy Markdown
Owner

@Anshumancanrock some conflicts maybe with the other PR

@coveralls

coveralls commented Apr 18, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 65.929%Anshumancanrock:fix/opennode-webhook-validation into cameri:main. No base build found for cameri:main.

@cameri
cameri merged commit c9c1fda into cameri:mainApr 18, 2026
12 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] OpenNode callback accepts unauthenticated requests and never parses the webhook body

4 participants

@Anshumancanrock@cameri@coveralls