Closed Bug 924932 (CVE-2013-1743) Opened 11 years ago Closed 11 years ago

[SECURITY] Field values are (still) not escaped correctly in tabular reports

Categories

(Bugzilla :: Reporting/Charting, defect)

4.1.1
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.2

People

(Reporter: mateusz.goik, Assigned: LpSolit)

References

Details

(Keywords: reporter-external, sec-critical, wsec-xss)

Attachments

(1 file, 2 obsolete files)

Hum, this was supposed to be fixed by bug 790296. There must be another place in the JS code which also needs HTML-filtering. (It's a bit irritating that YUI is unable to filter stuff itself).
OS: Linux → All
Hardware: x86_64 → All
Target Milestone: --- → Bugzilla 4.2
Version: unspecified → 4.1.1
Summary: XSS in report.cgi → [SECURITY] Field values are (still) not escaped correctly in tabular reports
(In reply to Mateusz Goik from comment #2)
> Not only JS:

Right. I found what the problem was for this specific case. A div had |FILTER js| instead of |FILTER html|. The root cause for comment 0 is still unknown, though.
(In reply to Frédéric Buclin from comment #3)
> Right. I found what the problem was for this specific case. A div had
> |FILTER js| instead of |FILTER html|.

... which was a regression due to bug 640987.
I can reproduce comment 0 only if the horizontal axis has evil data. If only the vertical axis has it, it's fine.
I think I found the problem: oColumn.field needs to be escaped.
Flags: blocking4.4.1+
Flags: blocking4.2.7+
This bug shall be known as CVE-2013-1743
Alias: CVE-2013-1743
Blocks: 926085
Attached patch patch, v1 (obsolete) — Splinter Review
This patch applies to all branches (4.2 and newer). As a side-effect, it also fixes bug 859188.
Assignee: charting → LpSolit
Status: NEW → ASSIGNED
Attachment #816273 - Flags: review?(dkl)
Blocks: 859188
Blocks: 912643
Attached patch patch, v1.1 (obsolete) — Splinter Review
Better patch: only decode HTML entities when necessary, i.e. for row values only (column values are not HTML-escaped). This correctly handles improbable strings such as "&amp;gt; &lt;" (which must not be converted to "&gt; <" or "> <").
Attachment #816273 - Attachment is obsolete: true
Attachment #816273 - Flags: review?(dkl)
Attachment #816319 - Flags: review?(dkl)
http://localhost/bugzilla_copy/userprefs.cgi
Your real name (optional, but encouraged): '.a*eval(alert(1))*-'


http://localhost/bugzilla_copy/report.cgi?x_axis_field=reporter_realname&y_axis_field=reporter_realname&z_axis_field=reporter_realname&no_redirect=1&query_format=report-table&short_desc_type=allwordssubstr&short_desc=&classification=aaaaaaa&classification=Unclassified&resolution=---&longdesc_type=allwordssubstr&longdesc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&deadlinefrom=&deadlineto=&bug_id=&bug_id_type=anyexact&votes=&votes_type=greaterthaneq&emailtype1=substring&email1=&emailtype2=substring&email2=&emailtype3=substring&email3=&chfieldvalue=&chfieldfrom=&chfieldto=Now&j_top=AND&f1=noop&o1=noop&v1=&format=table&action=wrap

...
  elLiner.innerHTML = '&lt;a href="buglist.cgi?action=wrap&amp;amp;classification=aaaaaaa&amp;amp;classification=Unclassified&amp;amp;resolution=---&amp;amp;reporter_realname='.a*eval(alert(1))*-'&amp;amp;reporter_realname='
                          + bz_encode(oColumn.field)
                          + '"&gt;' + oData + '&lt;/a&gt;';
    else
      elLiner.innerHTML = '&lt;a href="buglist.cgi?action=wrap&amp;amp;classification=aaaaaaa&amp;amp;classification=Unclassified&amp;amp;resolution=---&amp;amp;reporter_realname='.a*eval(alert(1))*-'&amp;amp;reporter_realname='
                          + bz_encode(oRecord.getData("row_title"), 1)
                          + '&amp;amp;reporter_realname='
                          + bz_encode(oColumn.field) + '"&gt;' + oData + '&lt;/a&gt;';
....
@Mateusz: is your testcase with my patch applied or not?
(In reply to Frédéric Buclin from comment #11)
> @Mateusz: is your testcase with my patch applied or not?

with your patch (Attachment #816319 [details] [diff])
The problem only happens when the z-axis is set to the field containing evil data. I will investigate.
Attached patch patch, v2Splinter Review
Thanks for your testing, Mateusz, that's very helpful. :)
Attachment #816319 - Attachment is obsolete: true
Attachment #816319 - Flags: review?(dkl)
Attachment #816391 - Flags: review?(dkl)
Comment on attachment 816391 [details] [diff] [review]
patch, v2

Can we use YAHOO.lang.escapeHTML() here?
See also bug 657194
(In reply to Reed Loden [:reed] from comment #15)
> Can we use YAHOO.lang.escapeHTML() here?

escapeHTML() is similar to |FILTER html|. encodeURIComponent() is similar to |FILTER uri|. What we want is |FILTER uri|, i.e. encodeURIComponent().
Mateusz: did you manage to trigger XSS with my new patch?
(In reply to Frédéric Buclin from comment #18)
> Mateusz: did you manage to trigger XSS with my new patch?

it's ok now
Comment on attachment 816391 [details] [diff] [review]
patch, v2

Review of attachment 816391 [details] [diff] [review]:
-----------------------------------------------------------------

r=dkl
Attachment #816391 - Flags: review?(dkl) → review+
Flags: approval?
Flags: approval4.4?
Flags: approval4.2?
Flags: approval?
Flags: approval4.4?
Flags: approval4.4+
Flags: approval4.2?
Flags: approval4.2+
Flags: approval+
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified template/en/default/reports/report-table.html.tmpl
Committed revision 8780.

Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/4.4/
modified template/en/default/reports/report-table.html.tmpl
Committed revision 8626.

Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/4.2/
modified template/en/default/reports/report-table.html.tmpl
Committed revision 8234.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Group: bugzilla-security
Security advisory sent.
Flags: sec-bounty? → sec-bounty+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: