Bug 283231 - [security] Nullbytes hide code on Eclipse 3.5 I20090611-1540 on Ubuntu 9.04
Summary: [security] Nullbytes hide code on Eclipse 3.5 I20090611-1540 on Ubuntu 9.04
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged, ui
Depends on:
Blocks:
 
Reported: 2009-07-11 20:55 EDT by Mario Heiderich CLA
Modified: 2018-11-30 10:29 EST (History)
7 users (show)

See Also:


Attachments
test case html w. nullbytes and trailing XSS vector (33 bytes, application/octet-stream)
2009-07-11 21:03 EDT, Mario Heiderich CLA
no flags Details
demo screenshot (33.45 KB, image/png)
2009-07-11 21:20 EDT, Mario Heiderich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Heiderich CLA 2009-07-11 20:55:45 EDT
Build ID: I20090611-1540

Steps To Reproduce:
1.Open the attached file
2.Choose either Text Editor/Aptana HTML Editor/Subclipse compare/ tbc
3.Cross-check the file with a hex editor/open with a browser


More information:
Null-bytes seem to hide the information positioned behind them. This can be used for smuggling arbitrary code which is not likely to be found during daily work flow.
Comment 1 Mario Heiderich CLA 2009-07-11 21:03:35 EDT
Created attachment 141363 [details]
test case html w. nullbytes and trailing XSS vector
Comment 2 Mario Heiderich CLA 2009-07-11 21:13:05 EDT
It seems to work only on *nix based systems so far. Tested were Ubuntu 9.04 32Bit (success) and the same Eclipse revision on Win XPSP2 32 (fail). Not tested yet were Mac OSX and other operating systems. 

The hidden code in the test-file resists editing/saving, SVN commits, exports and other comparable interaction/modification. A copying of the file doesn't impact the content - so the overhead is being noticeable via file size. Copy-pasting the text itself is OS dependent regarding result. 

Please see the attachment for a demonstration.

Excuse the lack of choice in the drop-down for 'Component' - I had no idea what to select..

Comment 3 Mario Heiderich CLA 2009-07-11 21:20:38 EDT
Created attachment 141364 [details]
demo screenshot
Comment 4 Mario Heiderich CLA 2009-08-14 08:36:55 EDT
Just in case someone is interested - I justed tested this on an Eclipse running on latest Kubuntu (9.0.4) with KDE 4.2.2 .- exact same result.
Comment 5 Remy Suen CLA 2009-08-14 08:39:34 EDT
Could be an SWT or Text problem.
Comment 6 Bogdan Gheorghe CLA 2009-10-13 14:40:08 EDT
Praveen, do you want to take a look at this?
Comment 7 Praveen CLA 2009-10-14 00:11:20 EDT
Sure, I will take a look.
Comment 8 Praveen CLA 2009-10-23 04:59:27 EDT
Upon investigation, it appears that this to be the JRE IO-classes problem on Linux. 
The function ResourceTextFileBuffer.setDocumentContent() is responsible for reading the contents of the (resource) file through BufferedReader. However, when the file contains a 'null' byte, then the characters following the null byte are not filled into the buffer. 
Though the API Reader.read(char[]) returns the correct number of bytes, the array is not filled with the characters position beyond the null character. However, on Windows, the API fills the characters in the right manner. 
Since the problem happens due to JRE of Linux itself, I have a reported a bug against Sun JRE (Review ID: 1635046).
As the rootcause of the problem is in org.eclipse.core.filebuffers, should this be routed to platform-text-inbox ?
Comment 9 Dani Megert CLA 2009-10-23 11:41:36 EDT
Which SDK version? Did you verify whether it's fixed in a newer version?
Comment 10 Praveen CLA 2009-10-26 05:41:43 EDT
(In reply to comment #9)
> Which SDK version? Did you verify whether it's fixed in a newer version?
I tried against Java 1.4 and 1.6 (on my machine), and the problem appears on both of them.
Comment 11 Dani Megert CLA 2009-10-26 05:48:50 EDT
Did you also try the IBM VMs?
Comment 12 Chris McGee CLA 2011-03-10 16:56:17 EST
I can confirm that something similar is also happening on Ubuntu 10.04 with an IBM 1.5 VM.

One difference is that I can still see the characters after the null bytes. Also, When I move the cursor with the left and right arrow keys it seems as though the cursor moves over these null bytes even though it doesn't move anywhere.

I move x characters to the right (using the right arrow key) I have to type the left arrow key x+1 times before the cursor moves left of where it was before (one character before the last non-null byte).

I would expect that if the bytes are not shown then the cursor should behave consistently. vi shows the characters as "^@" and open office just shows them just as "#".
Comment 13 Eric Williams CLA 2018-11-30 10:29:58 EST
This version of Ubuntu is no longer a supported target environment, please file a new ticket against 4.9/4.10 if the issue occurs on Ubuntu 18.04.