Opened 8 years ago
Closed 8 years ago
#13040 closed defect (fixed)
Script injection
Reported by: | Jun Omae | Owned by: | tkob-trac |
---|---|---|---|
Priority: | normal | Component: | MermaidMacro |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
Any scripts can be injected via id
argument:
{{{#!Mermaid id="''><script>alert(42)</script>" .... }}}
-
mermaidmacro/1.0/tracmermaid/mermaid.py
diff --git a/mermaidmacro/1.0/tracmermaid/mermaid.py b/mermaidmacro/1.0/tracmermaid/mermaid.py index 0f871da..e50b617 100644
a b class MermaidMacro(WikiMacroBase): 33 33 if args == None or 'id' not in args: 34 34 id_attr = '' 35 35 else: 36 id_attr = 'id=%s' % args['id']36 id_attr = 'id=%s' % escape(args['id']) 37 37 url_escaped_content = urllib2.quote(content) 38 38 div = """<div class="mermaid" 39 39 %s
Attachments (2)
Change History (7)
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
Oh, good catch, didn't see that one...
Just in case you're also testing my changes, I even have one more pending improvement, the support for TracLinks in flow charts.
I'll first version the changes locally so that we can have separated patches per ticket.
Changed 8 years ago by
Attachment: | 0005-TH13040-Fix-possible-script-injection-vulnerability.patch added |
---|
incremental patch, on top of 004 in #13042
comment:3 Changed 8 years ago by
For good measure. Now you have all my changes. Would be nice if tkob had a github repo for this plugin, but it seems not.
Changed 8 years ago by
Attachment: | 0005-TH13040-Fix-possible-script-injection-vulnerability.2.patch added |
---|
take 2, add missing "" after id=
comment:4 Changed 8 years ago by
By the way, it seems possible to insert <script> tags via the "normal" mermaid editor. Try the following:
sq["node <b>text</b><script>alert('bad!')</script>"] --> ci((Circle shape))
in http://knsv.github.io/mermaid/live_editor/.
However, via the MermaidMacro it seems OK, the alert doesn't show up, though the text is still bold. I haven't understood yet the difference between the two situations, i.e. the generated markup seems to be the same. Maybe you have a clue and could tell if there's a possible injection risk via this method?
The same issue can be occurred via wiki page named with
"><script>alert(42)</script>
.mermaidmacro/1.0/tracmermaid/mermaid.py
formatter.context.resource.realm,formatter.context.resource.id,formatter.context.resource.version or '',