Skip to content

Potential fix for code scanning alert no. 12: Incomplete multi-character sanitization#6

Merged
PRATHAM777P merged 1 commit into
mainfrom
alert-autofix-12
Apr 27, 2026
Merged

Potential fix for code scanning alert no. 12: Incomplete multi-character sanitization#6
PRATHAM777P merged 1 commit into
mainfrom
alert-autofix-12

Conversation

@PRATHAM777P
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/PRATHAM777P/AlphaMind/security/code-scanning/12

General fix: avoid relying on complex multi-character regex removal of dangerous tags (<script...>...</script> etc.) as a sanitizer. Instead, perform robust text extraction by removing/neutralizing all markup delimiters (< and >) after entity decoding, or use a vetted HTML sanitizer/parser.

Best minimal fix here (without changing intended functionality): keep current extraction logic, but change decodeEntities so it does not decode &lt;/&gt; back into </> before stripping. Then, in stripTags, continue to remove any literal <...> tags first and finally remove any remaining literal angle brackets. This prevents reintroduction of executable tag syntax through entity decoding and eliminates the incomplete multi-character sanitization concern around the script-removal block.

Edit only src/tools/fetch/web-fetch-utils.ts:

  • In decodeEntities, remove replacements that decode &lt; and &gt;.
  • Keep other entity decoding (nbsp, quot, numeric, amp) intact.

No new imports/dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ter sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@PRATHAM777P PRATHAM777P marked this pull request as ready for review April 27, 2026 18:25
@PRATHAM777P PRATHAM777P merged commit 76b9c27 into main Apr 27, 2026
2 checks passed
@PRATHAM777P PRATHAM777P deleted the alert-autofix-12 branch April 27, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant