Skip to content

MLE-33481: Bugcrowd: node-client-api: documents.remove() lets temporalCollection inject an extra uri= into the DELETE, deleting a document the caller never named - #1131

Merged
vishwach merged 1 commit into
developfrom
MLE-33481
Nov 20, 2026
Merged

vishwach merged 1 commit into
developfrom
MLE-33481

Conversation

@vishwach

@vishwach vishwach commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

In lib/documents.js, removeDocumentImpl() previously appended temporalCollection and systemTime using raw string concatenation without URL encoding. If an application passed input containing & or =, additional query parameters (such as extra uri= parameters) could be injected into the DELETE /v1/documents request sent to MarkLogic (CWE-93).

Changes

  • Wrapped temporalCollection with encodeURIComponent() in removeDocumentImpl().
  • Added encoding for systemTime, handling both string and Date types (toISOString()).
  • Added unit tests in test-basic/ to verify special characters (&, =, /) are properly escaped and do not inject additional query parameters.

Verification

  • Verified outgoing HTTP request path encodes delimiters (e.g. %26uri%3D).

@NiteshMehta
NiteshMehta marked this pull request as ready for review November 17, 2026 16:33
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:33
NiteshMehta
NiteshMehta previously approved these changes Nov 17, 2026
@NiteshMehta

Copy link
Copy Markdown

@vishwach Please investigate the cause of the build failure.

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.

🟢 Approval recommended

No active review issues are reported for the request-encoding and session-identifier hardening changes.

No open issues 🎉

What changed in this PR

This PR hardens the Node.js client’s request construction against query-parameter injection in document deletion and increases session identifier randomness.

Changes:

  • URL-encodes temporal parameters and transaction IDs to prevent injected query parameters.
  • Adds an outgoing-request regression test and updates negative tests to pass unencoded transaction IDs.
  • Increases session identifiers from 8 to 16 random bytes and updates the corresponding assertion.
File Description
test-basic/​session-state-test.js Expects 32-character hexadecimal session identifiers.
test-basic/​documents-remove-url-test.js Verifies parameter encoding prevents extra document URIs.
test-basic/​documents-negative.js Passes raw invalid transaction IDs to the client.
lib/​session-state.js Generates session identifiers using 16 random bytes.
lib/​mlutil.js URL-encodes string and object-based transaction IDs.
lib/​documents.js URL-encodes temporal collection and system-time values for deletion requests.

Review effort: Balanced

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.

🟢 Approval recommended

No active review issues were identified for the document-deletion parameter-encoding changes.

No open issues 🎉

Review effort: Balanced

…lCollection inject an extra uri= into the DELETE, deleting a document the caller never named
@vishwach
vishwach merged commit effc6a5 into develop Nov 20, 2026
4 checks passed
@vishwach
vishwach deleted the MLE-33481 branch November 23, 2026 07:36
Sign up for free to 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.

5 participants