fix(security): resolve ReDoS vulnerability in function execute tag pattern#4149
fix(security): resolve ReDoS vulnerability in function execute tag pattern#4149waleedlatif1 merged 4 commits intostagingfrom
Conversation
…ttern Simplified regex to eliminate overlapping quantifiers that caused exponential backtracking on malformed input without closing delimiter.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview This removes the previous potentially backtracking-heavy pattern and centralizes tag parsing behavior to the common reference-validation utility, mitigating ReDoS risk from malformed/untrusted code inputs. Reviewed by Cursor Bugbot for commit 4e21a08. Configure here. |
Greptile SummaryThis PR fixes a ReDoS vulnerability in Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["resolveTagVariables(code, ...)"] --> B["resolvedCode.match(TAG_PATTERN)"]
B --> C{"matches found?"}
C -- "no" --> Z["return resolvedCode"]
C -- "yes" --> D["for each match"]
D --> E["slice <...> to get tagName"]
E --> F["resolveBlockReference(blockName, fieldPath)"]
F --> G{"result found?"}
G -- "no" --> D
G -- "yes" --> H{"tagValue === undefined?"}
H -- "yes" --> I["replace match with 'undefined'/'None'"]
H -- "no" --> J["build safeVarName\n__tag_..."]
J --> K["contextVariables[safeVarName] = tagValue"]
K --> L["replace match with safeVarName in code"]
I --> D
L --> D
D --> Z
style B fill:#d4edda,stroke:#28a745
note1["TAG_PATTERN = createReferencePattern()\n= /<([^<>]+)>/g\n(no ReDoS risk)"]
Reviews (3): Last reviewed commit: "refactor(security): use createReferenceP..." | Re-trigger Greptile |
Matches createReferencePattern() from reference-validation.ts used by the core executor. Invalid refs handled gracefully by resolveBlockReference.
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4e21a08. Configure here.
Summary
resolveTagVariablesto eliminate overlapping quantifiers ([a-zA-Z0-9_.]*[a-zA-Z0-9_]) that caused exponential backtracking on malformed input (e.g.,<aaaa...without closing>)Type of Change
Testing
bun run lintpassesbun run test— all 5031 tests pass (5 pre-existing import failures unrelated)Checklist