#31466: A potential security issue in the Django template filter `escapejs`
-------------------------------------------+--------------------------
               Reporter:  phithon          |          Owner:  nobody
                   Type:  New feature      |         Status:  new
              Component:  Template system  |        Version:  3.0
               Severity:  Normal           |       Keywords:  escapejs
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+--------------------------
 Hi, I recently encountered a problem that is related to Django, I think I
 should report and discuss with you.

 As I know, `escapejs` is a helpful template filter which can protect us
 from XSS attack in Javascript string like this:

 {{{
 <script>
     function example() {
         query = '{{ request.GET.q | escapejs }}';
     }
 </script>
 }}}

 But there is usually a situation, as time goes on, someone thinks this
 function is not used anymore and comments it out:

 {{{
 <script>
     /*
     function example() {
         query = '{{ request.GET.q | escapejs }}';
     }
     */
 </script>
 }}}

 Oops, A XSS vulnerability is introduced. The attackers can trigger
 arbitrary javascript execution by the request
 {{{http://example.com/?q=*/(alert(1))/*}}}

 It's not a Django security bug but I also suggest making the `/` and `*`
 escaped in the `escapejs` filter.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31466>
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/050.bd4139f423242130f46b305f00e65c92%40djangoproject.com.

Reply via email to