Commit 344014d
fix(security): prevent ReDoS in extractTagContent (#9)
* fix(security): prevent ReDoS in extractTagContent
Escape special regex characters in tagName parameter before
constructing RegExp to prevent Regular Expression Denial-of-Service
attacks from malicious input.
* fix(security): eliminate ReDoS in extractTagContent via string-based parsing (#10)
* Initial plan
* fix(security): replace RegExp with string-based parsing in extractTagContent
- Remove dynamic RegExp construction to prevent ReDoS vulnerability
- Replace with safe string-based indexOf parsing
- Add input validation: only allow alphanumeric, hyphens, underscores
- Add length limit (100 chars) for tag names
- Maintain all existing functionality and test compatibility
Co-authored-by: theagenticguy <9553966+theagenticguy@users.noreply.github.com>
* refactor: improve extractTagContent performance and validation
- Replace regex validation with character-by-character check
- Implement custom case-insensitive search to avoid lowercasing large texts
- More efficient for large inputs (no full text copy)
- Still prevents ReDoS and maintains all functionality
Co-authored-by: theagenticguy <9553966+theagenticguy@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: theagenticguy <9553966+theagenticguy@users.noreply.github.com>
* fix: regex type guard
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>1 parent 833c8f7 commit 344014d
1 file changed
Lines changed: 72 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
164 | 194 | | |
165 | 195 | | |
166 | 196 | | |
167 | 197 | | |
168 | 198 | | |
169 | 199 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
173 | 240 | | |
174 | 241 | | |
175 | 242 | | |
| |||
0 commit comments