Closed Bug 1106552 Opened 10 years ago Closed 10 years ago

NPAPI plugin can get corrupted string inside NPVariant (leads to plugin crash)

Categories

(Core Graveyard :: Plug-ins, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla37

People

(Reporter: sekogan, Assigned: gfritzsche)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20141128004001

Steps to reproduce:

1. Make an NPAPI plugin for Firefox.

2. In the Javascript part of the plugin call some function from the native part. Pass a big string as a parameter with a zero byte in the middle:

var bad_data = 'helloworld' + 'x'.repeat(130000) + '\x00' + 'x'.repeat(130000);
functionFromNpapiPlugin(bad_data);

3. In the NPAPI part of the plugin try to copy the string from NPVariant.

Actual bug is located at line 63 of
http://mxr.mozilla.org/mozilla-central/source/dom/plugins/ipc/PluginScriptableObjectUtils-inl.h
String is copied using strdup despite the fact that it is not zero terminated and can contain zero bytes inside.


Actual results:

Actual: length (NPVariant::value::stringValue::utf8length) is unchanged (260010) but content (NPVariant::value::stringValue::utf8characters) has only the first 130010+1 bytes. Plugin generates access violation while trying to read the string beyond the zero byte.

Please find attached dump of some real NPAPI plugin. The third argument of invoke (convertedArgs.Elements()[2]) has NPVariant with corrupted string.


Expected results:

Expected: length and content of the string are unchanged. Plugin can read content of the string.
Thanks for the detailed report here.
Assignee: nobody → georg.fritzsche
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8534525 - Flags: review?(benjamin)
Attachment #8534525 - Flags: review?(benjamin) → review+
https://hg.mozilla.org/mozilla-central/rev/445905b4d3c3
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: