flashback sandbox paradox the windows - nullcon · 2019-08-27 · chromium windows sandbox owner...

74
nullcon International Security Conference Goa 2019 the neXt security thing! https://nullcon.net Nullcon 2019 James Forshaw @tiraniddo The Windows Sandbox Paradox Flashback 1

Upload: others

Post on 05-Aug-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Nullcon 2019James Forshaw @tiraniddo

The Windows Sandbox Paradox

Flashback

1

Page 2: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Obligatory Background Slide

● Founder Member of Google’s Project Zero● 10+ Years of Windows Security Research● Logical vulnerability specialist● Chromium Windows Sandbox Owner● “Attacking Network Protocols” Author● @tiraniddo on Twitter.

2

Page 3: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

What I’m Going to Talk About

3

Sandboxed Process

User ApplicationsSystem Services

Kernel Services Device Drivers

Prevent RCE

Pre

ven

t Eo

P

Page 4: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sandboxing Requirement #1

● Easy to get in, hard to get out

http://upload.wikimedia.org/wikipedia/commons/d/d9/GravityPotential.jpg

4

Page 5: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sandboxing Requirement #2

● Protects the user’s data from disclosure

https://openclipart.org/detail/190821/cles-de-serrure---lock-keys-by-enolynn-190821

5

Page 6: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sandboxing Requirement #3

● Work within the limits of the OS

http://upload.wikimedia.org/wikipedia/commons/8/8b/MUTCD_R2-1.svg

6

Page 7: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sandboxing Requirement #4

● Sandboxed application is usable

http://pixabay.com/p-305189/

7

Page 8: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Resource Security Descriptor

Owner of Secured

Resource

Mandatory Integrity Label

Discretionary Access Control List

(DACL)

8

Page 9: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Access Tokens

User Security Identifier

Groups

Privileges

Mandatory Label

9

Page 10: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Access Check

Deny AccessGrant Access

IL Check

Owner Check

DACL Check

Desired Access: e.g. Read and Write

10

Page 11: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sandbox Token

Sandbox Access Check

Deny AccessGrant Access

IL Check

Owner Check

DACL Check

Desired Access: e.g. Read and Write

Sandbox SID

Owner Check

Sandbox SID

DACL Check

11

Page 12: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Typical User-Mode Approach

Sandboxed Process

Low-PrivilegeNormal-Privilege

Broker ProcessIPC Services

ResourcesFiles,

Registry etc.

Restricted Access

12

Page 13: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

The Windows Sandbox Paradox

13

Page 14: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Welcome to 2019

14

Page 15: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Introducing Windows 10

15

Page 16: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

You’re Going to Update

16

Page 17: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Time to Release is ShorterD

ays

to n

ext v

ersi

on

17

Page 18: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Microsoft Edge

18

Page 19: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Path Traversal Security

\Session\0\BaseNamedObjects\ABC

\Session

\ABC

\0

\BaseNamedObjects

Parse Path

Security Check

Security Check Security

Check

19

Page 20: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Traverse Access

Object Directory has specific “Traverse” access.

20

Page 21: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

The Problem with Privileges

Weird name, but used to bypass traversal checks

21

Page 22: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Remove Privilege?

NTSTATUS ObpLookupObjectName( OBJECT_ATTRIBUTES ObjectAttributes, PACCESS_STATE AccessState) { // ... if (AccessMode == KernelMode || AccessState->Flags & TOKEN_HAS_TRAVERSE_PRIVILEGE || ObpCheckTraverseAccess(Object, AccessState)) { // Continue traversal. } else { return STATUS_OBJECT_NAME_NOT_FOUND; }}

Check for privilege

Do full traverse check

22

Page 23: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Full Traverse CheckBOOLEAN ObpCheckTraverseAccess( PVOID Object, PACCESS_STATE AccessState) {

PSECURITY_DESCRIPTOR SecurityDescriptor; ObpGetObjectSecurity(Object, &SecurityDescriptor);

if (SeFastTraverseCheck(SecurityDescriptor, AccessState, DIRECTORY_TRAVERSE)) { return TRUE; } else { return SeAccessCheck( SecurityDescriptor, &AccessState->SubjectSecurityContext, DIRECTORY_TRAVERSE); }}

Try “Fast” Check?

23

Page 24: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Fast Traverse CheckBOOLEAN SeFastTraverseCheck( PSECURITY_DESCRIPTOR SecurityDescriptor, PACCESS_STATE AccessState, ACCESS_MASK DesiredAccess) { if (AccessState->Flags & TOKEN_IS_RESTRICTED) { return FALSE; } PACL dacl = SecurityDescriptor->Dacl; for(PACE ace = GetAce(dacl); ace; ace = GetAce(dacl)) { if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE && ace->Mask & DesiredAccess && RtlEqualSid(SeWorldSid, ace->SidStart)) { return TRUE; } } return FALSE:}

If a “Restricted” Token return immediately

Otherwise if ACL has World SID ACE then allow

24

Page 25: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Fast Traverse CheckBOOLEAN SeFastTraverseCheck( PSECURITY_DESCRIPTOR SecurityDescriptor, PACCESS_STATE AccessState, ACCESS_MASK DesiredAccess) { if (AccessState->Flags & TOKEN_IS_RESTRICTED) { return FALSE; } PACL dacl = SecurityDescriptor->Dacl; for(PACE ace = GetAce(dacl); ace; ace = GetAce(dacl)) { if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE && ace->Mask & DesiredAccess && RtlEqualSid(SeWorldSid, ace->SidStart)) { return TRUE; } } return FALSE:}

If a “Restricted” Token return immediately

Otherwise if ACL has World SID ACE then allow

25

Page 26: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Reporting the Problem

https://bugs.chromium.org/p/project-zero/issues/detail?id=206

26

Page 27: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Fixed in Windows 10NTSTATUS SepCreateAccessStateFromSubjectContext( SECURITY_SUBJECT_CONTEXT *SubjectContext, PACCESS_STATE AccessState) { AccessState->SubjectSecurityContext = *SubjectContext; PTOKEN Token = SeQuerySubjectContextToken(SubjectContext); DWORD Flags = 0; if (Token->Privileges.Present & TRAVERSE_PRIVILEGE) Flags = TOKEN_HAS_TRAVERSE_PRIVILEGE;

Flags |= Token->TokenFlags & TOKEN_IS_RESTRICTED; AccessState->Flags = Flags; // ...}

Added Flag

27

Page 28: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

AC Device Attack SurfaceBOOLEAN IopDoFullTraverseCheck(PDEVICE_OBJECT Device, PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext) { if (Device->Characteristics & (FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL | FILE_DEVICE_SECURE_OPEN) == FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL) { return FALSE; } BOOLEAN IsAppContainer; SeIsAppContainerOrIdentifyLevelContext(SubjectSecurityContext, &IsAppContainer); return IsAppContainer;}

If AC Traversal flag in device then allow

Only allow if not AC.

28

Page 29: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Generic AC Capabilities

Fixed capabilities, introduced in Windows 8

Generic capabilities, introduced in Windows 10

29

Page 30: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Capability String to SID

MyFantasticCapability

myfantasticcapability

SHA256

S-1-15-3-%d-%d-%d-%d-...

BOOL DeriveCapabilitySidsFromName(LPWSTR CapName, PSID **Sids)

Arbitrary name

Lower Case

Hash Unicode String

Set RIDs to 32 bit Hash Values

30

Page 31: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

All Application Packages

BOOLEAN SepMatchPackage(PTOKEN Token, PSID Sid) { // ALL_APPLICATION_PACKAGES is S-1-15-2-1 if ( Sid->SubAuthority[0] == 2 && Sid->SubAuthorityCount == 2 ) { if (Sid->SubAuthority[1] == 1) return TRUE; } else { return RtlEqualSid(Token->Package, Sid); }}

Hardcoded Group Check if an App Container

31

Page 32: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Low Privilege App ContainerBOOLEAN SepMatchPackage(PTOKEN Token, PSID Sid) { if ( Sid->SubAuthority[0] == 2 && Sid->SubAuthorityCount == 2 ) { if (Sid->SubAuthority[1] == 1 && SepCanTokenMatchAllPackageSid(Token)) return TRUE; // ALL_RESTRICTED_APPLICATION_PACKAGES is S-1-15-2-2 if (Sid->SubAuthority[1] == 2) return TRUE; } else { return RtlEqualSid(Token->Package, Sid); }}

BOOLEAN SepCanTokenMatchAllPackageSid(PTOKEN Token) { int Policy; AuthzBasepQuerySecurityAttributeAndValues( L"WIN://NOALLAPPPKG", &Policy) return Policy == 0;}

32

Page 33: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Child App Containers

S-1-15-2-PARENT-RIDS S-1-15-2-PARENT-RIDS-CHILD-RIDS

33

Writable

Read-Only

Page 34: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

History of Symbolic Links

Windows NT 3.1 - July 27 1993Object Manager Symbolic LinksRegistry Key Symbolic Links

Windows 2000 - Feb 17 2000NTFS Mount Points and Directory Junctions

Windows Vista - Nov 30 2006NTFS Symbolic Links

34

Page 35: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

History of Symbolic Links

Windows NT 3.1 - July 27 1993Object Manager Symbolic LinksRegistry Key Symbolic Links

Windows 2000 - Feb 17 2000NTFS Mount Points and Directory Junctions

Windows Vista - Nov 30 2006NTFS Symbolic Links

Windows 10 - Jun 29 2015Banned in Sandboxes

35

Page 36: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

RtlIsSandboxedToken● Introduced in Windows 10 but backported

to Windows 7BOOLEAN RtlIsSandboxedToken() { SECURITY_SUBJECT_CONTEXT SecurityContext; SeCaptureSubjectContext(&SecurityContext); return !SeAccessCheck( SeMediumDaclSd, SubjectSecurityContext, READ_CONTROL);}

Must pass security check

36

Page 37: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Registry Key Symbolic LinksNTSTATUS CmpCheckCreateAccess(...) { BOOLEAN AccessGranted = SeAccessCheck(...); if (AccessGranted && CreateOptions & REG_OPTION_CREATE_LINK &&

RtlIsSandboxedToken()) { return STATUS_ACCESS_DENIED; }}

NTSTATUS CmSetValueKey(...) { if(Type == REG_LINK && RtlEqualUnicodeString(&CmSymbolicLinkValueName, ValueName, TRUE) && RtlIsSandboxedToken()) return STATUS_ACCESS_DENIED;}

Hard Ban!

37

Page 38: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Blocking NTFS Mount Points

NTSTATUS IopXxxControlFile(...) {if (ControlCode == FSCTL_SET_REPARSE_POINT && RtlIsSandboxedToken()) {

if (buffer.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { InitializeObjectAttributes(&ObjAttr, buffer.PathBuffer); status = ZwOpenFile(&FileHandle, FILE_GENERIC_WRITE,

&ObjAttr, ..., FILE_DIRECTORY_FILE); if (status < 0) return status; // Continue. } }}

Checks target is a directory and writable

38

Page 39: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Bypassing the Mitigation

https://bugs.chromium.org/p/project-zero/issues/detail?id=486

39

Page 40: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Bypassing the Mitigation

https://bugs.chromium.org/p/project-zero/issues/detail?id=486

NTSTATUS NtSetInformationProcess(...) { // ...

case ProcessDeviceMap: HANDLE hDir = *(HANDLE*)Data; if (RtlIsSandboxedToken()) return STATUS_ACCESS_DENIED; return ObSetDeviceMap(ProcessObject, hDir);

// ...}

40

Page 41: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Use Hardlinks

https://bugs.chromium.org/p/project-zero/issues/detail?id=531

41

Page 42: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Use Hardlinks

https://bugs.chromium.org/p/project-zero/issues/detail?id=531

NTSTATUS NtSetInformationFile(...) { case FileLinkInformation: ACCESS_MASK RequiredAccess = 0; if(RtlIsSandboxedToken()) { RequiredAccess |= FILE_WRITE_ATTRIBUTES; } ObReferenceObjectByHandle(FileHandle, RequiredAccess);}

42

Page 43: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Setting an Mitigation Policy

43

Policy Type

Accompanying Data

Page 44: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Available PoliciesPolicy Supported Win8.1 Update 2 Supported Win10 TH2

ProcessDEPPolicy Yes Yes

ProcessASLRPolicy Yes Yes

ProcessDynamicCodePolicy Yes Yes

ProcessStrictHandleCheckPolicy Yes Yes

ProcessSystemCallDisablePolicy Yes Yes

ProcessMitigationOptionsMask Invalid Invalid

ProcessExtensionPointDisablePolicy Yes Yes

ProcessControlFlowGuardPolicy Invalid Invalid

ProcessSignaturePolicy Yes* Yes

ProcessFontDisablePolicy No Yes

ProcessImageLoadPolicy No Yes

* Not supported through SetProcessMitigationPolicy

44

Page 45: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Kernel Attack Surface

~400 Syscalls ~1000 WIN3K

45

Page 46: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

WIN32K System Call Disable

~400 Syscalls ~0 WIN32K

46

Page 47: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

WIN32K System Call Filter

~400 Syscalls ~50 WIN32K

47

Page 48: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Dynamic Code Policy

struct PROCESS_MITIGATION_DYNAMIC_CODE_POLICY {DWORD ProhibitDynamicCode : 1;DWORD AllowThreadOptOut : 1;DWORD AllowRemoteDowngrade : 1;DWORD AuditProhibitDynamicCode : 1;

};

Called Arbitrary Code Guard (ACG) by Microsoft

Disables:● VirtualAlloc with PAGE_EXECUTE_*● MapViewOfFile with FILE_MAP_EXECUTE● VirtualProtect with PAGE_EXECUTE_*

48

Page 49: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Can Still JIT with a Helper

ACG Sandbox Process

JIT Server Process

void InjectExecutableCode(DWORD dwPid, PBYTE pData, SIZE_T nSize) { HANDLE hProcess = OpenProcess(dwPid, PROCESS_VM_WRITE | PROCESS_VM_OPERATION); LPVOID pMem = VirtualAllocEx(hProcess, PAGE_EXECUTE_READWRITE, nSize); WriteProcessMemory(hProcess, pMem, pData, nSize);}

New Executable

Memory

VirtualAllocEx

Create With Dynamic Code Mitigation

49

Page 50: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Binary Signature Policy

struct PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY{

DWORD MicrosoftSignedOnly : 1;DWORD StoreSignedOnly : 1;DWORD MitigationOptIn : 1;DWORD AuditMicrosoftSignedOnly : 1;DWORD AuditStoreSignedOnly : 1;

};

Blocks unsigned or non-Microsoft Store signed DLLs.

Called Code Integrity Guard by Microsoft

50

Page 51: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Bypassable Mitigation

https://bugs.chromium.org/p/project-zero/issues/detail?id=1597

51

Page 52: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Image Load Policy

struct PROCESS_MITIGATION_IMAGE_LOAD_POLICY {

DWORD NoRemoteImages : 1;DWORD NoLowMandatoryLabelImages : 1;DWORD PreferSystem32Images : 1;DWORD AuditNoRemoteImages : 1;DWORD AuditNoLowMandatoryLabelImages : 1;

};

Disable DLL loading from UNC paths or with Low IL label.

52

Page 53: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Font Disable Policy

struct PROCESS_MITIGATION_FONT_DISABLE_POLICY {

DWORD DisableNonSystemFonts : 1;DWORD AuditNonSystemFontLoading : 1;DWORD ReservedFlags : 30;

};

Disable fonts loaded from memory or outside of %WINDIR%\Fonts

53

Page 54: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Font Mitigation Auditing

54

Page 55: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Bypassable Mitigation

https://bugs.chromium.org/p/project-zero/issues/detail?id=779

55

Page 56: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

User Mode Font Driver

56

Page 57: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Bugs Bugs Bugs

https://bugs.chromium.org/p/project-zero/issues/detail?id=468

57

Page 58: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

● No policies can be disabled once set in-process.

● However only a small subset of mitigations are inherited

Process Mitigations Inheritance

Policy Inherited

Dynamic Code No

System Call Disable Yes

Signature No

Font Disable No

Image Load Yes

58

Page 59: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Migrate to a New Process

Sandbox Process

59

Page 60: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Job Object

Restrict With Job Objects

Sandbox Process

Exceeds Job Process Limit

60

Page 61: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Job Object

Restrict With Job Objects

WMI ServiceWin32_Process::Create

Sandbox Process

61

Page 62: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Inside NtCreateUserProcessDWORD ChildProcessPolicyFlag = // From process attribute.BOOLEAN ChildProcessAllowed = TokenObject->TokenFlags & CHILD_PROCESS_RESTRICTED;if (!ChildProcessAllowed) { if (!ChildProcessPolicyFlag & PROCESS_CREATION_CHILD_PROCESS_OVERRIDE)

|| !SeSinglePrivilegeCheck(SeTcbPrivilege)) return STATUS_ACCESS_DENIED;

}

SepDuplicateToken(TokenObject, ..., &NewTokenObject);if (ChildProcessPolicyFlag & PROCESS_CREATION_CHILD_PROCESS_RESTRICTED) NewTokenObject->TokenFlags |= CHILD_PROCESS_RESTRICTED;

Block process with Token flag.

Set the flag on new Token

62

Page 63: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Effective Mitigation

WMI ServiceWin32_Process::Create

Sandbox Process

63

Page 64: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Except When It’s Not!

https://bugs.chromium.org/p/project-zero/issues/detail?id=1544

64

Page 65: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Logging for Mitigation

65

Page 66: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sharing Sections

Section Object

Main Process

Sandbox Process

Handle with FILE_MAP_WRITE

Access

Handle with FILE_MAP_READ

AccessDuplicateHandle

Kernel Mode

User Mode

b666 7055 7a53 cec5 0d95 2301 c7ba 46eb 7d89 2f22 3315 49b4 2afb a3ec4590 9c9d 9726 41df 8c64 b282 51c67fbc 6079 9eaf c6aa 9127 ddac 184f

Writable Mapped Memory

b666 7055 7a53 cec5 0d95 2301 c7ba 46eb 7d89 2f22 3315 49b4 2afb a3ec4590 9c9d 9726 41df 8c64 b282 51c67fbc 6079 9eaf c6aa 9127 ddac 184f

Read-Only Mapped Memory

Security Descriptor

\BaseNamedObjects\ABC

66

Page 67: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sharing Sections

Section Object

Main Process

Sandbox Process

Handle with FILE_MAP_WRITE

Access

Handle with FILE_MAP_READ

AccessDuplicateHandle

Kernel Mode

User Mode

Writable Mapped Memory

b666 7055 7a53 cec5 0d95 2301 c7ba 46eb 7d89 2f22 3315 49b4 2afb a3ec4590 9c9d 9726 41df 8c64 b282 51c67fbc 6079 9eaf c6aa 9127 ddac 184f

Read-Only Mapped Memory

Security Descriptor

\BaseNamedObjects\ABC

b666 7055 7a53 cec5 0d95 2301 c7ba 46eb 7d89 2f22 3315 49b4 2afb a3ec4590 9c9d 9726 41df 8c64 b282 51c67fbc 6079 9eaf c6aa 9127 ddac 184f

67

Page 68: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Sharing Sections

Section Object

Main Process

Sandbox Process

Handle with FILE_MAP_WRITE

Access

Handle with FILE_MAP_WRITE

AccessDuplicateHandle

Kernel Mode

User Mode

Writable Mapped Memory Writable Mapped Memory

Security Descriptor

\BaseNamedObjects\ABC

b666 7055 7a53 cec5 0d95 2301 c7ba 46eb 7d89 2f22 3315 49b4 2afb a3ec4590 9c9d 9726 41df 8c64 b282 51c67fbc 6079 9eaf c6aa 9127 ddac 184f

b666 7055 7a53 cec5 0d95 2301 c7ba 46eb 7d89 2f22 3315 49b4 2afb a3ec4590 9c9d 9726 41df 8c64 b282 51c67fbc 6079 9eaf c6aa 9127 ddac 184f

68

Page 69: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Name No Longer NeededNo Name - No SD

Specify SD to Create

69

Page 70: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Hyper-V Everywhere

● Windows Defender Application Guard● Windows Sandbox (coming soon!)

70

Page 71: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

PICO Process Available

71

Page 72: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

DEMOSAll of the Above

Page 73: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Conclusions

● Introduction of Windows 10 Had Effect on Sandboxes○ Edge gave Microsoft an excuse to innovate○ Fast release cycle meant new mitigations could ship

sooner● Still plenty of things I’d like to see

○ Better system call filtering, NTOS as well as WIN32K○ Improvements to Eliminate long standing warmup

problems.

73

Page 74: Flashback Sandbox Paradox The Windows - NULLCON · 2019-08-27 · Chromium Windows Sandbox Owner “Attacking Network Protocols” Author @tiraniddo on Twitter. 2. nullcon International

nullcon International Security Conference Goa 2019

the neXt security thing!https://nullcon.net

Thanks for ListeningQuestions?