Closed Bug 801681 (CVE-2012-4207) Opened 12 years ago Closed 12 years ago

"~" eats a char near chunk delimiter in HZ-GB-2312 encoding

Categories

(Core :: Internationalization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19
Tracking Status
firefox16 --- affected
firefox17 --- fixed
firefox18 --- fixed
firefox19 --- fixed
firefox-esr10 17+ fixed
firefox-esr17 --- fixed

People

(Reporter: masatokinugawa, Assigned: smontagu)

References

Details

(4 keywords, Whiteboard: [adv-track-main17+][adv-track-esr17+] XSS against sites using this charset)

Attachments

(3 files, 2 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 6.0; rv:16.0) Gecko/20100101 Firefox/16.0
Build ID: 20121010144125

Steps to reproduce:

In HZ-GB-2312 encoding, "~" eats a char near chunk delimiter. This behavior is Firefox only. 

This leads to XSS attack:
http://vulnerabledoma.in/fx_hz?q=~%20123

Also, this has potential risk of Bug 690225.



Expected results:

"~" should not eat character.
Component: Untriaged → Internationalization
Product: Firefox → Core
Matt: please capture this testcase and add it as an attachment.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mwobensmith)
Keywords: sec-high, testcase
Whiteboard: XSS against sites using this charset
Flags: needinfo?(mwobensmith)
Attached file captured testcase (obsolete) —
More faithful capture... the previous attachment suffered from browser translation of >< to &gt;&lt; which broke the testcase -- onmouseover triggered because it was legitimately in the source regardless of charset.

If you load this testcase as the hz-gb-2312 charset you see one <input> with an alert triggered on mouseover. If you then go to the View menu and change the Character Encoding to UTF-8 you will see two inputs, with "~ 123" in one and the onmouseover injection in the other.
Attachment #672400 - Attachment is obsolete: true
Comment on attachment 672572 [details]
captured testcase

This doesn't work either. The only obvious difference I see is that vulnerabledoma.in is using Transfer-Encoding: chunked and there's no way to do that for an attached testcase that I know of.
Attachment #672572 - Attachment is obsolete: true
Attached file Alternative testcase
The bug is there in the decoder even without the chunking - this testcase finds another way to exhibit it.
Assignee: nobody → smontagu
Keywords: regression
Attached patch PatchSplinter Review
When unconsuming the character we need to decrement the loop index as well as the source pointer.

The patch fixes another error, not related to this bug: we should only increment iDestlen++ when actually outputting a character. I need to work out a testcase for that as well.
Attachment #672714 - Flags: review?(VYV03354)
Attachment #672714 - Flags: review?(VYV03354) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/38784da3792d
OS: Windows Vista → All
Hardware: x86 → All
Version: 16 Branch → Trunk
Attached file Testcase 2
This is a testcase for the second issue mentioned in comment 6. Without the patch it asserts:
 
###!!! ASSERTION: The Unicode decoder consumed the wrong number of bytes.: 'totalByteCount == (int32_t)aCount', file parser/html/nsHtml5StreamParser.cpp, line 869
###!!! ASSERTION: Wrong number of stream bytes written/sniffed.: 'writeCount == aLength', file parser/html/nsHtml5StreamParser.cpp, line 1077
https://hg.mozilla.org/mozilla-central/rev/38784da3792d
Status: NEW → RESOLVED
Closed: 12 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Comment on attachment 672714 [details] [diff] [review]
Patch

[Approval Request Comment]
Bug caused by (feature/regressing bug #): bug 715319
User impact if declined: Possibility of XSS attack in pages encoded in HZ-GB-2312
Testing completed (on m-c, etc.): On m-c since 2012-10-18
Risk to taking this patch (and alternatives if risky): minimal
String or UUID changes made by this patch: None
Attachment #672714 - Flags: approval-mozilla-esr10?
Attachment #672714 - Flags: approval-mozilla-beta?
Attachment #672714 - Flags: approval-mozilla-aurora?
Attachment #672714 - Flags: approval-mozilla-esr10?
Attachment #672714 - Flags: approval-mozilla-esr10+
Attachment #672714 - Flags: approval-mozilla-beta?
Attachment #672714 - Flags: approval-mozilla-beta+
Attachment #672714 - Flags: approval-mozilla-aurora?
Attachment #672714 - Flags: approval-mozilla-aurora+
Whiteboard: XSS against sites using this charset → [adv-track-main17+][adv-track-esr17+] XSS against sites using this charset
Alias: CVE-2012-4207
Keywords: verifyme
Flags: sec-bounty?
Flags: sec-bounty? → sec-bounty+
Group: core-security
Tests checked in https://hg.mozilla.org/integration/mozilla-inbound/rev/f27d5d9ebef2
Flags: in-testsuite? → in-testsuite+
mass remove verifyme requests greater than 4 months old
Keywords: verifyme
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: