Commit 56f19b8
Saurabh Badenkal
Fix CodeQL ReDoS: replace vulnerable write regex with comment-stripping approach
CodeQL found exponential backtracking in _SQL_WRITE_RE which used
nested quantifiers for SQL comment matching: (?:/\*.*?\*/\s*|...)*
Fix: separate comment stripping (_SQL_COMMENT_RE) from write detection.
1. Strip SQL comments with a safe non-backtracking regex
2. Check for write keywords with the simple anchored regex
The comment regex uses [^*]*\*+(?:[^/*][^*]*\*+)*/ which is the
standard safe pattern for matching C-style block comments.
3 new tests for comment-prefixed write detection.
774 unit tests passing.1 parent b5eb12b commit 56f19b8
2 files changed
Lines changed: 23 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
842 | | - | |
843 | | - | |
| 842 | + | |
| 843 | + | |
844 | 844 | | |
| 845 | + | |
845 | 846 | | |
846 | 847 | | |
847 | 848 | | |
| |||
929 | 930 | | |
930 | 931 | | |
931 | 932 | | |
932 | | - | |
933 | | - | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
934 | 936 | | |
935 | 937 | | |
936 | 938 | | |
| |||
1035 | 1037 | | |
1036 | 1038 | | |
1037 | 1039 | | |
1038 | | - | |
1039 | | - | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1040 | 1044 | | |
1041 | 1045 | | |
1042 | 1046 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
| |||
0 commit comments