Skip to content

[LEGIT] Fix - js/polynomial-redos - #107

Open
liorn-test-app[bot] wants to merge 1 commit into
masterfrom
legit-security-36f54b
Open

[LEGIT] Fix - js/polynomial-redos#107
liorn-test-app[bot] wants to merge 1 commit into
masterfrom
legit-security-36f54b

Conversation

@liorn-test-app

@liorn-test-app liorn-test-app Bot commented Jul 7, 2026

Copy link
Copy Markdown

🔍 The problem

Polynomial regular expression used on uncontrolled data
See issue in Legit

🔒 Fix Details

Fixed a potential Regular Expression Denial of Service (ReDoS) vulnerability where user-controlled input (bankRouting from the request body) was passed directly to a regex test without length validation.

Added input validation that checks if bankRouting is a string and enforces a maximum length of 50 characters before the regex pattern is applied. This prevents attackers from submitting extremely large strings that could cause the regex engine to consume excessive CPU resources, even though the current regex pattern itself does not exhibit catastrophic backtracking.

This is a defense-in-depth measure that protects against resource exhaustion from oversized inputs while maintaining the existing validation logic for legitimate bank routing numbers.

--- a/app/routes/profile.js
+++ b/app/routes/profile.js
@@ -32,6 +32,20 @@
     this.handleProfileUpdate = (req, res, next) => {
 
         const {firstName, lastName, ssn, dob, address, bankAcc, bankRouting} = req.body;
+
+        // Validate bankRouting length to prevent ReDoS
+        if (typeof bankRouting !== 'string' || bankRouting.length > 50) {
+            return res.render("profile", {
+                updateError: "Bank Routing number format is invalid",
+                firstName,
+                lastName,
+                ssn,
+                dob,
+                address,
+                bankAcc,
+                bankRouting: ''
+            });
+        }
 
         // Fix for Section: ReDoS attack
         // The following regexPattern that is used to validate the bankRouting number is insecure and vulnerable to

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants