Skip to content

fix: blacklist transaction sort fields from query parameters - #1135

Merged
Klakurka merged 1 commit into
masterfrom
cursor/fix-orderby-type-confusion-2e84
Oct 1, 2026
Merged

Klakurka merged 1 commit into
masterfrom
cursor/fix-orderby-type-confusion-2e84

Conversation

@Klakurka

@Klakurka Klakurka commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Related to https://github.com/PayButton/paybutton-server/security/code-scanning/3
Related to https://github.com/PayButton/paybutton-server/security/code-scanning/6
Related to https://github.com/PayButton/paybutton-server/security/code-scanning/7
Related to https://github.com/PayButton/paybutton-server/security/code-scanning/8

Description

CodeQL js/type-confusion-through-parameter-tampering flagged orderBy on the paybutton and address transaction lists. A repeated query key is an array, and includes() then checks membership instead of a substring before the value is used as a Prisma sort key.

Sort fields are now an explicit blacklist. Unknown values, including arrays, sort by timestamp. Payment sorting uses the same approach for values, networkId, and the other payment columns.

The GitHub token for this run cannot read code-scanning alert bodies, so this is one of the fixes from a local CodeQL code-scanning run of the same default query suite.

Test plan

  • npx ts-node -O '{"module":"commonjs"}' node_modules/jest/bin/jest.js tests/unittests/transactionService.test.ts --forceExit
  • Confirmed blacklist sorts (address.networkId, values, networkId) and that __proto__, constructor, and array orderBy fall back to timestamp.
  • Re-ran the CodeQL query; this finding is gone.
Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: a64f8902-8554-4496-8df6-45d8278f3d55

📥 Commits

Reviewing files that changed from the base of the PR and between 525622e and fc9b16d.

📒 Files selected for processing (2)
  • services/transactionService.ts
  • tests/unittests/transactionService.test.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor cursor Bot changed the title fix: allowlist transaction sort fields from query parameters fix: blacklist transaction sort fields from query parameters Oct 1, 2026
Repeated orderBy query keys are arrays, and string checks such as includes()
do not mean the same thing for arrays as they do for strings. Sort fields are
now matched explicitly, and unknown values fall back to timestamp.

Co-authored-by: David <Klakurka@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/fix-orderby-type-confusion-2e84 branch from 93a36d6 to fc9b16d Compare October 1, 2026 17:05
@Klakurka Klakurka self-assigned this Oct 1, 2026
@Klakurka Klakurka added the bug Something isn't working label Oct 1, 2026
@Klakurka Klakurka added this to the Phase 3 milestone Oct 1, 2026
@Klakurka
Klakurka requested a balanced review from Copilot October 1, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The static sort mappings address the type-confusion risk while preserving supported sorting behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Replaces dynamic Prisma transaction sorting with safe, explicit field mappings.

Changes:

  • Adds transaction and payment sort-field allowlists with timestamp fallback.
  • Handles repeated query parameters safely.
  • Adds tests for valid, unknown, and array sort values.
File Description
services/​transactionService.ts Safely maps transaction and payment sorting fields.
tests/​unittests/​transactionService.test.ts Tests supported fields and secure fallbacks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Klakurka
Klakurka marked this pull request as ready for review October 1, 2026 17:17
@Klakurka
Klakurka merged commit 9d6f605 into master Oct 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants