#31466: A potential improvement in the Django template filter `escapejs`
---------------------------------+--------------------------------------
     Reporter:  Phithon          |                    Owner:  Phithon
         Type:  New feature      |                   Status:  closed
    Component:  Template system  |                  Version:  3.0
     Severity:  Normal           |               Resolution:  wontfix
     Keywords:  escapejs         |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------
Changes (by felixxm):

 * status:  assigned => closed
 * resolution:   => wontfix


Comment:

 Replying to [comment:5 Claude Paroz]:
 > Are you aware that in the example you provided, the `\*` and `*/` parts
 are **not** passed to `escapejs`?

 They pass `q=*/(alert(1))/*` so in a clever way we end with a valid JS:
 {{{
 <script>
     /*
     function example() {
         query = '*/(alert(1))/*';
     }
     */
 </script>
 }}}

 Replying to [ticket:31466 Phithon]:
 > Oops, A XSS vulnerability is introduced. The attackers can trigger
 arbitrary javascript execution by the request

 `escapejs` **does not** make the string safe for use in HTML or JavaScript
 template literals, see
 [https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#escapejs
 documentation]. It only protects you from syntax errors when using
 templates to generate JavaScript/JSON. I agree with Claude.

 See related #29055.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31466#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.3dbffb446a2b98fcae9f242c5bae8060%40djangoproject.com.

Reply via email to