33
A Para-virtualized Interface for Socket Calls Dimitri Stiliadis Founder/CEO – Aporeto @dstiliadis Stefano Stabellini Linux Kernel Lead - Aporeto @stabelinnist

XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Embed Size (px)

Citation preview

Page 1: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

APara-virtualizedInterfaceforSocketCalls

DimitriStiliadisFounder/CEO– Aporeto

@dstiliadis

StefanoStabelliniLinuxKernelLead- Aporeto

@stabelinnist

Page 2: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Overview

• Whyareweworkingonthis(andwhatitisnot)?• Usecases• Proposedprotocol• Performance• Demo

Page 3: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

SecurityThreatsinaContainerEnvironment

Namespaceconfiguration(capabilities,seccomp,SELinux,AppArmor

ContainerImagesandSources(validation,vulnerabilityanalysis)

Accesscontroltomanagementdaemon

Networking&Communications

TheKernelItself

SecuredefaultsBut..severalwaystomessitup

AddressedbyseveraltoolsImagescanning,signatures

Delegatedtomanagementsystems

Severaloptionsavailable

?

Page 4: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

SecurityRecommendations(fromNCCWhitePaper)• From“Understanding andHardeningLinuxContainers”byNCCGroup:

• Rununprivilegedcontainers(usernamespaces,rootcapability,dropping)• ApplyaMandatoryAccessControlsystem,suchasSELinux• Buildacustomkernelbinarywithasfewmodulesaspossible• Applysysctl hardening• Applydiskandstoragelimits• Controldeviceaccessandlimitresourceusagewithcgroups• Dropanycapabilitieswhichare notrequiredfortheapplicationwithinthecontainer• Usecustommountoptions to increasedefenseindepth• ApplyGRSecurity andPAXpatchestoLinux• ReduceLinuxattacksurfacewithSeccomp-bpf• Isolatecontainersbasedontrustandexposure• Logging,auditingandmonitoringisimportantforcontainerdeployment• Usehardwarevirtualizationalongapplicationtrustzones

Page 5: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

It’sComplicated

PicturefromDonNorman’stalk“LivingwithComplexity”

Page 6: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

SecurityRisks- ”TheKernelItself”

KernelExploitDisablesSecurity

LinuxKernel

Apps/Docker

netfilterSeccomp/bfp

Apps/Docker

Attack

Page 7: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

AndtheKernelisnotFreeofBugs

http://www.cvedetails.com/product/47/Linux-Linux-Kernel.html?vendor_id=33

Page 8: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

TheAlternative:ContainersinVMs

Kernel

Root

Ring0

Ring3 Container

OSContainers

Container

HypervisorRoot

Ring0

Ring3

KernelKernel

Container Container

HWVirtualization

VirtualDev VirtualDev

VirtualDev VirtualDev

Isolation,significantI/OoverheadsDifferentOSbetweenHypervisorandGuests

DeviceAbstraction

Simplicity,limitedhardwareisolationSameKernelforallContainers

Page 9: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

TheVirtualizationOverhead:ExampleNetwork

HypervisorRoot

Ring0

Ring3

Kernel

Container

VirtualDev

VirtualDev

TCP/IPstack

NSBridge

Bridge

IPStack

Andofcourse,managingsecurityinmultiplekernels

Ring0

Ring3 Container

OSContainers

Container

Kernel

Dev

TCP/IPstack

NSBridge

HardwareVirtualization

Page 10: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

WhatWeReallyWant

ContainerPerformance

VirtualMachineIsolation ?

Page 11: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

WhatIfweThoughtofVirtualizationALittleDifferent?

HardwareVirtualizationAssumptions

HostandGuestOSaredifferentRunanyGuestonanyHost

VMmovesetc

OSVirtualizationAssumptions

AllGuestssharethesametype ofKernelAllGuestsareofthesametypeWedon’tcareaboutmoves

(DockerModel)

Page 12: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

SystemCallVirtualization

• Introduceproxykernel• Sameasrootkernel• Allowsmemorypagesre-use• Singlekerneltomanage

• Subsetofsyscalls deliveredtomachinekernel• Socket, file,time

• Majorityofsystemcallsrestrictedwithinsyscall proxy

Syscall KernelProxy

RootKernelRoot

Ring0

Ring3 Container Container

SyscallVirtualization

Unprotected

Proxied/TranslatedHypercall

Syscall KernelProxy

Page 13: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

ExampleImplementationInXen

Dom0App(Container)

XenPV Interface

VM

Syscallbackend

Syscallfrontend

PV CallsAll othersyscalls

LinuxDomUinternals

Page 14: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

WhyXen?

• Efficientpara-virtualizationinterface• Allowdeploymentsinbaremetalandcloud

• XenonGCP• (MorecomplexthoughtodoXen-on-Xen inAWSwithpara-virtualizedIO)

Page 15: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Example:NetworkAccess

• Translatesocketcallstohypercalls• Containeropensa“paravirtualizedsocket”insidethehostOS• UsesnativelyIPstackofhost• Securityandforwardingpoliciesappliedatthehost

Syscall KernelProxy

KernelRoot

Ring0

Ring3 Container Container

SyscallVirtualization

Syscall KernelProxy

Connect

Connect

10.1.1.5NIC

10.1.1.5

Page 16: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Example:NetworkAccesswithNamespaces

• Containernamespace createdatthehostasbefore

• Containerprocess is launchedinside aprotected VM

• ThroughSystemCallvirtualizationsystemcallsappliedtonamespacecontext

• Containergets IPaddressofnetworknamespace

• TransparenttoDockerandothercontainersystems

Syscall KernelProxy

Root

Ring0

Ring3 Container Container

SyscallVirtualization

Syscall KernelProxy

Connect

Connect

192.168.2.1

Bridge 192.168.2.1

Page 17: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

PVCallsfornetworking

PortsopenedinaVM,areopenedonthehost

Enablecross-domainsnetworknamespacesandSELinuxlabels

Zero-confnetworkinginVMs• noneedforabridgeindom0• workswithwireless networks,VPNs,anyotherspecial configurations inDom0

Page 18: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

FirstImplementation

• Designdocument• http://marc.info/?l=xen-devel&m=147033114613017

• Code

• First,simpleimplementationonXen• 1Commandring• Persocket:

• dataring• event ring

• Variableringdatasizesconfigurablepersocket• Supportedfunctions(socket,connect,release,bind,listen,accept,poll)• git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.gitpvcalls-5

Page 19: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

PVCallsBenchmarks

Xen4.7.0-rc3 Linuxv4.6-rc2Dom04vcpus,pinned,28GBRAMDomU4vcpus,pinned,4GBRAM

Page 20: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

App(Container)

LinuxDomU

Xen

POSIX

PV Interface

VM Dom0

Iperf-c127.0.0.1 Iperf-s

PVCalls

Page 21: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

PVCalls

Page 22: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

App(Container)

LinuxDomU

Xen

POSIX

PV Interface

VM Dom0

Iperf-s Iperf-c127.0.0.1

PVCalls

Page 23: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

PVCalls

Page 24: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

?!

PVCalls

Page 25: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Howisthatpossible?

Page 26: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Howisthatpossible?

Page 27: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

PVCalls

Page 28: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

And,youusesomethinglikethattoday(DockerforMacandVPNKit)

MacOSx

Root

Ring0

Ring3

Kernel

DockerforMac

VirtualDev

VirtualDev VirtualDev

The“simplistic”versionofthesyscall proxy

SocketProxy

Container Container

“VPNKit operatesbyreconstructingEthernettrafficfromtheVMandtranslatingitintotherelevantsocketAPIcallsonOSXorWindows.Thisallowsthehostapplicationtogeneratetrafficwithoutrequiringlow-levelEthernetbridgingsupport.”

Page 29: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

FirstImplementation

• Designdocument• http://marc.info/?l=xen-devel&m=147033114613017

• Code

• First,simpleimplementationonXen• 1Commandring• Persocket:

• dataring• event ring

• Variableringdatasizesconfigurablepersocket• Supportedfunctions(socket,connect,release,bind,listen,accept,poll)• git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.gitpvcalls-5

Page 30: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Extensions

• Mechanismisgenericandcanbeextendedtoothersystemcalls

• Co-processingofsystemcallsisalsopossible• Guestcanprocesssystemcallparametersandtranslate athypercall

• Resolvememoryreferences(pointers)• Resolves TOCTOU riskofsystemcallinterposition

• TimeofCheck/TimeofUse

• UsingN/N+1kernelversionscanreduceattacksurfacefarther

Page 31: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Demo1:PerformanceComparison

Kernel

Root

Ring0

Ring3 Container

Syscall Proxy

KernelRoot

Ring0

Ring3 Container Container

SyscallVirtualization

Syscall Proxy

Container

Nonoticeableperformancedifference

Page 32: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

Demo2:KernelExploit

Kernel

Root

Ring0

Ring3 Container

Docker

Container

Vulnerablecontainercrashesmachineandallothercontainers

Syscall Proxy

KernelRoot

Ring0

Ring3 Container Container

SyscallVirtualization

Syscall Proxy

VulnerablecontainercrashesitselfonlyAttackcontained

Page 33: XPDS16: A Paravirtualized Interface for Socket Syscalls - Dimitri Stiliadis, Aporeto

ThankYou!

Wearehiring!!

[email protected],[email protected]