37
Virtual Private Networks Chester Rebeiro IIT Madras

Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

1

VirtualPrivateNetworks

ChesterRebeiroIITMadras

Page 2: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

2

PrivateNetworks

2

PhysicallydisconnectedfromtheoutsideInternet.Threeproperties:•  UsersAuthenticated.Usersareauthorizedandtheiridentitiesverified.•  ContentProtected.

Communicationwithintheprivatenetworkcannotbesniffedfromoutside.cablesarephysicallysecured

•  IntegrityPreserved.Nobodyfromoutsidethenetworkcanspoof

Page 3: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

3

VirtualPrivateNetworks

3

Abletoachieve:UsersAuthentication,ContentProtection,andIntegrityPreservedwithoutbeingphysicallylocated

Internet

Page 4: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

4

VirtualPrivateNetworks

4

Anyattempttodirectlyconnecttoacomputerinsidetheprivatenetworkwillbestoppedbythefirewall.Moreover,theIPaddressmaynotbevalid.

InternetFirewall

client

Page 5: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

5

VirtualPrivateNetworks

5

VPNServer:exposedtotheoutsidenetwork.OutsidecomputerswillbeauthenticatedbytheVPNserver.Onceauthenticated,asecurechannelisestablishedbetweentheVPNserverandclient,sopacketsareencryptedandintegritypreserved.

InternetFirewall

VPNServer

Client

Page 6: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

6

VirtualPrivateNetworks

6

OnlywaytoconnecttoasystemintheprivatenetworkisviatheVPNserver.NeedstobeTransparent.TheVPNclientshouldbeignorantthatitisaremoteclient.

InternetFirewall

VPNServer

Client

Page 7: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

7

VPNvsApplicationLevelSecurity•  Thisisdifferentfromaregularapplicationsecurity,whereTLS

canbeused.–  IPspoofing/sniffingcanbedone–  ClientneedstoopenandinitiateaTLSconnection,thusno

transparency

•  ForVPN,theIPheadersneedtobeencrypted–  However,trafficcannotberouted

7

Page 8: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

8

IPTunneling

8

Firewall

VPNClient

IPPacket

IPPacketIPhead

Encryptedpacket

EncryptedpacketIPhead

forthedestination

fortheVPNserver

Destination

VPNServer

Page 9: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

9

IPTunneling

9

Firewall

VPNClient

IPPacket

IPPacketIPhead

Encryptedpacket

EncryptedpacketIPhead

forthedestination

fortheVPNserver

Destination

toVPNSer

ver

EncryptedpacketIPhead

IPPacketIPheaddecrypt

Forwardtodestination

Page 10: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

10

IPTunneling•  TwowaysofachievingIPTunneling

–  IPSectunneling:usesIPSecprotocolwhichoperatesattheIPlayerandhasatunnelingmode

–  TheentireIPpacketisencapsulatedintoanewIPpacketwithanewheaderadded

–  Doneatthekernellevel

10

Page 11: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

11

IPTunneling•  TwowaysofachievingIPTunneling

–  TLStunneling:usesTLSlibraryattheapplicationlayertoachievetunneling

–  TheentireIPpacketisencapsulatedintoanewTCP/UDPpacketwithanewheaderadded

–  Doneattheapplicationlevel

11

Page 12: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

12

AnOverviewofHowTLS/SSLVPNWorksThisisjustanormalTCPorUDPbasedSSLconnection

PrimarySiteSatelliteSite

Page 13: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

13

AnOverviewofHowTLS/SSLVPNWorks

1.MutualauthenticationusingPKC,passwordauthentication

Page 14: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

14

AnOverviewofHowTLS/SSLVPNWorks2.Routing

Anypacketto10.0.8.xwillberoutedtotheVPNclient

Anypacketto10.0.7.xwillberoutedtotheVPNserver

Page 15: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

15

AnOverviewofHowTLS/SSLVPNWorks

NeedstoencapsulatetheframereceivedinaTLSpacketanddirectedtotheVPNserver.Needstobedoneintheapplicationlayer.Noteasilyachieved.Promiscuousmode,Rawpackets,filteringAlternatively:VirtualNetworkCards.

Page 16: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

16

VirtualNetworkCards•  Mostoperatingsystemshavetwotypesofnetworkinterfaces:

–  Physical:CorrespondstothephysicalNetworkInterfaceCard(NIC)–  Virtual:Itisavirtualizedrepresentationofcomputernetworkinterfacesthatmayormaynot

corresponddirectlytotheNICcard.Example:loopbackdevice

•  TUNVirtualInterface–  WorkatOSIlayer3orIPlevel–  SendinganypackettoTUNwillresultinthepacketbeingdeliveredtouserspaceprogram

•  TAPVirtualInterfaces–  WorkatOSIlayer2orEthernetlevel–  Usedforprovidingvirtualnetworkadaptersformultipleguestmachinesconnectingtoa

physicaldeviceofthehostmachine

16

Page 17: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

17

TUN/TAPInterfaces

17

SocketInterface

Page 18: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

18

CreatingaTUNInterface

18

TheflagIFF_TUNspecifiesthatwearecreatingaTUNinterface

RegisteraTUNdevicewiththekernel

NeedsCAP_NET_ADMIN

Page 19: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

19

ConfiguretheTUNInterface

FindtheTUNinterface

Page 20: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

20

ConfiguretheTUNInterface

AssignanIPaddresstotheTUNinterfaceandbringitup

Page 21: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

21

SetUPtheRouting

Routingpacketstothetunnel

Page 22: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

22

SetuptheRouting

Packetstothisdestinationshouldberoutedtothetun0interface,i.e.,theyshouldgothroughthetunnel.

Allothertrafficwillberoutedtothisinterface,i.e.,theywillnotgothroughthetunnel

Page 23: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

23

PingtotheTUNinterface

23

Page 24: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

24

ReadingFromTUNInterface

Wedidanexperimentbysendingapingpacketto10.0.8.32.ThepacketwassenttotheTUNinterfaceandthentoourprogram.Weuse“xxd”toreadfromtheinterfaceandconverttheintohexdump.

IPHeade

r

Page 25: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

25

WritingToTUNInterface

•  WecanwritedatatoTUNinterfaces.•  Wecancreateavalidpacketusingthesame“xxd”command.•  Copy-pastethexxdoutputfromthepreviousslideintoafile

called“hexfile”andrun“xxd–rhexfile>packetfile”.•  Nowwewritethepacketfiletotheinterface:•  WeshouldbeabletoobservethepacketusingWireshark.

Page 26: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

26

EstablishaTransport-LayerTunnel

•  AtunnelisjustaTLS/SSLconnection.•  Twoapplications(VPNclientandserverapplications)just

establishaTLS/SSLconnectionbetweenthemselves.•  TrafficinsideareprotectedbyTLS/SSL•  WhatmakesthisTLS/SSLconnectionatunnel?

–  ThepayloadsinsideareIPpackets–  ThatiswhyitiscalledIPtunnel

Page 27: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

27

HowtoSend/ReceivePacketsviaTunnelSendingapacketviathetunnel•  GetanIPpacketfromtheTUNinterface•  Encryptit(alsoaddMAC)•  Senditasapayloadtotheotherendofthe

tunnel

Receivingapacketfromthetunnel•  Getapayloadfromthetunnel•  Decryptitandverifyitsintegrity•  Wegettheactualpacket•  WritethepackettotheTUNinterface

Page 28: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

28

MonitoringBothInterfaces

•  Eachtunnelapplicationhastwointerfaces:socketandTUN

•  Needtomonitorboth•  Forwardpacketsbetween

thesetwointerfaces

Page 29: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

29

Implementation(Monitoringthe2Interfaces)

select()willbeblockeduntiloneoftheinterfaceshasdata.

Page 30: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

30

Implementation(TUNàSocket)

Note:theencryptionstepisomittedfromthecode(forthesakeofsimplicity)

Page 31: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

31

Implementation(SocketàTUN)

Note:thedecryptionstepisomittedfromthecode(forthesakeofsimplicity)

Page 32: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

32

BypassingFirewallsusingVPN

Page 33: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

33BypassingFirewallusingVPN:theMainIdea

•  SendourFacebook-boundpacketstotheTUNinterfacetowardsVPNserver•  VPNserverwillreleaseourFacebook-boundpacketstotheInternet•  Facebook’sreplypacketswillberoutedtotheVPNserver(question:why)•  VPNserversendsthereplypacketsbacktousviathetunnel

Page 34: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

34

Experiment:NetworkSetup

Page 35: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

35

•  SetupfirewalltoblockUserfromaccessingFacebook•  WerunthefollowingcommandtogetthelistofIPprefixesownedbyFacebook:

•  WecanalsogetIPaddressesreturnedbyFacebook’sDNSserverbyrunningthefollowingcommand(thisIPaddresscanchange):dig www.facebook.com

SettingUPFirewall

Page 36: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

36

BlockingFacebook

Facebookbecomesunreachable

OneoftheIPprefixesbelongtoFacebook

Page 37: Virtual Private Networkschester/courses/19e_ns/slides/10_VPN.pdf · An Overview of How TLS/SSL VPN Works Needs to encapsulate the frame received in a TLS packet and directed to the

37

BypassingtheFirewall•  Weaddaroutingentrytotheusermachine,changingtheroute

forallFacebooktraffic.Insteadofgoingthrougheth6,weusetheTUNinterface:

•  TheFacebook-boundpacketsaregoingthroughourtunnel.•  TheFacebook-boundpacketsarehiddeninsideapacketgoingto

theVPNserver,soitdoesnotgetblocked.•  VPNserverwillreleasethepackettotheInternet.•  RepliesfromFacebookwillcomebacktoVPNserver,whichwill

forwarditbacktousviathetunnel.