Skip to content

JS: remove encodeURI from sanitizer list of request forgery #19750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Napalys
Copy link
Contributor

@Napalys Napalys commented Jun 13, 2025

No description provided.

@Napalys Napalys force-pushed the js/remove_encodeURI branch from dbaa5bd to c2b9a5c Compare June 13, 2025 09:18
@Napalys Napalys changed the title JS: remove encodeURI from sanitizer list for xss and request forgery JS: remove encodeURI from sanitizer list of request forgery Jun 13, 2025
@Napalys Napalys marked this pull request as ready for review June 13, 2025 09:25
@Copilot Copilot AI review requested due to automatic review settings June 13, 2025 09:25
@Napalys Napalys requested a review from a team as a code owner June 13, 2025 09:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes encodeURI from the list of recognized sanitizers in request-forgery analysis, so calls to encodeURI no longer suppress alerts.

  • Added a test case in serverSide.js to show encodeURI(input) is now flagged.
  • Updated the expected alerts in RequestForgery.expected to include the new alert for encodedUrl.
  • Modified RequestForgeryCustomizations.qll to filter out encodeURI from being treated as a sanitizer.
  • Added a change note documenting the removal of encodeURI.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
javascript/ql/test/query-tests/Security/CWE-918/serverSide.js Added encodeURI(input) and its flagged axios.get call.
javascript/ql/test/query-tests/Security/CWE-918/RequestForgery.expected Updated expected alerts to include the new encodedUrl case.
javascript/ql/lib/semmle/javascript/security/dataflow/RequestForgeryCustomizations.qll Excluded encodeURI calls from UriEncodingSanitizer.
javascript/ql/lib/change-notes/2025-06-13-remove-encodeuri.md Documented the removal of encodeURI from the sanitizer list.
Comments suppressed due to low confidence (2)

javascript/ql/lib/change-notes/2025-06-13-remove-encodeuri.md:4

  • [nitpick] Since the analysis comment mentions both encodeURI and encodeURIComponent, update this change note to also mention removal of encodeURIComponent if that exclusion is intended.
* Removed `encodeURI` function from the sanitizer list for request forgery.

javascript/ql/lib/semmle/javascript/security/dataflow/RequestForgeryCustomizations.qll:114

  • The comment above mentions both encodeURI and encodeURIComponent as not valid URL sanitizers, but only encodeURI is excluded. Consider adding a similar exclusion for encodeURIComponent to match the documentation.
class UriEncodingSanitizer extends Sanitizer instanceof Xss::Shared::UriEncodingSanitizer {

@Napalys Napalys force-pushed the js/remove_encodeURI branch from c2b9a5c to 7a7e879 Compare June 16, 2025 08:52
@Napalys Napalys force-pushed the js/remove_encodeURI branch from 8aca630 to 0d5f510 Compare June 16, 2025 11:08
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.

1 participant