Skip to content

Fix FormDataConsumer to avoid ReDoS in source detection#11224

Merged
slax57 merged 2 commits intomasterfrom
fix-form-data-consumer-redos
Mar 31, 2026
Merged

Fix FormDataConsumer to avoid ReDoS in source detection#11224
slax57 merged 2 commits intomasterfrom
fix-form-data-consumer-redos

Conversation

@WiXSL
Copy link
Copy Markdown
Collaborator

@WiXSL WiXSL commented Mar 31, 2026

Summary

  • simplify the array-source detection logic in FormDataConsumer
  • replace the previous regex shape with a safe anchored suffix check

Why

GitHub code scanning reports alert #44 (Polynomial regular expression used on uncontrolled data) on FormDataConsumer.

The previous regex used a greedy repeated token before the numeric suffix. This change keeps the same intent while avoiding the backtracking pattern that CodeQL flagged.

Testing

  • yarn test-unit --runTestsByPath packages/ra-core/src/form/FormDataConsumer.spec.tsx

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates FormDataConsumer’s “array item source” detection to avoid a potentially unsafe regular expression pattern flagged by CodeQL, while preserving the existing behavior used to infer scopedFormData when inside iterator-like components.

Changes:

  • Replace /.+\.\d+$/ matching via exec() with a safer anchored suffix check (/\.\d+$/) via test().
  • Introduce a small helper (getArraySource) to centralize and clarify the detection logic.
  • Continue using the detected array-item source path to compute scopedFormData via lodash/get.

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

@WiXSL WiXSL requested a review from slax57 March 31, 2026 15:08
@slax57 slax57 added this to the 5.14.6 milestone Mar 31, 2026
@slax57 slax57 changed the title Avoid ReDoS in FormDataConsumer source detection Fix FormDataConsumer to avoid ReDoS in source detection Mar 31, 2026
@slax57 slax57 merged commit 39f924b into master Mar 31, 2026
15 checks passed
@slax57 slax57 deleted the fix-form-data-consumer-redos branch March 31, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants