22
1 PUBLIC © ACROS Remote Binary Planting An Overlooked Vulnerability Affair OWASP Maribor, 8.12.2010 Mitja Kolsek ACROS d.o.o. [email protected] www.acrossecurity.com Page 2 PUBLIC OWASP Maribor, 8.12.2010 Vulnerability Super-Star 1. Arbitrary Code Execution 2. Easy to Find 3. Easy to Exploit 4. Reliable 5. No Privileges 6. Remote 7. Works Through Firewalls 100.000.000.000

Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

1

PUBLIC © ACROS

Remote Binary PlantingAn Overlooked Vulnerability AffairOWASP Maribor, 8.12.2010

Mitja KolsekACROS [email protected]

Page 2PUBLIC OWASP Maribor, 8.12.2010

Vulnerability Super-Star

1. Arbitrary Code Execution2. Easy to Find3. Easy to Exploit4. Reliable5. No Privileges6. Remote7. Works Through Firewalls

100.000.000.000

Page 2: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

2

Page 3PUBLIC OWASP Maribor, 8.12.2010

Misunderstood

Page 4PUBLIC OWASP Maribor, 8.12.2010

Underestimated

Page 3: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

3

Page 5PUBLIC OWASP Maribor, 8.12.2010

Downplayed

Page 6PUBLIC OWASP Maribor, 8.12.2010

Ignored

Page 4: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

4

Page 7PUBLIC OWASP Maribor, 8.12.2010

Forgotten

Page 8PUBLIC OWASP Maribor, 8.12.2010

Quasi-Addressed

Page 5: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

5

Page 9PUBLIC OWASP Maribor, 8.12.2010

Still Ignored

Page 10PUBLIC OWASP Maribor, 8.12.2010

Unfixed

Page 6: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

6

Page 11PUBLIC OWASP Maribor, 8.12.2010

The Life of Binary Planting1998 NSA: Windows NT Security Guidelines2000 Georgi Guninski: Two Office bugs2001 Nimda uses “DLL spoofing” for propagation2004 Microsoft introduces “safe search order”2005 “DLL Spoofing in Windows” paper (local attack)2008 David LeBlanc: “DLL Preloading Attacks” articleMay 2009 Acros reports BP bugs to VMwareMar 2010 Acros reports BP bugs to Apple, Google, MicrosoftApr 2010 Phone conference with MicrosoftMeanwhile... Microsoft preparing remedy

520+ bugs in stockAug 18, 2010 Apple fixes iTunes, Acros publishes ASPRLater that day The cat gets “out of the bug”- Less than 10 publicized vulnerabilities in over 10 years

- Mostly local attacks- Only DLLs perceived as problem

- Less than 10 publicized vulnerabilities in over 10 years- Mostly local attacks- Only DLLs perceived as problem

“Double clicking on MS Office documents from Windows Explorer may execute arbitrary programs in some cases.”

Page 12PUBLIC OWASP Maribor, 8.12.2010

Page 7: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

7

Page 13PUBLIC OWASP Maribor, 8.12.2010

Local Media

Page 14PUBLIC OWASP Maribor, 8.12.2010

DLL Search Order

1. The directory from which the application loaded2. C:\Windows\System323. C:\Windows\System4. C:\Windows5. Current Working Directory (CWD)6. System PATH; User PATH

LoadLibrary(“SomeLib.dll”)

Page 8: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

8

Page 15PUBLIC OWASP Maribor, 8.12.2010

It Was Even Worse Before 2004

1. The directory from which the application loaded2. Current Working Directory (CWD)3. C:\Windows\System324. C:\Windows\System5. C:\Windows6. System PATH; User PATH

“UNSAFE” Search Order

Page 16PUBLIC OWASP Maribor, 8.12.2010

But is it Safe?

1. The directory from which the application loaded2. C:\Windows\System323. C:\Windows\System4. C:\Windows5. Current Working Directory (CWD)6. System PATH; User PATH

“SAFE” Search Order

Page 9: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

9

Page 17PUBLIC OWASP Maribor, 8.12.2010

Causes For Not Finding DLLs in Primary Locations

1. Programmer checks for local capabilities by trying to load a library

2. Some DLLs are present on OS1 but not on OS2 (dwmapi.dll)3. Custom/partial installs4. Backward compatibility5. Forward compatibility6. Application written so that it finds its binaries in PATH7. O/S Porting (loading “linuxlib.so.1” on Windows)8. Assumptions about installed components9. Incomplete uninstalls10.... Closed-Source

3rd Party ComponentsClosed-Source

3rd Party Components

Page 18PUBLIC OWASP Maribor, 8.12.2010

Binary Planting Attacks

Page 10: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

10

Page 19PUBLIC OWASP Maribor, 8.12.2010

3-Step Attack Scenario

1... Plant a malicious DLL

2... Set CWD to location of the DLL

3... Wait

Page 20PUBLIC OWASP Maribor, 8.12.2010

Setting The Current Working Directory

1. Double-clicking a file in Explorer2. File Open, File Save dialogs3. Last open/save location4. cmd.exe: cd command5. File explorers6. CreateProcess, ShellExecute7. New process inherits parent’s CWD8. Shortcuts9. ...

Page 11: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

11

Page 21PUBLIC OWASP Maribor, 8.12.2010

Internal Network Attack

File Server

Attacker User

1

2

3

Internal Corporate Network

File Server

Attacker User

1

2

3

Internal Corporate Network

Page 22PUBLIC OWASP Maribor, 8.12.2010

Local Goes Remote

Page 12: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

12

Page 23PUBLIC OWASP Maribor, 8.12.2010

Attacking From Internet – The WebDAV Magic

Page 24PUBLIC OWASP Maribor, 8.12.2010

Attack Vectors

1. Clicking on a link in browser2. Clicking on a link in e-mail3. Clicking on a link in IM message4. Planting a DLL on a file server5. Document and DLL in a ZIP archive6. Document and DLL on a USB stick7. Document and DLL on CD/DVD8. Local privilege escalation9. Advanced binary planting attacks

Page 13: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

13

Page 25PUBLIC OWASP Maribor, 8.12.2010

Binary Planting Demo

Page 26PUBLIC OWASP Maribor, 8.12.2010

Page 14: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

14

Page 27PUBLIC OWASP Maribor, 8.12.2010

Binary Planting Goes “EXE”

Page 28PUBLIC OWASP Maribor, 8.12.2010

Searching for Non-Absolute EXEs

1. The directory from which the application loaded2. Current Working Directory (CWD)3. C:\Windows\System324. C:\Windows\System5. C:\Windows6. System PATH; User PATH

CreateProcess(“SomeApp.exe”)

Page 15: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

15

Page 29PUBLIC OWASP Maribor, 8.12.2010

Searching for Non-Absolute EXEs

The directory from which the application loaded1. Current Working Directory (CWD)2. C:\Windows\System323. C:\Windows\System4. C:\Windows5. System PATH; User PATH

ShellExecute(“SomeApp.exe”)

Page 30PUBLIC OWASP Maribor, 8.12.2010

Searching for Non-Absolute EXEs

The directory from which the application loaded1. Current Working Directory (CWD)2. C:\Windows\System32

C:\Windows\System3. C:\Windows4. System PATH; User PATH

_spawn*p* and _exec*p*

Page 16: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

16

Page 31PUBLIC OWASP Maribor, 8.12.2010

Our Research

Page 32PUBLIC OWASP Maribor, 8.12.2010

Research Summary

Inspected 200+ Windows applicationsAt least one exploitable Binary Planting issue

in almost every one!(And we barely scratched the surface)

Recorded 520+ Binary Planting issuesTool for detecting Binary Planting vulnerabilities

GUI, monitoring processesAutomated exploitationAbility to directly debug vulnerable code

Page 17: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

17

Page 33PUBLIC OWASP Maribor, 8.12.2010

ACROS Binary Planting Detector

Page 34PUBLIC OWASP Maribor, 8.12.2010

Score – DLL and EXE Plantings

400+

120+

Page 18: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

18

Page 35PUBLIC OWASP Maribor, 8.12.2010

How Many Bugs?!?

XP ~1340m, Vista ~400m, Windows 7 ~150mApprox. 11.000 times the number of bicycles in

BeijingHundreds of BP bugs on every Windows computerTens of thousands of ways to break into any bank... or competitor’s network... or government agency... or nuclear facility in Iran

100.000.000.000

Page 36PUBLIC OWASP Maribor, 8.12.2010

Affected VendorsMicrosoft

AppleGoogleVMware

IBMSiemensMozillaAdobeAvast

AutodeskSophosPGP ...

... ~100 at Secunia

...100+ from our research

Page 19: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

19

Page 37PUBLIC OWASP Maribor, 8.12.2010

What Can You Do?

Page 38PUBLIC OWASP Maribor, 8.12.2010

APPLY: Recommendations for Developers

• Use absolute paths to libraries and executables• Don’t make “let’s see if it’s there” LoadLibrary* calls• Don’t plan on finding your DLL/EXE

in CWD or PATH• Set CWD to a safe location at startup• Use SetDllDirectory(“”) at startup• Don’t use SearchPath function for locating DLLs• Check your product with Process Monitor or another tool• Test with CWDIllegalInDllSearch hotfix set to "max". • Do this for all modules of your product!

http://www.binaryplanting.com/guidelinesDevelopers.htm

Page 20: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

20

Page 39PUBLIC OWASP Maribor, 8.12.2010

APPLY: Recommendations for Administrators

• Install Microsoft’s Hotfix, remember to configure it• Disable “Web Client” service• Windows Software Restriction Policy,

Windows AppLocker (DLL)• Use a personal firewall with process and connection

blocking• Block outbound SMB on corporate firewall• Block outbound WebDAV on corporate firewall• Limit internal SMB, WebDAV traffic• Restrict write access on file repositories

to prevent planting

Page 40PUBLIC OWASP Maribor, 8.12.2010

APPLY: Recommendations for Users

• Be careful when using USB sticks, CDs,DVDs from unknown sources

• Think before double-clicking on anything presented to you

• If in doubt, transfer the data file (alone)to local drive and open it

• Alert your administrators about binary planting

Page 21: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

21

Page 41PUBLIC OWASP Maribor, 8.12.2010

Resources

www.binaryplanting.comblog.acrossecurity.com

http://support.microsoft.com/kb/2264107http://blog.metasploit.com/2010/08/exploiting-dll-hijacking-flaws.html

http://blog.metasploit.com/2010/08/better-faster-stronger.htmlhttp://securityxploded.com/dllhijackauditor.php

http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

http://secunia.com/advisories/windows_insecure_library_loading/

Google “binary planting”, “dll hijacking”, “dll preloading”

Page 42PUBLIC OWASP Maribor, 8.12.2010

Public Binary Planting Tools

DLLHijackAuditKit

Page 22: Remote Binary Planting - OWASP · 2010. 12. 8. · 2005 “DLL Spoofing in Windows” paper (local attack) 2008 David LeBlanc: “DLL Preloading Attacks” article May 2009 Acros

22

Page 43PUBLIC OWASP Maribor, 8.12.2010

www.binaryplanting.com/test.htm

Page 44PUBLIC OWASP Maribor, 8.12.2010

The Ultimate Solution: Eliminating CWD From The Game