64
Keeping Windows Secure

Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Keeping Windows Secure

Page 2: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Securing the “world’s computer”

5.7 Million 440

3600+1100

Page 3: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Windows for PCsFamiliar desktop experience

Broad hardware ecosystem

Desktop app compat

One Core OS Base OS

App and Device Platform

Runtimes and Frameworks

Windows on XBOXGaming Packages

Unique security model

Shared gaming experience

Windows on IOTLean core platform

Azure connected

Runtimes and Frameworks

Windows for …Form factor appropriate

shell experience

Device specific scenario

support

Page 4: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 5: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Threat Intelligence

Page 6: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 7: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 8: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 9: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Limitless data warehouse with unmatched time to insights

Page 10: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Limitless data warehouse with unmatched time to insights

Attack surface Raw # Diff from last OS

WinRT 731 +46

RPC 164 +33

COM servers 231 +15

Device drivers 142 +0

System calls 1737 +84

Attack Surface Requiring Action

Page 11: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Attack surface is identified

manually

Developer manually writes

test harness to exercise

coverage

Developer manually

integrates LibFuzzer or other

library

Fuzzing used to be a manual process

Page 12: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Instrumented guest-to-host

network protocol

communication channels

High risk native code self

contained parsers

200,000 iters/sec

72% code coverage

4 vulnerabilities

2 RCE

Page 13: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

easy

Page 14: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Limitless data warehouse with unmatched time to insights

Page 15: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

input = “bood”input = “baod”input = “badd”input = “bad!”

void top(char input[4])

{

int cnt = 0;

if (input[0] == ‘b’) cnt++;

if (input[1] == ‘a’) cnt++;

if (input[2] == ‘d’) cnt++;

if (input[3] == ‘!’) cnt++;

if (cnt >= 4) crash();

}

input = “good”

I0!=‘b’

I1!=‘a’

I2!=‘d’

I3!=‘!’

Path constraint:

good

goo!

bood

gaod

godd

→ I0=‘b’

→ I1=‘a’

→ I2=‘d’

→ I3=‘!’

Gen 1

baod

Gen 2

badd

Gen 3

bad!

Gen 4

Page 16: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

147Rules run at build

7+ Engines run

Most cost-effective place to find issues

In the Engineering SystemOn the Developers Desktop

Run complex analysis

without impact to

developer

300Rules run at build

12 Static Analysis frameworks

Page 17: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

OACR/PreFast

Semmle

Static Analysis bug filed

Official BuildGIT PR

Developer

using Azure DevOps Static Analysis BuildRelease

Readiness

OS Repo

56/24 2760

Page 18: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Source-Code Annotation Language within Windows

= // sizeof(*Header) == 16VulnerableFunction(

,, // Length = 2

& );...

* = -> ;

<<< SAL Annotated

CodeBug

The function() will return a buffer that's two bytes (Length = 2)

Header is a pointer to a 16 byte structure. So, accessing Header->Id may go OOB

SA

Function returns a buffer similarly to malloc()

SAL wasn't correctly expressing that before

Added this SAL annotation to constrain the return value: _At_(return, _Readable_bytes_(BytesNeeded))

Page 19: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

C/C++/SAL

Fully bound tree (FBT)

Source Code

C/C++ Compiler

Abstract syntax tree (AST)

AST Translator

PREfast Framework

Annotation Parsing (NMM); Reporting Infrastructure

C#

Intermediate

Representation

(IR)

MSIL

C# Compiler

Phoenix HIR

Phoenix

Control Flow Graph (CFG)

Esp Dataflow Analysis FrameworkAnalysis

Frameworks

PREfast Plug-ins

PREfixGlobal (cross-

Function) analysis

EspX EspC Goldmine NullPtr

Global Esp

Page 20: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 21: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 22: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 23: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Highest PriMed-High Pri

Medium PriLow Pri

5 billion 700+

11+ Community

Page 24: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Containerd (Kubernetes/Dockerd)

Hypervisor

Common Intercepts

VMX Intercepts

SVM Intercepts

Existing HyperCalls Dispatch ManagerInstruction Completion

Address Management

Kernel (Root Partition)

Intercept Handling VSMM

VID

Channel Manage

ment

KMCL

XPart

Winsock Provider

(HVsocket)

VMBUS

VMSwitch

VFP

Azure Storage

Disk Driver

VHDMP

VSP

vPCI

Virtual Machine Worker Process (VMWP.exe)

Instruction Emulator

Synth RDP

Chipset Speaker

Chipset RTC

VDEV

RDP Encoder

Input Manag

er

vPCI

Chipset Super IO

Synth Keyboard

Synth Mouse

Serial

StorageSynth

Mother Board

Network Synth

Debug Device

Dynamic Memory Video

Monitor

BIOS

Video Synth

Video S3

Chipset ISA BUS

Chipset PCI BUS

Chipset IO APIC

Chipset DMA

Chipset PowerManagement

Input I8042

Chipset PIT

Chipset PIC

Storage Floppy

Storage IDE Cont.

Storage VSMB

vTPM

Input HID

GPUP Device

Network Emulated

Storage Fibre

IC

Activation Component

Data Exchange

Guest Shutdown

Heartbeat

Volume Shadow

Copy

Time SyncRDV

PowerShell Direct Guest

StorVSPRPC

Provider (HVRPC)

Host Compute Service (VMCompute.exe)

HCS Bridge Relay [STDIO]

RemoteFX

(Synth3d)

WCIFS

FS

StoragePlan9FS

StoragevPMem

Battery Passthr

ough

VMGS

Windows Storage Driver

Kernel

HCSShim

LinuxC TAR/VHD

conversion API

VHDPMEM tool (vhdconvert.exe)

OSS Pmem Parsing

hvsocketcontrol

Vhd2 Parsing Library

Vhd2Parsing

VPMEMLoopback

VMBFS

FlexIOVCrashDump

New HyperCalls

ARM64

User-Mode

interface

NVMe Direct

NVMe Direct

MicroVM

IntegratedScheduler

3rd party devices

EIC

HCS Bridge

User-mode VMBus

Page 25: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Goal: Prevent remote code execution vulnerabilities in TLS 1.3

TLS underpins nearly all secure communication in Windows

Has access to highly sensitive private keys and hardware

Mature code base recently updated to support 1.3

Used by: IIS, SMB, RDP, SQL, AD, SMTP, IMAP, …

Page 26: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Initial setup of build and test environment

Identify how to debug or gain introspection

1

Test Environment

Page 27: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Identify security boundariesLots of documentation…

Focus on remote security boundary

Used existing web server and client to understand network

traffic flow in and out of LSASS

Begin getting hands-on with the codeCode search

Understand

2

Attack Surface

Page 28: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

2

Attack Surface

Page 29: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Complete solutions are hard, get a first pass up and

running

Rapid, inefficient fuzzing harness created and kicked

off

Shallow target coverage, but low cost

Allows us to test basic target understanding, proves

test lab works

3

Fuzzing Phase 1

Page 30: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Solving for completeness now

Target specific harness created

Distribute and scale solution to Azure

4

Fuzzing Phase 2

Page 31: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Optimization pass

Increase detection rate of vulnerabilities

Increase classes of vulnerabilities detected

5

Fuzzing Phase 3

Page 32: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Manual code review of difficult to fuzz or complex

areas

Leverage existing tooling

6

Static Analysis

Page 33: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Code coverage + state coverage + human sanity used to measure

completeness66.43%

Up-level the takeaways

7

Collecting Results

Page 34: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Ensure engagements result in long-term security benefits

Establish sustainable fuzzing model

8

Final Pass

Page 35: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

1 wormable RCE that would affect any product using TLS 1.3

Even the unweaponized PoC results in forced target reboot

8

Results

Page 36: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 37: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Platform

Page 38: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

ProductiveCrash bucketing, Code Coverage, Corpus Management

Full System EmulationA full system, deterministic snapshot fuzzing harness

ScalableScalable fuzzing locally and distributed

Security Research Platform

Page 39: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

1/100th Native Speed

Page 40: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

In July GPZ reported 5 MSRC cases related

to the PE file format.

Built PE Fuzzer on TKO

Results:

To achieve this with TKO it required

implementing a plugin that used the

breakpoint, mutate, generate, and inject

callbacks.

But first we needed a snapshot we could

load in TKO.

/// Plugin used to fuzz PE Files./// Other than the breakpoint set for the harness there is nothing/// PE specific about this.pub struct PeFuzz {

end_case_bp: u64,eel: Eel,ready: bool,

}

impl Plugin for PeFuzz {/// Initialize the plugin prior to usefn init(&mut self, franzia: &mut Franzia,rcself: Rc<RefCell<dyn Plugin>>) {

franzia.register_callback(CallbackType::Generate, rcself.clone());franzia.register_callback(CallbackType::Mutate, rcself.clone());franzia.register_callback(CallbackType::Inject, rcself.clone());franzia.register_callback(CallbackType::Breakpoint, rcself.clone());

// Set a fuzz case timeout after 100 million instructionsfranzia.fuzz_timeout(Some(100_000_000 * 1));

// Set breakpoint for end of test casefranzia.vm_mut().add_breakpoint(self.end_case_bp as usize);

}

Page 41: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

To get a snapshot into a fuzzable state we write a simple harness that uses a custom CPUID

which will create a bochs snapshot.

…int ignored_cpuid_result[4];__cpuid(ignored_cpuid_result, 0x7b3c3638);

op = NtCreateFile(&hFile, FILE_GENERIC_WRITE, &objAttribs, &ioStatusBlock, &largeInteger,FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SUPERSEDE, FILE_NON_DIRECTORY_FILE| FILE_SYNCHRONOUS_IO_ALERT, NULL, NULL);

op = NtWriteFile(hFile, NULL, NULL, NULL, &ioStatusBlock, *buf, size, NULL, NULL);if (op == STATUS_SUCCESS){

open_pe(out);}

Page 42: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

/// Create a new fuzz inputfn generate(&mut self, franzia: &mut Franzia, input: &mut Vec<u8>) {

input = self.eel.generate_pe(franzia);}

/// Mutate an existing inputfn mutate(&mut self, franzia: &mut Franzia, input: &mut Vec<u8>) {

// Nothing to doif input.len() == 0 {

return;}

self.eel.mutate(input, franzia);}

Page 43: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

/// Called when a user defined breakpoint is hit. It's up to a user/// to get the program counter to determine which breakpoint was hit./// This is only invoked due to breakpoints hit which were added with/// `franzia.vm_mut().add_breakpoint()`fn breakpoint(&mut self, franzia: &mut Franzia) {

let rip = franzia.vm().regs().rip();

if rip == self.end_case_bp {// call case donefranzia.queue_new_fuzz_case(ResetReason::EndCondition);

}}

Page 44: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 45: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 46: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 47: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

REDTEAM

Model real-world attacks

Model attacks based on ecosystem

analysis and threat intelligence

Evaluate the customer-promises

from an attack perspective

Provide data sets of detection-and-

response

Attack the full stack in production

configuration (software,

configuration, hardware, OEMs)

Identify security gaps

Measure Time-to-Compromise

(MTTC) / Pwnage (MTTP)

Identify invariant techniques for

mitigation

Simulate a real-world incident

response before it occurs (process,

owners, messaging)

Provide detection guidance for

Defenders

Demonstrate impact

Work with teams to Address issues

Design mitigations to drive up

MTTC/MTTP metrics

Enumerate business and legal risk

Show business value, priorities,

and investments needs with

demonstrable attacks

Assume Breach: An Inside Look at Cloud Service Provider Security - Russinovich

Page 48: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Attacker has modified RDP server on compromised host

Wants to pivot to internal network

Compromised Server

Internal Network Asset System Administrator

RDP Session

SMB, RDP, etc.

Compromised Server

Malware running inside isolated environment

WDAG, Hyper-V, Window Sandbox

RDP Server runs inside sandbox alongside malicious code

Sandbox Escape

Page 49: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

REDTEAM

13 Days 20 Days

33 Days

Findings

Initial findings included 13 vulnerabilities

CVE-2019-{1290, 1291, 0787, 0788, 1181, 1182, 1222, 1223, 1224,

1225, 1226}

Page 50: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Memory Write DejaBlue)

if pChopper->totalUncompressedByteCount

pChopper->totalUncompressedByteCount (8 * 1024);

m_reassembled

// snip …

memcpy m_reassembled pDecompressed cbDecompressed

Page 51: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Memory Read

uninitialized heap data

if ( 0 != pSndFormat->nAvgBytesPerSec ) {memcpy(pFmtCopy, pSndFormat, sizeof( *pSndFormat ));

}

Page 52: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

RDP Client

VTable Ptr

IVar – m_MyMemberVariable1 = 0x01

IVar – m_ptrMyMemberVariable2 = 0xdeadbeef

Fake CMemStream Object!

RdpGfxClientChannel::OnDataReceived

.rodata - vtables

RdpGfxClientChannel::SomeFunction

CMemStream::Write

IVar – m_streamPtr = 0x7ffabcdef

...

...

g_transportDLL

attacker.com\share\evil.dll

Copy data from first argument to m_streamPtr

Graphics Channel

LFH Full of Graphics Objects

Plugin Loader

Evil RDP Server

Evil Network Share

RDP Control Channel

GfxObj->OnDataReceived(packet,

LoadLibrary(g_transportDLL)

1

2

3

Page 53: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 54: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 55: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Silently initialize local arrays, scalars, structures to 0

Limited to kernel components built with MSVC

Kills stack uninitialized use and leaks

Already shipped in latest Windows

InitAll

Checks for static casts of objects to prevent illegal downcasts

Causes illegal casts to fast fail

Mitigates ~1/3 of reported type confusion cases

Code is feature complete, not yet shipped

CastGuard

Page 56: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

classpublicvirtual void void

protecteduint32_t

class publicpublicvirtual void void

void

mov eax, __vftable_A; Populate edx with vftablemov edx, [eax]; Calculate distancesub edx, ecx; Check within rangerol edx, 27cmp edx, 3ja _slow_path ; Jump to inter-DLL check

;; code for the bit map check (if emitted)

;; a->foo()call [eax]

Page 57: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

1/3 of all Access Control, and 1/2 of all Race Conditions found in the last 6 months

Distribution of root cause: 2015 to 6 months ago Distribution of root cause: last 6 months

Page 58: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Popularized by James Forshaw

and more recently highlighted by

SandboxEscaper

Class of issue stemming from trusting

redirection and/or file system TOCTOU

A highly privileged service interacts with a file

in a location where a lower privilege/integrity

user can perform redirection

Page 59: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Malory makes an IPC call to a service

Service impersonates and creates a file

Service closes its handle to the new file

Malory races to replace the file with a link

The service reverts to SYSTEM…

and deletes Malory’s targeted file

Page 60: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Mitigations coming in a future release

Hardlink mitigation

Junction mitigation

SYSTEM %TEMP% change

Page 61: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 62: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

Bug Fix Rate YoY

Bug fix rate is the percentage of security bugs that our team finds that are fixed by teams

Investments into better relationships with teams, better tools to find higher quality bugs and

generate repros for teams have driven fix rate to improved levels

150% increase in bugs being fixed

20192018

Page 63: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process
Page 64: Keeping Windows Secure€¦ · Channel Manage ment KMCL XPart Winsock Provider (HVsocket) VMBUS VMSwitch VFP Azure Storage Disk Driver VHDMP VSP vPCI Virtual Machine Worker Process

https://aka.ms/psvrjobs