Closed Bug 1167370 Opened 9 years ago Closed 9 years ago

TextRenderer::RenderText using uninitialized memory

Categories

(Core :: Graphics: Text, defect)

38 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox38 --- disabled
firefox38.0.5 --- disabled
firefox39 --- disabled
firefox40 --- disabled
firefox41 --- fixed
firefox-esr38 --- disabled

People

(Reporter: q1, Assigned: kyle_fung)

Details

(Keywords: csectype-uninitialized, sec-other, Whiteboard: [post-critsmash-triage])

Attachments

(1 file, 2 obsolete files)

User Agent: Mozilla/5.0 (Windows; rv:26.0) Gecko/20100101 Firefox/26.0
Build ID: 20150305021524

Steps to reproduce:

In Firefox 38.0.1, TextRenderer::RenderText uses uninitialized memory at gfx\layers\composite\TextRenderer.cpp line 96 et seq.

The problem is that TextRenderer::RenderText does not check the return value from DataSourceSurface::Map at line 93, thus (on failure and for some derived classes of DataSourceSurface, e.g., DataSourceSurfaceD2D) leaving untouched whatever was contained in the uninitialized variable map:

 92: DataSourceSurface::MappedSurface map;
 93: textSurf->Map(DataSourceSurface::MapType::READ_WRITE, &map);
 94:
 95: // Initialize the surface to transparent white.
 96: memset(map.mData, uint8_t(sBackgroundOpacity * 255.0f),
 97:        numLines * sCellHeight * map.mStride);
 98:
 99:  uint32_t currentXPos = 0;
100:  uint32_t currentYPos = 0;
101:
102:  // Copy our glyphs onto the surface.
  ...
115:  memcpy (map.mData + ...)

Since map can contain anything, this bug could make it possible to write data into anywhere in Firefox's address space. Depending on how RenderText is used, this bug might be exploitable to disclose sensitive data and/or cause execution of attacker-selected code. Perhaps an attacker could design a font that contains data to be written to the stack such that, when RenderText returns, it passes control to an attacker-designated function.
There's also a similar bug in TextRenderer::EnsureInitialized at line 154.
Status: UNCONFIRMED → NEW
Component: Untriaged → Graphics: Layers
Ever confirmed: true
Flags: needinfo?(milan)
Product: Firefox → Core
Component: Graphics: Layers → Graphics: Text
Flags: needinfo?(milan)
Assignee: nobody → kfung
Attached patch Returns if Map() fails (obsolete) — Splinter Review
Attachment #8609533 - Flags: review?(gavin.sharp)
Attachment #8609533 - Flags: review?(gavin.sharp) → review?(bas)
Attached patch Addressed issue in line 154 (obsolete) — Splinter Review
Attachment #8609533 - Attachment is obsolete: true
Attachment #8609533 - Flags: review?(bas)
Attachment #8609666 - Flags: review?(bas)
Attachment #8609666 - Flags: review?(bas) → review+
Should be noted this isn't exactly sec critical as the TextRenderer isn't used without custom prefs set.
Flags: needinfo?(milan)
Comment on attachment 8609666 [details] [diff] [review]
Addressed issue in line 154

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

I'd have a more informative check-in comment, like "check for Map call failing" or some such.  You'd also want it to be in the format Bug xxxxx: comment.  r=reviewer".
This is sec-other, so I don't think we need a security approval.
Flags: needinfo?(milan)
Attachment #8609666 - Attachment is obsolete: true
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/20da4771e913
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Flags: sec-bounty?
(In reply to Bas Schouten (:bas.schouten) from comment #4)
> Should be noted this isn't exactly sec critical as the TextRenderer isn't
> used without custom prefs set.

If we're never going to use it we should just rip it out. If we're working toward turning it on by default some day then the fact it isn't now doesn't reduce the severity of the potential vulnerability described here (though it wouldn't be an emergency, so critical->high is acceptable).

So what's the status of this feature?
Flags: needinfo?(bas)
Keywords: sec-other
(In reply to Daniel Veditz [:dveditz] from comment #10)
> (In reply to Bas Schouten (:bas.schouten) from comment #4)
> > Should be noted this isn't exactly sec critical as the TextRenderer isn't
> > used without custom prefs set.
> 
> If we're never going to use it we should just rip it out. If we're working
> toward turning it on by default some day then the fact it isn't now doesn't
> reduce the severity of the potential vulnerability described here (though it
> wouldn't be an emergency, so critical->high is acceptable).
> 
> So what's the status of this feature?

Incorrect, it's used for diagnostic purposes by Mozilla engineers. But only through a pref that would essentially never run in a production environment. So it serves a clear purpose, but is unlikely to ever be used in our normal release builds by our regular users.

(Doesn't mean it isn't nice to have fixed)
Flags: needinfo?(bas)
Would we want to make it only show up in nightly+aurora then?
(In reply to Bas Schouten (:bas.schouten) from comment #11)
> Incorrect, it's used for diagnostic purposes by Mozilla engineers. But only
> through a pref that would essentially never run in a production environment.
> So it serves a clear purpose, but is unlikely to ever be used in our normal
> release builds by our regular users.

Thanks for clarifying. sec-other is appropriate then
Flags: sec-bounty? → sec-bounty+
Keywords: sec-other
Group: core-security → core-security-release
Whiteboard: [post-critsmash-triage]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: