SlideShare a Scribd company logo
1 of 43
Adam Wick @ QCon San Francisco, 2015
Tor in Haskell
and Other Unikernel Tricks
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/tor-haskell
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Presented at QCon San Francisco
www.qconsf.com
This combination is not crazy.
(In fact, it makes a lot of sense.)
© 2015 Galois, Inc.3 © 2015 Galois, Inc.3
Adam Wick @ QCon San Francisco, 2015
Built the Haskell Lightweight Virtual Machine (HaLVM)
Works for
(a unikernel)
Adam Wick
© 2015 Galois, Inc.4 © 2015 Galois, Inc.4
Use Case #3: Nimble
© 2015 Galois, Inc.5 © 2015 Galois, Inc.5
Use Case #3: Nimble
© 2015 Galois, Inc.6 © 2015 Galois, Inc.6
Use Case #3: Nimble + Massive
© 2015 Galois, Inc.7 © 2015 Galois, Inc.7
Why are Unikernels and Tor such a good idea?
Unikernels are fundamentally designed to be
Lightweight
Fast
Secure
More nodes for the same price, or
the same number of nodes for
less.
Fewer schedulers means lower
latency.
A much smaller OS stack means less
code to get wrong.
So We Did This
(And now I’m going to tell you about it.)
But First: Tor
© 2015 Galois, Inc.10 © 2015 Galois, Inc.10
: Anonymity Through Root Vegetables
Tor is an anonymous communication layer built on TLS that
prevents people from learning who you are interacting with over
the Internet.*
* Terms and conditions may apply.
© 2015 Galois, Inc.11 © 2015 Galois, Inc.11
Guarantees*:
1. For any single relay node, it is impossible to tell where you are in the chain.
2. The exit node cannot tell how many hops were before it.
3. The entrance node cannot tell how many hops are in front of it.
* Terms and conditions may apply.
© 2015 Galois, Inc.12 © 2015 Galois, Inc.12
Terms and Conditions May Apply
The security of Tor is dependent on:
1. The correctness of the protocol design.
2. The correctness of the protocol implementation.
3. Ensuring that there are enough nodes that no single entity
owns a sufficient percentage of nodes to have a top level view.
And Second: Haskell
© 2015 Galois, Inc.14 © 2015 Galois, Inc.14
It is also known for being popular with people that know more
category theory than is good for them, which has given it a certain
… reputation.
Haskell is a functional programming language:
fact :: Integer -> Integer map :: (a -> b) -> [a] -> [b]
fact 0 = 1 map _ [] = []
fact x = x * fact (x – 1) map f (x:r) = (f x) : map f r
It is mostly known for being lazy, pure, and strongly typed.
Very HelpfulHandyMeh
© 2015 Galois, Inc.15 © 2015 Galois, Inc.15
do -- "To authenticate the initiator, the responder MUST check the
-- following:
-- * The CERTS cell contains exactly one CerType 3 'AUTH'
-- certificate.
let authCert = exactlyOneAuth certs Nothing
authCert' = signedObject (getSigned authCert)
-- * The CERTS cell contains exactly one CerType 2 'ID'
-- certificate
let iidCert = exactlyOneId certs Nothing
iidCert' = signedObject (getSigned iidCert)
-- * Both certificates have validAfter and validUntil dates
-- that are not expired.
when (certExpired authCert' now) $ fail "Auth certificate expired."
when (certExpired iidCert' now) $ fail "Id certificate expired."
-- * The certified key in the AUTH certificate is a 1024-bit RSA
-- key.
unless (is1024BitRSAKey authCert) $
fail "Auth certificate key is the wrong size."
-- * The certified key in the ID certificate is a 1024-bit RSA
-- key.
unless (is1024BitRSAKey iidCert) $
fail "Identity certificate key is the wrong size."
-- * The auth certificate is correctly signed with the key in the
-- ID certificate.
unless (authCert `isSignedBy` iidCert') $
fail "Auth certificate not signed by identity cert."
© 2015 Galois, Inc.16 © 2015 Galois, Inc.16
I’m Not Here To Sell You Haskell, But:
Type Safety + Purity + Safe Data Structures + GC
=
Fewer bugs per LOC
=
Less security advisories per LOC
Unikernels
© 2015 Galois, Inc.18 © 2015 Galois, Inc.18
Unikernels are specialised, single address space machine images
constructed using library operating systems.
- Wikipedia
or
Unikernels : Virtual Machines :: Exokernels : Physical Machines
or
Unikernels are single-process programs compiled to run directly on
(usually virtual) hardware, rather than within a full-featured OS.
© 2015 Galois, Inc.19 © 2015 Galois, Inc.19
© 2015 Galois, Inc.20 © 2015 Galois, Inc.20
Lower operating costs
Faster response to events
Smaller attack surface
© 2015 Galois, Inc.21 © 2015 Galois, Inc.21
Containers and Unikernels
Unikernels: The next step in separation:
1. We started with single-task code.
2. Next, we separated some of our tasks into threads.
3. Next, we separated some of our threads into processes.
4. Next, we separated some of our processes into containers.
5. Now, we separated our critical containers into unikernels.
Each level provides additional separation properties, at the cost of
increased complexity in creating and reasoning about new code.
So: Tor + Haskell + Unikernels?
© 2015 Galois, Inc.23 © 2015 Galois, Inc.23
Terms and Conditions May Apply
The security of Tor is dependent on:
1. The correctness of the protocol design.
2. The correctness of the protocol implementation.
3. Ensuring that there are enough nodes that no single entity
owns a sufficient percentage of nodes to have a top level view.
Can’t really do much for this
one. Except that more
implementations means more
eyes on the specs.
Haskell limits memory issues,
type safety helps correctness.
Unikernels limit attack surface.
Unikernels limit resource
usage, which allows a lot more
relay nodes for the same cost.
Cool! How Did That Work?
© 2015 Galois, Inc.25 © 2015 Galois, Inc.25
So You Want To Build A Unikernel
There are five steps to building a Unikernel:
1. Don’t.
2. Test & Measure.
3. Do.
4. Test (Part II)
5. Deploy.
© 2015 Galois, Inc.26 © 2015 Galois, Inc.26
Step #1: Don’t Build a Unikernel
Building a unikernel adds a number of complications to the
development process (which is already complicated enough).
So start by building your application as you normally would, in a
language that supports unikernels. (In this case, Haskell.)
Build using your normal tools, libraries, and techniques, but:
1. Try to avoid local storage.
2. Try to minimize the number of libraries you pull in.
3. Stay away from libraries that link against C.
With Tor, I began by implementing the core
parsing and protocol code, sufficient to
anonymously look up a hostname.
To avoid a linking problem, I also ended up
writing my own zlib decompression library.
More on that later.
© 2015 Galois, Inc.27 © 2015 Galois, Inc.27
Step #2: Measure & Test
What is your application’s peak memory use?
Exactly how much space do you need for configuration files, etc.?
Does this space need to be writeable?
Then TEST, TEST, TEST.
Your goal is that in later steps, any bugs you find have to do with
the unikernel translation, not your application.
In measuring my work with Tor, I discovered
that the zlib library I’d written earlier was very
… silly ... with regard to memory use.
I wish I’d found that here.
© 2015 Galois, Inc.28 © 2015 Galois, Inc.28
Step #3: Do it.
Once it works well, and you know about its resource usage, now
it’s time to start converting it to a unikernel.
1. Some of your libraries won’t build, and you will either need
to fix or replace these. Predicting which ones is possible, but
requires some experience and internal knowledge of the
library.
2. Disks are expensive and slow; consider using ramdisks. For
many of our uses of unikernels, and Tor can be one of them, then
the only need for a disk is to pass configuration information: small
bits of read-only data. Ramdisks are the way to go.
3. You will need to rewrite your start-up code. You will now need
to explicitly instantiate all your devices, for example.
4. Your Edit-Compile-Test loop just got more painful. Sorry.
Getting things working on the HaLVM required:
• Updates to the TLS library I was using.
• Updates to the x.509 library I was using.
And it benefited from a bunch of previous work
I’d done for other unikernels.
© 2015 Galois, Inc.29 © 2015 Galois, Inc.29
Step #4: Test (Part II)
Hopefully, any bugs you hit at this point are bugs in the adaptation
to the unikernel, not in your code.
But here are some more questions to verify:
1. Does your system come up cleanly, every time, even with
flakey device timings?
2. Are you flying safely under your memory bounds? (If so,
can you lower them safely?)
3. Can you run your test suite as a unikernel? (If so, do it.)
4. Optional: Does your new unikernel survive migration?
This is still in progress.
(This is always in progress.)
© 2015 Galois, Inc.30 © 2015 Galois, Inc.30
Step #5: Deploy
The unikernel community is working to make deployment to all the
standard clouds quicker and easier, but there are documents
online that you can use.
There are tools for distributing to EC2, but
they’re incomplete.
Different unikernels are in different places with
regard to EC2 and other clouds.
Let’s See Some Code
© 2015 Galois, Inc.32 © 2015 Galois, Inc.32
Let’s Run Some Tor
main :: IO ()
main = runDefaultMain $  flags ->
do (MkNS ns, logger) <- initializeSystem flags
let options = defaultTorOptions{ … }
tor <- startTor ns options
addrs <- torResolveName tor "www.whatismypublicip.com"
case addrs of
[] ->
putStrLn ("Could not resolve www.whatismypublicip.com!")
((addr, _ttl) : _) ->
do sock <- torConnect tor addr 80
putStrLn ("Connected to " ++ show addr)
torWrite sock (buildGet "/")
putStrLn ("Wrote GET request.")
resp <- readLoop sock
putStrLn ("Response: " ++ show resp)
torClose sock ReasonDone
Parse command line arguments,
turn them into Tor configuration
options, and start up the network.
name, based on the options
provided earlier.
Create an anonymous
connection and read the
response.
Start the various daemon threads
required to run a Tor entrance
node.
Anonymously look up a domain
© 2015 Galois, Inc.33 © 2015 Galois, Inc.33
Starting Means Booting
initializeSystem :: [Flag] ->
IO (SomeNetworkStack, String -> IO ())
initializeSystem _ =
do con <- initXenConsole
xs <- initXenStore
ns <- newNetworkStack
macstr <- findNIC xs
nic <- openNIC xs macstr
let mac = read macstr
addDevice ns mac (xenSend nic) (xenReceiveLoop nic)
deviceUp ns mac
ipaddr <- dhcpDiscover ns mac
return (MkNS (hansNetworkStack ns),
makeLogger ( x -> writeConsole con (x ++ "n")))
Most unikernels will get your
memory and such set up, but
devices are all up to you.
Network setup is all your
responsibility.
© 2015 Galois, Inc.34 © 2015 Galois, Inc.34
Abstracting Over Your Network Stack
-- |The type of a Tor-compatible network stack. The first type variable is the
-- type of a listener socket, the second the type of a standard connection
-- socket.
data TorNetworkStack lsock sock = TorNetworkStack {
connect :: String -> Word16 -> IO (Maybe sock)
-- |Lookup the given hostname and return any IP6 (Left) or IP4 (Right)
-- addresses associated with it.
, getAddress :: String -> IO [TorAddress]
, listen :: Word16 -> IO lsock
, accept :: lsock -> IO (sock, TorAddress)
, recv :: sock -> Int -> IO S.ByteString
, write :: sock -> L.ByteString -> IO ()
, flush :: sock -> IO ()
, close :: sock -> IO ()
, lclose :: lsock -> IO ()
}
© 2015 Galois, Inc.35 © 2015 Galois, Inc.35
QuickCheck!
tapHandshakeCheck :: Word32 -> RouterTAP -> TorRNG -> Bool
tapHandshakeCheck circId (RouterTAP myRouter priv) g0 =
let (g1, (privX, cbody)) = startTAPHandshake myRouter g0
(g2, (dcell, fenc, benc)) =
advanceTAPHandshake priv circId cbody g1
Created circIdD dbody = dcell
in case completeTAPHandshake privX dbody of
Left err ->
False
Right (fenc', benc') ->
(circId == circIdD) && (fenc == fenc') &&
(benc == benc')
© 2015 Galois, Inc.36 © 2015 Galois, Inc.36
QuickCheck!
TorCell Serialization:
TorAddress round-trips: [OK, passed 100 tests]
TorAddress makes sensible ByteStrings: [OK, passed 100 tests]
ExtendSpec serializes: [OK, passed 100 tests]
DestroyReason serializes (check #1): [OK, passed 100 tests]
DestroyReason serializes (check #2): [OK, passed 100 tests]
HandshakeType serializes (check #1): [OK, passed 100 tests]
HandshakeType serializes (check #2): [OK, passed 100 tests]
RelayEndReason serializes: [OK, passed 100 tests]
RelayCell serializes: [OK, passed 100 tests]
RelayCell serializes w/ digest: [OK, passed 100 tests]
RelayCell serializes w/ digest: [OK, passed 100 tests]
Tor certificates serialize: [OK, passed 100 tests]
Hybrid encryption tests:
Hybrid encryption works when forced: [OK, passed 100 tests]
Hybrid encryption works in general: [OK, passed 100 tests]
Handshakes:
TAP Handshake: [OK, passed 100 tests]
NTor Handshake: [OK, passed 100 tests]
Make sure we get data
formats like. Next
step: fuzzing to make
sure we’re sufficiently
defensive.
Test custom crypto.
Test handshakes.
What is it like developing unikernels?
© 2015 Galois, Inc.38 © 2015 Galois, Inc.38
Boring
• It’s just like normal development when you start.
• Then you have to be a little more rigorous about testing and
evaluation.
• Then you run into a wall with library support.
• Except it’s not nearly as much of a problem as it used to be.
• With Tor, this meant writing one additional library from scratch
(zlib), and then sending patches to a few other authors.
• Debugging unikernels is also now more palatable:
• printf(), gdbsx, profiling
• The big remaining gap: the big web frameworks don’t work.
• They require all the deep device and OS integration that
causes problems with unikernels.
(Mostly)
© 2015 Galois, Inc.39 © 2015 Galois, Inc.39
But What You Get Is
More nodes,
For less money,
With a better security posture.
Which is great for , and perhaps your next
project.
© 2015 Galois, Inc.40 © 2015 Galois, Inc.40
All trademarks, service marks, trade names, trade dress, product names and
logos appearing in these slides are the property of their respective owners,
including in some instances Galois, Inc.
All rights are reserved.
http://github.com/GaloisInc/haskell-tor
Adam Wick
awick@galois.com
Twitter: @acwpdx
Any questions?
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/tor-
haskell

More Related Content

What's hot

ZendCon Security
ZendCon SecurityZendCon Security
ZendCon Security
philipo
 

What's hot (20)

DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015
 
DEF CON 27 - workshop - MAURICIO VELAZCO - writing custom paylods
DEF CON 27 - workshop - MAURICIO VELAZCO - writing  custom paylodsDEF CON 27 - workshop - MAURICIO VELAZCO - writing  custom paylods
DEF CON 27 - workshop - MAURICIO VELAZCO - writing custom paylods
 
Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017
 
Securing your Container Environment with Open Source
Securing your Container Environment with Open SourceSecuring your Container Environment with Open Source
Securing your Container Environment with Open Source
 
Open source security tools for Kubernetes.
Open source security tools for Kubernetes.Open source security tools for Kubernetes.
Open source security tools for Kubernetes.
 
Hacking the future with USB HID
Hacking the future with USB HIDHacking the future with USB HID
Hacking the future with USB HID
 
Docker & Daily DevOps
Docker & Daily DevOpsDocker & Daily DevOps
Docker & Daily DevOps
 
BH Arsenal '14 TurboTalk: The Veil-framework
BH Arsenal '14 TurboTalk: The Veil-frameworkBH Arsenal '14 TurboTalk: The Veil-framework
BH Arsenal '14 TurboTalk: The Veil-framework
 
ZendCon Security
ZendCon SecurityZendCon Security
ZendCon Security
 
Kautilya: Teensy beyond shell
Kautilya: Teensy beyond shellKautilya: Teensy beyond shell
Kautilya: Teensy beyond shell
 
(03 2013) guide to kali linux
(03 2013)   guide to kali linux(03 2013)   guide to kali linux
(03 2013) guide to kali linux
 
The Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote WorldThe Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote World
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
 
Bandit and Gosec - Security Linters
Bandit and Gosec - Security LintersBandit and Gosec - Security Linters
Bandit and Gosec - Security Linters
 
Pwnstaller
PwnstallerPwnstaller
Pwnstaller
 
Roberto Clapis/Stefano Zanero - Night of the living vulnerabilities: forever-...
Roberto Clapis/Stefano Zanero - Night of the living vulnerabilities: forever-...Roberto Clapis/Stefano Zanero - Night of the living vulnerabilities: forever-...
Roberto Clapis/Stefano Zanero - Night of the living vulnerabilities: forever-...
 
KITE Network Instrumentation: Advanced WebRTC Testing
KITE Network Instrumentation: Advanced WebRTC TestingKITE Network Instrumentation: Advanced WebRTC Testing
KITE Network Instrumentation: Advanced WebRTC Testing
 
5 Ways to Secure Your Containers for Docker and Beyond
5 Ways to Secure Your Containers for Docker and Beyond5 Ways to Secure Your Containers for Docker and Beyond
5 Ways to Secure Your Containers for Docker and Beyond
 
All You need to Know about Secure Coding with Open Source Software
All You need to Know about Secure Coding with Open Source SoftwareAll You need to Know about Secure Coding with Open Source Software
All You need to Know about Secure Coding with Open Source Software
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devices
 

Viewers also liked

Php basics
Php basicsPhp basics
Php basics
hamfu
 
00025233
0002523300025233
00025233
fpem
 
C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...
C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...
C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...
Jluis Dela Rosa
 

Viewers also liked (17)

Presentation Protein Synthesis
Presentation Protein SynthesisPresentation Protein Synthesis
Presentation Protein Synthesis
 
Is brief illustrated guide الدليل المصور الموجز لفهم الإسلام آيسلندي
Is brief illustrated guide   الدليل المصور الموجز لفهم الإسلام   آيسلنديIs brief illustrated guide   الدليل المصور الموجز لفهم الإسلام   آيسلندي
Is brief illustrated guide الدليل المصور الموجز لفهم الإسلام آيسلندي
 
Catalogue HOP'TOYS Autonomie 2017
Catalogue HOP'TOYS Autonomie 2017Catalogue HOP'TOYS Autonomie 2017
Catalogue HOP'TOYS Autonomie 2017
 
Jongerenparticipatie Sensoa - Inspiratiedag Kansengroepen van Ambrassade op ...
Jongerenparticipatie Sensoa -  Inspiratiedag Kansengroepen van Ambrassade op ...Jongerenparticipatie Sensoa -  Inspiratiedag Kansengroepen van Ambrassade op ...
Jongerenparticipatie Sensoa - Inspiratiedag Kansengroepen van Ambrassade op ...
 
Zoekwoordenselectie
ZoekwoordenselectieZoekwoordenselectie
Zoekwoordenselectie
 
EL BOSQUE ENCANTADO
EL BOSQUE ENCANTADOEL BOSQUE ENCANTADO
EL BOSQUE ENCANTADO
 
Creatividad o mal gusto de los japoneses.
Creatividad o mal gusto de los japoneses.Creatividad o mal gusto de los japoneses.
Creatividad o mal gusto de los japoneses.
 
Tautas ataudzes mērķi NAP2020 un to sasniegšanas gaita
Tautas ataudzes mērķi NAP2020 un to sasniegšanas gaitaTautas ataudzes mērķi NAP2020 un to sasniegšanas gaita
Tautas ataudzes mērķi NAP2020 un to sasniegšanas gaita
 
Php basics
Php basicsPhp basics
Php basics
 
Cognitive Biases: How the Clustering Illusion will impact your pitch
Cognitive Biases:  How the Clustering Illusion will impact your pitchCognitive Biases:  How the Clustering Illusion will impact your pitch
Cognitive Biases: How the Clustering Illusion will impact your pitch
 
Шобанов Константин "Боль и удовольствие в продажах"
Шобанов Константин "Боль и удовольствие в продажах"Шобанов Константин "Боль и удовольствие в продажах"
Шобанов Константин "Боль и удовольствие в продажах"
 
Modified maximum tangential stress criterion for fracture behavior of zirconi...
Modified maximum tangential stress criterion for fracture behavior of zirconi...Modified maximum tangential stress criterion for fracture behavior of zirconi...
Modified maximum tangential stress criterion for fracture behavior of zirconi...
 
מחדד 05.03
מחדד 05.03מחדד 05.03
מחדד 05.03
 
Oscars after - party
Oscars after - partyOscars after - party
Oscars after - party
 
00025233
0002523300025233
00025233
 
Ylen Suomalaiset verkossa 2010 - tutkimuksen esittely
Ylen Suomalaiset verkossa 2010 - tutkimuksen esittelyYlen Suomalaiset verkossa 2010 - tutkimuksen esittely
Ylen Suomalaiset verkossa 2010 - tutkimuksen esittely
 
C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...
C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...
C mo-ganarse-la-vida-escribiendo-orientaciones-para-desarrollar-la-escritura-...
 

Similar to Tor in Haskell & Other Unikernel Tricks

Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
Volodymyr Shynkar
 
Wo defensive trickery_13mar2017
Wo defensive trickery_13mar2017Wo defensive trickery_13mar2017
Wo defensive trickery_13mar2017
Dan Kaminsky
 

Similar to Tor in Haskell & Other Unikernel Tricks (20)

DevSecOps and Drupal: Securing your applications in a modern IT landscape
DevSecOps and Drupal: Securing your applications in a modern IT landscapeDevSecOps and Drupal: Securing your applications in a modern IT landscape
DevSecOps and Drupal: Securing your applications in a modern IT landscape
 
Help Doctor, my application is an onion!
Help Doctor, my application is an onion!Help Doctor, my application is an onion!
Help Doctor, my application is an onion!
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
DockerCon SF 2015: Keynote Day 1
DockerCon SF 2015: Keynote Day 1DockerCon SF 2015: Keynote Day 1
DockerCon SF 2015: Keynote Day 1
 
Kube Security Shifting left | Scanners & OPA
Kube Security Shifting left | Scanners & OPAKube Security Shifting left | Scanners & OPA
Kube Security Shifting left | Scanners & OPA
 
#Morecrypto (with tis) - version 2.2
#Morecrypto (with tis) - version 2.2#Morecrypto (with tis) - version 2.2
#Morecrypto (with tis) - version 2.2
 
When the internet bleeded : RootConf 2014
When the internet bleeded : RootConf 2014When the internet bleeded : RootConf 2014
When the internet bleeded : RootConf 2014
 
Creating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with TestcontainersCreating Realistic Unit Tests with Testcontainers
Creating Realistic Unit Tests with Testcontainers
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)
 
KubeCon EU 2016: Kubernetes meets Finagle for Resilient Microservices
KubeCon EU 2016: Kubernetes meets Finagle for Resilient MicroservicesKubeCon EU 2016: Kubernetes meets Finagle for Resilient Microservices
KubeCon EU 2016: Kubernetes meets Finagle for Resilient Microservices
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: Keynote
 
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
 
London HUG 19/5 - Kubernetes and vault
London HUG 19/5 - Kubernetes and vaultLondon HUG 19/5 - Kubernetes and vault
London HUG 19/5 - Kubernetes and vault
 
Kubernetes Security
Kubernetes SecurityKubernetes Security
Kubernetes Security
 
Wo defensive trickery_13mar2017
Wo defensive trickery_13mar2017Wo defensive trickery_13mar2017
Wo defensive trickery_13mar2017
 
10 tips for Cloud Native Security
10 tips for Cloud Native Security10 tips for Cloud Native Security
10 tips for Cloud Native Security
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Security Tips to run Docker in Production
Security Tips to run Docker in ProductionSecurity Tips to run Docker in Production
Security Tips to run Docker in Production
 
Secure your web app presentation
Secure your web app presentationSecure your web app presentation
Secure your web app presentation
 
Lares from LOW to PWNED
Lares from LOW to PWNEDLares from LOW to PWNED
Lares from LOW to PWNED
 

More from C4Media

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

Tor in Haskell & Other Unikernel Tricks

  • 1. Adam Wick @ QCon San Francisco, 2015 Tor in Haskell and Other Unikernel Tricks
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /tor-haskell
  • 3. Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide Presented at QCon San Francisco www.qconsf.com
  • 4. This combination is not crazy. (In fact, it makes a lot of sense.)
  • 5. © 2015 Galois, Inc.3 © 2015 Galois, Inc.3 Adam Wick @ QCon San Francisco, 2015 Built the Haskell Lightweight Virtual Machine (HaLVM) Works for (a unikernel) Adam Wick
  • 6. © 2015 Galois, Inc.4 © 2015 Galois, Inc.4 Use Case #3: Nimble
  • 7. © 2015 Galois, Inc.5 © 2015 Galois, Inc.5 Use Case #3: Nimble
  • 8. © 2015 Galois, Inc.6 © 2015 Galois, Inc.6 Use Case #3: Nimble + Massive
  • 9. © 2015 Galois, Inc.7 © 2015 Galois, Inc.7 Why are Unikernels and Tor such a good idea? Unikernels are fundamentally designed to be Lightweight Fast Secure More nodes for the same price, or the same number of nodes for less. Fewer schedulers means lower latency. A much smaller OS stack means less code to get wrong.
  • 10. So We Did This (And now I’m going to tell you about it.)
  • 12. © 2015 Galois, Inc.10 © 2015 Galois, Inc.10 : Anonymity Through Root Vegetables Tor is an anonymous communication layer built on TLS that prevents people from learning who you are interacting with over the Internet.* * Terms and conditions may apply.
  • 13. © 2015 Galois, Inc.11 © 2015 Galois, Inc.11 Guarantees*: 1. For any single relay node, it is impossible to tell where you are in the chain. 2. The exit node cannot tell how many hops were before it. 3. The entrance node cannot tell how many hops are in front of it. * Terms and conditions may apply.
  • 14. © 2015 Galois, Inc.12 © 2015 Galois, Inc.12 Terms and Conditions May Apply The security of Tor is dependent on: 1. The correctness of the protocol design. 2. The correctness of the protocol implementation. 3. Ensuring that there are enough nodes that no single entity owns a sufficient percentage of nodes to have a top level view.
  • 16. © 2015 Galois, Inc.14 © 2015 Galois, Inc.14 It is also known for being popular with people that know more category theory than is good for them, which has given it a certain … reputation. Haskell is a functional programming language: fact :: Integer -> Integer map :: (a -> b) -> [a] -> [b] fact 0 = 1 map _ [] = [] fact x = x * fact (x – 1) map f (x:r) = (f x) : map f r It is mostly known for being lazy, pure, and strongly typed. Very HelpfulHandyMeh
  • 17. © 2015 Galois, Inc.15 © 2015 Galois, Inc.15 do -- "To authenticate the initiator, the responder MUST check the -- following: -- * The CERTS cell contains exactly one CerType 3 'AUTH' -- certificate. let authCert = exactlyOneAuth certs Nothing authCert' = signedObject (getSigned authCert) -- * The CERTS cell contains exactly one CerType 2 'ID' -- certificate let iidCert = exactlyOneId certs Nothing iidCert' = signedObject (getSigned iidCert) -- * Both certificates have validAfter and validUntil dates -- that are not expired. when (certExpired authCert' now) $ fail "Auth certificate expired." when (certExpired iidCert' now) $ fail "Id certificate expired." -- * The certified key in the AUTH certificate is a 1024-bit RSA -- key. unless (is1024BitRSAKey authCert) $ fail "Auth certificate key is the wrong size." -- * The certified key in the ID certificate is a 1024-bit RSA -- key. unless (is1024BitRSAKey iidCert) $ fail "Identity certificate key is the wrong size." -- * The auth certificate is correctly signed with the key in the -- ID certificate. unless (authCert `isSignedBy` iidCert') $ fail "Auth certificate not signed by identity cert."
  • 18. © 2015 Galois, Inc.16 © 2015 Galois, Inc.16 I’m Not Here To Sell You Haskell, But: Type Safety + Purity + Safe Data Structures + GC = Fewer bugs per LOC = Less security advisories per LOC
  • 20. © 2015 Galois, Inc.18 © 2015 Galois, Inc.18 Unikernels are specialised, single address space machine images constructed using library operating systems. - Wikipedia or Unikernels : Virtual Machines :: Exokernels : Physical Machines or Unikernels are single-process programs compiled to run directly on (usually virtual) hardware, rather than within a full-featured OS.
  • 21. © 2015 Galois, Inc.19 © 2015 Galois, Inc.19
  • 22. © 2015 Galois, Inc.20 © 2015 Galois, Inc.20 Lower operating costs Faster response to events Smaller attack surface
  • 23. © 2015 Galois, Inc.21 © 2015 Galois, Inc.21 Containers and Unikernels Unikernels: The next step in separation: 1. We started with single-task code. 2. Next, we separated some of our tasks into threads. 3. Next, we separated some of our threads into processes. 4. Next, we separated some of our processes into containers. 5. Now, we separated our critical containers into unikernels. Each level provides additional separation properties, at the cost of increased complexity in creating and reasoning about new code.
  • 24. So: Tor + Haskell + Unikernels?
  • 25. © 2015 Galois, Inc.23 © 2015 Galois, Inc.23 Terms and Conditions May Apply The security of Tor is dependent on: 1. The correctness of the protocol design. 2. The correctness of the protocol implementation. 3. Ensuring that there are enough nodes that no single entity owns a sufficient percentage of nodes to have a top level view. Can’t really do much for this one. Except that more implementations means more eyes on the specs. Haskell limits memory issues, type safety helps correctness. Unikernels limit attack surface. Unikernels limit resource usage, which allows a lot more relay nodes for the same cost.
  • 26. Cool! How Did That Work?
  • 27. © 2015 Galois, Inc.25 © 2015 Galois, Inc.25 So You Want To Build A Unikernel There are five steps to building a Unikernel: 1. Don’t. 2. Test & Measure. 3. Do. 4. Test (Part II) 5. Deploy.
  • 28. © 2015 Galois, Inc.26 © 2015 Galois, Inc.26 Step #1: Don’t Build a Unikernel Building a unikernel adds a number of complications to the development process (which is already complicated enough). So start by building your application as you normally would, in a language that supports unikernels. (In this case, Haskell.) Build using your normal tools, libraries, and techniques, but: 1. Try to avoid local storage. 2. Try to minimize the number of libraries you pull in. 3. Stay away from libraries that link against C. With Tor, I began by implementing the core parsing and protocol code, sufficient to anonymously look up a hostname. To avoid a linking problem, I also ended up writing my own zlib decompression library. More on that later.
  • 29. © 2015 Galois, Inc.27 © 2015 Galois, Inc.27 Step #2: Measure & Test What is your application’s peak memory use? Exactly how much space do you need for configuration files, etc.? Does this space need to be writeable? Then TEST, TEST, TEST. Your goal is that in later steps, any bugs you find have to do with the unikernel translation, not your application. In measuring my work with Tor, I discovered that the zlib library I’d written earlier was very … silly ... with regard to memory use. I wish I’d found that here.
  • 30. © 2015 Galois, Inc.28 © 2015 Galois, Inc.28 Step #3: Do it. Once it works well, and you know about its resource usage, now it’s time to start converting it to a unikernel. 1. Some of your libraries won’t build, and you will either need to fix or replace these. Predicting which ones is possible, but requires some experience and internal knowledge of the library. 2. Disks are expensive and slow; consider using ramdisks. For many of our uses of unikernels, and Tor can be one of them, then the only need for a disk is to pass configuration information: small bits of read-only data. Ramdisks are the way to go. 3. You will need to rewrite your start-up code. You will now need to explicitly instantiate all your devices, for example. 4. Your Edit-Compile-Test loop just got more painful. Sorry. Getting things working on the HaLVM required: • Updates to the TLS library I was using. • Updates to the x.509 library I was using. And it benefited from a bunch of previous work I’d done for other unikernels.
  • 31. © 2015 Galois, Inc.29 © 2015 Galois, Inc.29 Step #4: Test (Part II) Hopefully, any bugs you hit at this point are bugs in the adaptation to the unikernel, not in your code. But here are some more questions to verify: 1. Does your system come up cleanly, every time, even with flakey device timings? 2. Are you flying safely under your memory bounds? (If so, can you lower them safely?) 3. Can you run your test suite as a unikernel? (If so, do it.) 4. Optional: Does your new unikernel survive migration? This is still in progress. (This is always in progress.)
  • 32. © 2015 Galois, Inc.30 © 2015 Galois, Inc.30 Step #5: Deploy The unikernel community is working to make deployment to all the standard clouds quicker and easier, but there are documents online that you can use. There are tools for distributing to EC2, but they’re incomplete. Different unikernels are in different places with regard to EC2 and other clouds.
  • 34. © 2015 Galois, Inc.32 © 2015 Galois, Inc.32 Let’s Run Some Tor main :: IO () main = runDefaultMain $ flags -> do (MkNS ns, logger) <- initializeSystem flags let options = defaultTorOptions{ … } tor <- startTor ns options addrs <- torResolveName tor "www.whatismypublicip.com" case addrs of [] -> putStrLn ("Could not resolve www.whatismypublicip.com!") ((addr, _ttl) : _) -> do sock <- torConnect tor addr 80 putStrLn ("Connected to " ++ show addr) torWrite sock (buildGet "/") putStrLn ("Wrote GET request.") resp <- readLoop sock putStrLn ("Response: " ++ show resp) torClose sock ReasonDone Parse command line arguments, turn them into Tor configuration options, and start up the network. name, based on the options provided earlier. Create an anonymous connection and read the response. Start the various daemon threads required to run a Tor entrance node. Anonymously look up a domain
  • 35. © 2015 Galois, Inc.33 © 2015 Galois, Inc.33 Starting Means Booting initializeSystem :: [Flag] -> IO (SomeNetworkStack, String -> IO ()) initializeSystem _ = do con <- initXenConsole xs <- initXenStore ns <- newNetworkStack macstr <- findNIC xs nic <- openNIC xs macstr let mac = read macstr addDevice ns mac (xenSend nic) (xenReceiveLoop nic) deviceUp ns mac ipaddr <- dhcpDiscover ns mac return (MkNS (hansNetworkStack ns), makeLogger ( x -> writeConsole con (x ++ "n"))) Most unikernels will get your memory and such set up, but devices are all up to you. Network setup is all your responsibility.
  • 36. © 2015 Galois, Inc.34 © 2015 Galois, Inc.34 Abstracting Over Your Network Stack -- |The type of a Tor-compatible network stack. The first type variable is the -- type of a listener socket, the second the type of a standard connection -- socket. data TorNetworkStack lsock sock = TorNetworkStack { connect :: String -> Word16 -> IO (Maybe sock) -- |Lookup the given hostname and return any IP6 (Left) or IP4 (Right) -- addresses associated with it. , getAddress :: String -> IO [TorAddress] , listen :: Word16 -> IO lsock , accept :: lsock -> IO (sock, TorAddress) , recv :: sock -> Int -> IO S.ByteString , write :: sock -> L.ByteString -> IO () , flush :: sock -> IO () , close :: sock -> IO () , lclose :: lsock -> IO () }
  • 37. © 2015 Galois, Inc.35 © 2015 Galois, Inc.35 QuickCheck! tapHandshakeCheck :: Word32 -> RouterTAP -> TorRNG -> Bool tapHandshakeCheck circId (RouterTAP myRouter priv) g0 = let (g1, (privX, cbody)) = startTAPHandshake myRouter g0 (g2, (dcell, fenc, benc)) = advanceTAPHandshake priv circId cbody g1 Created circIdD dbody = dcell in case completeTAPHandshake privX dbody of Left err -> False Right (fenc', benc') -> (circId == circIdD) && (fenc == fenc') && (benc == benc')
  • 38. © 2015 Galois, Inc.36 © 2015 Galois, Inc.36 QuickCheck! TorCell Serialization: TorAddress round-trips: [OK, passed 100 tests] TorAddress makes sensible ByteStrings: [OK, passed 100 tests] ExtendSpec serializes: [OK, passed 100 tests] DestroyReason serializes (check #1): [OK, passed 100 tests] DestroyReason serializes (check #2): [OK, passed 100 tests] HandshakeType serializes (check #1): [OK, passed 100 tests] HandshakeType serializes (check #2): [OK, passed 100 tests] RelayEndReason serializes: [OK, passed 100 tests] RelayCell serializes: [OK, passed 100 tests] RelayCell serializes w/ digest: [OK, passed 100 tests] RelayCell serializes w/ digest: [OK, passed 100 tests] Tor certificates serialize: [OK, passed 100 tests] Hybrid encryption tests: Hybrid encryption works when forced: [OK, passed 100 tests] Hybrid encryption works in general: [OK, passed 100 tests] Handshakes: TAP Handshake: [OK, passed 100 tests] NTor Handshake: [OK, passed 100 tests] Make sure we get data formats like. Next step: fuzzing to make sure we’re sufficiently defensive. Test custom crypto. Test handshakes.
  • 39. What is it like developing unikernels?
  • 40. © 2015 Galois, Inc.38 © 2015 Galois, Inc.38 Boring • It’s just like normal development when you start. • Then you have to be a little more rigorous about testing and evaluation. • Then you run into a wall with library support. • Except it’s not nearly as much of a problem as it used to be. • With Tor, this meant writing one additional library from scratch (zlib), and then sending patches to a few other authors. • Debugging unikernels is also now more palatable: • printf(), gdbsx, profiling • The big remaining gap: the big web frameworks don’t work. • They require all the deep device and OS integration that causes problems with unikernels. (Mostly)
  • 41. © 2015 Galois, Inc.39 © 2015 Galois, Inc.39 But What You Get Is More nodes, For less money, With a better security posture. Which is great for , and perhaps your next project.
  • 42. © 2015 Galois, Inc.40 © 2015 Galois, Inc.40 All trademarks, service marks, trade names, trade dress, product names and logos appearing in these slides are the property of their respective owners, including in some instances Galois, Inc. All rights are reserved. http://github.com/GaloisInc/haskell-tor Adam Wick awick@galois.com Twitter: @acwpdx Any questions?
  • 43. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/tor- haskell