Skip to content

fix: reject array address query parameters - #1137

Open
Klakurka wants to merge 3 commits into
masterfrom
cursor/fix-address-query-type-confusion-2e84
Open

Klakurka wants to merge 3 commits into
masterfrom
cursor/fix-address-query-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 parseAddress. The address routes pass req.query.address through, and a repeated address query key is an array. includes(':') on an array does not search for a substring.

parseAddress now rejects arrays with the invalid-address error before any string method runs. The balance, transaction, and count routes all go through this function.

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/validators.test.ts --forceExit
  • New case: an array of addresses throws INVALID_ADDRESS_400. Existing address parsing cases still pass.
  • Re-ran the CodeQL query; this finding is gone.
Open in Web Open in Cursor 

Next.js turns a repeated query key into an array. parseAddress called
string methods on that value, so includes() checked element membership
instead of a substring. Non-string addresses are now rejected.

Co-authored-by: David <Klakurka@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 59c1db90-708d-44dd-a42d-9076ae82924c

  • 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.

@Klakurka
Klakurka marked this pull request as ready for review October 1, 2026 17:08
@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

🟡 Changes recommended

Balance and transaction-count endpoints convert the new validation error into HTTP 500 instead of 400.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Updates address validation to reject repeated query parameters represented as arrays.

Changes:

  • Expands parseAddress input handling to reject arrays.
  • Adds a unit test for repeated address parameters.
File Description
utils/​validators.ts Rejects array-valued addresses.
tests/​unittests/​validators.test.ts Tests array rejection.

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

Comment thread utils/validators.ts
export const parseAddress = function (addressString: string | string[] | undefined): string {
// Repeated query keys arrive as arrays. String methods like includes() then
// check membership instead of a substring, so reject non-strings before use.
if (Array.isArray(addressString)) throw new Error(RESPONSE_MESSAGES.INVALID_ADDRESS_400.message)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Added INVALID_ADDRESS_400 handling to both routes and added repeated-address endpoint response tests in commit 83d123a3.

Comment thread tests/unittests/validators.test.ts Outdated
…preserve parseAddress type coverage'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Klakurka <4713204+Klakurka@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

4 participants