-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path2017-2 Network Security.fex
2420 lines (2306 loc) · 91 KB
/
2017-2 Network Security.fex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
network summary
===============
layers (vertical):
layers stacked up on one another (802.11 -> IP -> TCP -> HTTP)
lower layers are outside and wrap the next upper layer protocol
each layer adds its own header
higher layers uses the services of the next lower one (encapsulation)
more evolved in practice, with trailers, encryption, compression
OSI 7 Layers:
physical (sends bits as signals)
data link (sends frames of information)
network (sends packets over multiple links)
transport (provides end-to-end delivery)
session (manages task dialogs)
presentation (converts data representations)
application (provides functionality to users)
internet reference model:
application (SMTP, HTTP, RTP, DNS)
transport (TCP, UDP)
internet (IP)
link (Ethernet, 3G, Cable, DSL, 802.11)
protocols (horizontal):
protocols of same kind communicate with each other
ethernet:
preamble 8
destination address 6
source address 6
type 2
data 0-1500
pad 0-45
CRC checksum 4
IPv4:
version 4, IHL 4, DS 8, total length 16
ID 16, empty 1, DontFrag 1, MoreFrag 1, FragOffset 14
TTL 8, Protocol 8, Header checksum 16
Source Address 16
Destination Address 16
Options (0 or more words d*32)
Payload
IPv6:
8 groups of 4 hex digits
omit leading zeros
shorten all-zero group to single zero
shorten multiple zero groups using double colon (only allowed once)
component names:
application (or app, user) uses the network (skype, browser)
host (or node, source, sink) supports apps (laptop, server)
node (or switch, router, hub) relays messages (AP, cable, modem)
link (or channel) connects nodes (wires, wireless)
hardware:
middleboxes:
sit inside network, but perform more than IP processing
can change the outer layer (from ethernet to 802.11)
NAT, firewall, intrusion detection system
NAT:
connects internal with external network
many internal hosts using only a few external addresses
motivated by IP address scarcity
map IP & ports of inside hosts to different outside ports/IP combinations
needs to lookup and rewrite IP packet
routing:
decentralized, distributed node run same algorithm
operate concurrently, communicate using messages
node/link/message failures possible
needed properties:
correctness (find working path)
efficiency (use bandwidth well)
fair (don't starve any nodes)
fast convergence (recover quickly after changes)
scalability (support large networks)
target bandwidth allocation:
efficient (most capacity used, but no congestion)
fair (every sender gets reasonable share)
max-min fairness (bottled flows get equal share)
algorithms:
dijkstra:
extract the node with the lowest distance
add link N to the shortest path tree
relax the distances of neighbours of N by lowering to the best estimate
distance-vector DV:
routing table contains nodes, distances and next hop
nodes adapt table if better connection found by broadcast
more scalable than LS, but slow convergence after failures
link-state LS:
nodes flood topology with link state packets
nodes compute own forwarding table
faster than DV, typically used in practice
ICMP:
on routing error, ICMP sent back to source in IP packet
exact:
ICMP header with type, code
ICMP data with start of offending packet, the IP header first
traceroute:
sends probe packet with increasing TTL starting at 1
logs ICMP errors, and therefore knows the path the packet is taking
ping:
ping request/reply (type=8/0)
code is always 0, if reply received then host reachable
destination information:
destination unreachable (type=3)
code is 0/1 if net/host is not reachable
code is 4 if fragment is too big (MTU is set too high)
path error:
time exceeded (type=11)
code is always 0, if TTL of packet is maxed out
protects against forwarding loops
used by traceroute to find path of packet
IPsec:
operates at network layer
provides data integrity, secrecy
multiple algorithms available to secure connection
encrypts traffic between two "Security Gateway"s
Security Association SA:
an end-to-end configuration
contains security identifier
modes:
tunnel (IPsec packet inside IP packet)
transport (header with SA number)
IKEv2:
established tunnel
protocol which provides authentication
agree on security proposal, keys setup
headers:
authentication header (integrity checks, sequence number)
encapsulating security payload (secrecy)
investigates issues:
packet type dependent traffic handling (other paths chosen)
port NAT (packets modified in transit)
modified sequence numbers (DoS attack, ISP made mistake)
man in the middle (downgrade attack, response time too slow)
TCP:
secure connection at network layer
exact:
source port 16, destination port 16
sequence number 32
acknowledgement number 32
tcp header length 4, various 12, window size 16
checksum 16, urgent pointer 16
options (d*32 words)
connection establishment:
sender and receiver need to be ready to receive, agree on parameters
with three way handshake
client sends SYN(x)
server replies with SYN(y)ACK(x+1)
client replies with ACK(y+1)
connection release:
active FIN(SEQ=x), passive (ACK=x+1, SEQ=y)
passive FIN(SEQ=y, ACK=x+1), active (SEQ=x+1, ACK=y+1)
each FIN/ACK closes one direction
sliding window:
building on stop and wait
sends while LastFrameSent - LastAckRecieved < Window
flow control:
slow down enthusiastic sender by sending available buffer space
sends WIN together with ACK of available space
may resends same ACK if buffer increased
retransmissions:
if timeout occurs, resend packet
adapt timeout based on last data
TCP slow start:
increasing cwnd with each packet received (doubling each timeslice)
use till congestion window reached, then continue with AI
Additive Increase, Multiplicative Decrease (AIMD):
AI to reach max transmission speed (increase slowly)
MD to avoid congestion detected (if detected, half bandwidth)
leads to characteristic Sawtooth pattern
converges to allocation which is fair and efficient
detect congestion:
packet loss (easy but too late, used by TCP NewReno & Cubic TCP)
packet delay (know early but complicated, used by Compound TCP)
ERN (know early but router needs to explicitly set notification)
Crypto Refresher
=============
basic definitions:
anonymity:
keep identity (name / identifier) of a protocol participant secret
privacy:
the control over how information about oneself is shared
confidentiality:
extension of privacy
defines how identifiable data is treated
secrecy:
more general than confidential, privacy, anonymity
keep data hidden from unintended receivers
integrity:
property of local/stored data
unchanged and syntactically correct
prevents unauthorized, improper changes
non-repudiation:
sender cannot deny sending of message
initial receiver can pass message with proof to third party
authentication:
of property ensures identity of sender verified and data integrity
of entity verifies identify of another protocol participant
of data ensures data originates from claimed sender
cryptographic primitives:
asymmetric (public-private key):
public key to verify/encrypt
private key to sign/decrypt
public/private key systems such as RSA
digital signatures
more powerful than symmetric, but much slower
symmetric (shared-key, same-key):
secret key to encrypt/decrypt
block ciphers (pseudo-random permutation PRP)
stream ciphers (pseudo-random generators PRG):
message authentication codes (MAC)
use asymmetric to setup secure key
hash:
provides integrity
no keys needed
MAC:
provides integrity, authentication
uses symmetric keys
digital signatures:
provides integrity, authentication, non-repudiation
uses asymmetric keys
symmetric primitives:
one-time pad:
use random keystream for each message (XOR with plaintext)
perfectly secure if bytestream never reused
stream cipher:
to archive secrecy
very fast (faster than block ciphers)
using PRG (Pseudo Random Generator):
Initialization Vector IV, secret key k
cipher = plain XOR PRG(k, IV)
keystream reuse attack:
if same keystream used for two different messages
XOR two cipher text gives XOR of two plain texts
ciphertext modification attack:
flip a bit in cipher will flip a bit in plain
integrity of message needed
general security question:
is the bitstream reused?
can I change a bit?
block ciphers:
to archive secrecy
take fixed size of plaintext
encrypt each block separately
DES:
computation power of bitcoin larger than needed to break DES
AES/Rijndael:
works well and fast
blocksize 128
key size 128, 192, 256
Intel and AMD implement special instructions for AES
split message M into m_1, m_2, ..., m_n
encrypt each block mode specific
semantic security:
advisory can guess value of single plaintext bit at most random
even if same message is encrypted, the cryptotext looks random each time
cannot infer if newly encrypted message is same as before
block cipher modes:
Electronic Code Book (ECB):
block encrypted with key K
simple to compute
but same plain equals same cipher, restructure possible
Counter Mode (CTR):
IV encrypted, XOR with block, new IV = old IV + 1
semantic security
but altered cyphertext only influences one block
Cipher Block Chaining (CBC):
block XOR IV, block encrypted (is new IV)
semantic security
but altered cyphertext only influences two blocks
if bits flipped in C2, then P3 has same bits flipped
Cypher Feedback (CFB):
IV encrypted, XOR with block (is new IV)
semantic security, altered cyphertext influences all following blocks
Output Feedback (OFB):
IV encrypted (is new IV), XOR with block
semantic security
but altered cyphertext only influences one block
Galois Counter Mode (GCM):
gives both secrecy and authenticity
message authentication codes (MAC):
to archive authenticity, needs a symmetric key
hash-based MAC (HMAC):
choose hash function, adapt key K to hash block size
secure even if strong collision resistance broken
HMAC[K, m] = H[K XOR 0x5c5c... || H[K XOR 0x3636... || m]]
(pads allow for more entropy, maximize hamming distance)
block-cypher based MAC (CMAC):
encrypt message with block cypher
use last block as MAC
multiple hash functions:
can AES encrypt file, use as many bits as needed from cypher
secure encryption implies same properties as good hash function
asymmetric primitives:
diffie-hellman (DH):
public values are large prime p, generator g
private values are a, b
A to B -> r_1 = g^a (mod p), B computes key = r_1^b
B to A -> r_2 = g^b (mod p), A computes key = r_2^a
Eve cannot compute g^ab
man in the middle possible (advisory can sit between A and B)
works because of discrete logarithm problem
RSA algorithm:
choose p,q as large secret primes
pick public e, compute secret d such that e*d mod ((p-1)(q-1)) = 1
publish public key N=p*q, e (and keep p,q,d secret)
create signature with v = M^d mod N
verify signature by M = v^e mod N
Encrypted Key Exchange (EKE):
A,B share private p, hash function H, use it to calculate K = H(p)
A,B have private values a,b respectively
use EKE to calculate session key K' = H(g^ab)
verify with nonce that other party was successful
A to B -> g^a ENC K
B to A -> g^b ENC K, nonce_b ENC K'
A to B -> (nonce_a, nonce_b) ENC K'
B to A -> nonce_a ENC K'
cryptographic hash functions:
maps arbitrary length input to finite length output
properties:
one-way:
give y = H(x), cannot find x' such that y = H(x') (no inversion)
find x' after 2^(n-1) on average, probability for each try is 1/(2^n)
weak collision resistance:
given x, cannot find x' != x such that H(x) = H(x')
same complexity as one-way
strong collision resistance:
cannot find x != x' such that H(x) = H(x')
root(2^(n/2)) because can test against any hash (birthday paradox)
hash chains:
robust to missing values, infeasible for attackers, efficient to verify
pick secret and public one-way function (hash H)
hash n times (r_i = H(r_(i+1))) and publish r_0
used as cheap one-time passwords
used in router protocol (can't claim shorter distance)
enhance:
security lowered with each more revealed hash chain entry
attacker can try to create a collisions
loose logn bits of entropy with each new revealed entry
simply add index to hash like r_i = H(r_i+1, i+1)
merkle hash trees:
authenticate sequence of data values D_i
build up tree by hashing two together T_3 = H(D_0 || D_1)
walk up the tree by continuously hashing nodes, sign root
to authenticate D_i, accompany it with nodes to reach root
if signed root node can be reached, then D_i authenticated
power of two conversions:
remember 2^1 till 2^10
calculation:
2^n = 10^m
n = (m/3) *10
m = (n/10) * 3
basic big numbers:
seconds per day is 2^16
seconds per year is 2^16 * 2^9 = 2^25
Introduction to blockchains
=========
bitcoin:
first block mined in 2009, first commercial pizza bought for 10'000 bitcoins
used for criminal activities, because hardly traceable
original whitepaper by Satoshi Nakamoto describes only main operation
reference implementation is de-facto specification
forks expected to appear as reference implementation holds no authority
traditional digital cash:
first paper (1982) by david chaum introduced anonymous coins
bank only verifies that same coin is not used two times
commercialized as DigiCash but not a huge success
improvements included offline transaction, and breaking into smaller coins
all require trusted authority, the bank, bitcoin removes central authority
core concepts:
proof of work to combat spam / DDoS attack
public ledger to prevent double spending (transactions are state)
innovation:
archives consensus without trusted authorities or preassumed identities
under such constraints the general problem of consensus is impossible
uses additional assumptions about incentives & networking
lessons learned from bitcoin may help to create better tools
theoretical problems:
difficult to model in precision (relies heavily on socio-economic factors)
hard to argue about soundness
main components:
transactions:
input contains a scriptSig with public key and signature
inputs are combined, each input group gives two outputs
one output for the real receiver, one output for rest back to the sender
output contains a scriptPublicKey which signs a script
script must evaluate to true for the output to be valid
scripting is simple stack-based language (not turing complete)
valid transactions are included in block
block is put in public ledger (block chain)
transaction is "confirmed" when block deep inside chain
ownership:
each user has wallets containing a public/private keypair
knowledge of private key gives ability to spend or redeem outputs
user state represented as set of transactions using the scripting language
nakamoto concensus:
only signing does not prevent using same output multiple times
therefore all transactions are saved into public log (ledger), chain
can extend the chain by solving computational puzzle (mining)
reject wrong solutions, and append to longest chain
multiple chains may exist (forks) if multiple solutions
eventually one of those chains will be longer (eventual consistency)
mining:
find nonce for H(H(previous_block) || transactions || nonce) < target
target is adjustable (the lower the harder), solving by brute force
miners finding a valid nonce get the block reward & transaction fees
block rewards will half every four years till 2140, then cease to exist
transaction fees will stay, amount to several bitcoins
proof of work (puzzle) with an incentive to work (fees)
peer to peer network:
used to broadcast new transactions and blocks
protocol works by flooding
INV message to advertise block
GETDATA message to request full block data
network has low latency and can't block any participants
any node connects to eight other nodes as outgoing connections
any node accepts about 100 incoming connections
10min delay, 10'000 nodes in bitcoin network
bitcoin analysis:
needed for stability:
eventual consensus:
all compliant nodes eventually agree on longest chains
exponential convergences:
probability of forks is exponentially proportional to length of chain
liveness:
valid transactions will be added to the chain
correctness:
in the longest chain all transactions are valid
fairness:
fraction f of computing power should be able to mine 1/f blocks
properties:
stability:
if (majority honest) then consensus, convergence and liveness
but needs good network (latency lot lower than block discovery)
privacy:
users create many pseudonyms, this guarantees strong privacy
merchant can create new pseudo for each received payment
payer may has to combine multiple sources to pay
performance:
7 transactions per seconds (tps)
6.5s delivery time of new block (95% reception at 40s)
can adjust parameters to increase to 60tps
slower generation rate + smaller block = higher security
upgrade:
using soft forks (backwards compatible, only few changes possible)
using hard forks (enabling new kinds of transactions)
har fork bugfix from 2013 won only after 24 blocks
attacks:
large mining power (more than half):
ignore blocks found by others because own chain will grow faster
refuse to include certain transactions
introduce arbitrary forks
block withholding attack (selfish mining):
waste resources of others
miner finds two blocks, waits with publish till other have found one
higher expected payoff
eclipse attack:
isolate (eclipse) node from the rest of network
monopolizing its incoming and outgoing connections
enable targeted double spending, easy with access to cable
off path attack:
get the victim to only connect to attacker nodes
advisory does not need to be directly connected to victim
influence victims view of network using other nodes to send fake data
on victim restart, will likely connect to advisory nodes only
message delaying:
inform victim late about changes in network
delay delivery of block, instead of relaying them
only requires single connection, exploits scalability measures
routing level attacks:
delay/disconnect victim from network
possible because BGB hijacking
completely disconnect / delay messages for up to 20 minutes
deanonymise participants:
mapping money flow to individuals is often possible
parse through blockchain, link transactions to identity cluster
then try to make trade with one of those clusters to find out identity
broadcasting to network leaks IP (can use TOR to mitigate)
then link together multiple pseudonyms used in one session
blockchains:
permissionless:
anybody can mine
can scale to a big number of nodes (but low throughput)
low performance compared to more centralized systems (like VISA)
permissioned:
blockchain consensus is maintained by predefined entities
can only scale up to small number of nodes (but good throughput)
examples:
bitcoin:
permissionless & special-purpose
only for money
ethereum:
permissionless & general (turing complete byte-code language)
currency called ether can be transferred to users/contracts
programs are called "smart contracts", fee paid on execution
can invoke functions of other contracts
transactions contains state of financial application
hyperledger:
permissioned & general
supports smart contracts
can select small number of validators to validate next block
dramatically increased performance
other applications:
replace database with permissioned blockchain
replace property registry; each entity can run its own validators in it
research:
blockchain address certain problems but not perfect
blockchain does not ensure data secrecy
blockchain hype to extreme
open questions:
security (attacks on mining, network, incentives)
consensus (is blockchain really the way to go?)
partially-centralized (control chains)
trusted computing (build stronger chain)
DNS
======
concept:
globally distributed database (loosely coherent, scalable, dynamic)
no single computer has all DNS data
maps names to resources of various types (URL to IP's for example)
attackers perspective:
helps to setup services which are hard to shutdown (botnets)
helps building hidden channels (can send UDP through DNS)
distributed storage system (can be used to distributed files)
abused for DDoS attacks
abused for impersonation attacks
consists of:
namespaces (hierarchy)
servers (making namespaces available)
resolvers (query server)
hierarchy:
from right to left, each dot separates a domain
. ("dot") is root level (root servers, controlled by US)
TLD top-level domains controlled by registrars (generic/country TLD)
SLD second-level domains controlled by private entities
FQDN fully-qualified domain (mail.ethz.ch)
resolution:
ask ISP caching resolver, which then asks from root to SLD
caching only valid as specified by TTL
# dig 8.8.8.8 url.ch
protocol:
simple UDP/TCP protocol
no encryption, authentication nor integrity built into
DNSSec is a secure extension, but not adapted largely
query section (with target url)
reply section (with target IP
authorative section (with nameserver URLs)
additional section (more IP/URL mappings, including for NS)
name server:
authorative for a specific zone (ETH nameserver for ETH domains)
cache response for queries as long as TTL is valid
resolvers:
stub resolver (library which contacts recursive resolver)
recursive resolver (iterative DNS resolution)
resolution:
request has 16bit transaction id TXID (generated on device)
replies can be matched using the transaction id
replies contain TTL
responds with NXDOMAIN if not found
responds with most specific authority found
record types:
address record (A, AAAA) to map FQDN to IP
pointer record (PTR) to map IP to FQDN
name server record (NS) advertises name servers for zone
start of authority (SOA) advertises attributed of zone
canonical name (CNAME) may defines alias for FQDN
mail exchanger record (MX) to define mail server URLs
text record (TXT) for untyped storage
fundamental DNS problems:
session id does not have enough entropy, or is predictable
amplification due to large response for small request
open resolvers respond to any query even from outside network
content in additional section of DNS protocol is cached
name server roles:
authorative name servers:
non-recursive response with data it is authorative about
responds to queries from everywhere
cache/recursive resolver:
attempts to resolve fully
only responds to queries from network
attacks:
phantom domain attack:
advertise domain on attacker NS, which on purpose responds slowly
ask real DNS server for resolving
real DNS server hangs waiting for response from attacker NS
URL access check:
ask DNS server, if TTL has low value URL has been accessed before
can abuse to see if URL has been visited without owning the domain
distributed reflection:
create TCP packet with spoofed victim IP
DNS sends big response for small request to victim
DNS spoofing:
reply faster than DNS server (DHCP forge, random broadcast)
set high TTL to forged data
adds more URL/IP in additional section of DNS packet
poison shared DNS cache with forged DNS entries
modify hosts file to point to attacker NS
manipulate DNS settings to point to attackers NS
DNS/domain hijacking:
hack the domain registrar / abuse weak passwords
change domain NS and set high TTL
DNS tunneling:
bypass firewall by sending traffic over DNS
mostly fixed nowadays
attack mitigations:
distributed reflection:
reject packets with IP unreachable from actual path
establish response rate limit per IP
authoritative nameservers disable recursion, only respond for own zone
recursive resolvers limit to authorized clients from own network
cache poisoning:
detect poisoning with a monitoring service
set high TTL for own records (attack retry time longer)
protect with SSL certificates (need to have capable users)
botnet control with DNS:
botnet must have reliable way to be controlled
fixed IP allows to identify bot agent & controller and is easy to block
botnet architecture:
main controller / bot master, shielded by layer of intermediaries
layer of redundant bots to hide bot master
network of managed bots which perform tasks
control architectures:
use single domain:
set low TTL, multiple IP addresses (A records)
hart to shutdown because of DNS caches, but still weak
use IP flux:
frequent change of IP related to FQDN
TTL to low value, provide array of valid IP addresses
use domain flux:
frequent change of FQDN
domain generation algorithm DGA to computes list of domain names
attacker registers one of the possible domains
bot attempts to connect to any of the generated domains
defender cannot simply buy all of them
DNSSec:
attempts to add security, while being backwards compatible
provides:
origin authentication of DNS data
authenticated denial of existence (so can't add stuff to the message)
integrity (but not availability or confidentiality)
how:
all DNSSEC zone data is signed with private key of zone
response consists of signed record set
can be verified with trusted public key
problem with DNSSec:
DNS resolves to found, not_found, but cannot express forged
deployed at ISP level
need to manage master keys
new fields:
resource record signature RRSIG:
contains DNSSEC signature for record set
verified using the DNSKEY
public key record DNSKEY:
public key used to verify DNSSEC
delegation signer record DS:
references a DNSKEY (glues the chain)
lives in the parent zone, singed by parent or other trusted key
next secure record NSEC:
contains link to next record name in zone (non-existence proofs)
so if A,C exist and asked for B, return A NSEC B
SSL/TLS Public-Key Infrastructure (PKI)
====================
introduction:
security in network stack:
PGP in application layer
SSH, TLS in transport layer
IPsec in internet layer
AES, WPA2 in link layer
security requirements:
secrecy to prevent eavesdroppers to learn sensitive information
entity and message authentication to prevent alteration / injection
browser warnings:
41% for facebook, youtube, google
61% clock, 13% antivirus, 13% captive portal, 3% unknown
PKI:
public key infrastructure provides a way to validate public keys
trust establishment:
trust root which cryptographically transfers trust
trust depends on size of trust root (how reliable)
trust depends on number of malicious entries tolerable
certificate authorities (CA):
trust roots in TLS PKI which can sign keys of lower entities
possible trust roots:
monopoly model with single trust root (DNSSEC, BGPSEC)
oligarchy model with numerous roots of trust (SSL, TLS)
both implementations lack update of trust roots
who controls root vs weakest-link security
X.509:
from 1988, standard format
defines structure of PK certificates with data & signature section
contains valid from, valid to, and permissions (any, only sign, ...)
TLS PKI:
levels of trust:
no ssl/tls
domain validation DV (common case, verify that you own domain)
organization validation OV (more info about owner)
extended validation EV (a lot of checks till issued)
multi-domain certificates by CDN:
CDN need https but sit between user and webpage
CDNs therefore obtain certificate for multiple domains (from CA)
problems:
CA's can sign any URL/email, may abuse privilege
lots of CA's means large root trust base but weakest link security
improve TLS:
challenges:
cannot tolerate additional latency during ssl handshake
certificate has to be immediately usable and verifiable
need to be able to revocate certificates
users shouldn't decide if certificate is legitimate
CAP theorem:
Consistency, Availability, Tolerance to Partition
need to sacrifice one
short-lived certificates:
only very short livetime to avoid revocation issues
Lets Encrypt CA:
provide free TLS certificates, sponsors like mozilla
automate domain validation, issuance and renewal (90 days valid)
uses ACME (automated certificate management environment) protocol
HTTP strict transport security (TSTS):
allow servers to declare HTTPS only in its header (Strict-Transport-Security: max-age=62631263)
prevents downgrade, SSL stripping, session hijacking
certificate revocation list (CRL):
revoke certificates (because private key disclosed, employee leaves)
url in CA certificates resolves to revoked certificates
online certificate status protocol (OCSP):
addresses issues with CRL
(slow) protocol which clients can use to verify certificate status
clients directly ask at CA, which responds with signed response
browsers treat errors non fatal, rather relay on software update
OCSP stapling:
replaces revocation, saves OCSP status inside certificate
server needs to periodically renew its certificate status at CA
DNS-based authentication of names entities (DANE):
goal is to authenticate TLS servers without CA
add TLSA entry to DNS containing constrains
add cert constrains (directly specify certificate)
add CA constraints ("only trust those CA's")
add trust root assertion (specify new trust root)
relies heavily on DNSSEC (which has single trust root)
HTTP public key pinning (HPKP):
server sends set of public keys to client for future connections
in HTTPS header Public-Key_pins:: max-age=9123981, pin-sha256="..."
certificate transparency (CT):
hold CA publicly accountable for all issued certificates
do so without introducing yet another third party
Integrity Log Server (ILS):
holds log of published certificates publicly available
technical:
CT log is append-only list of certificates
ILS can append any new entries, then signs root node
data structure used is merkle hash tree with certificates as leaves
does not endorse certificates, only makes them publicly available
verify if entity is part of the tree is fast (hash till at root)
verify if tree is append only is efficient
SCT (Signed Certificate Timestamp):
when CA adds certificate to ILS it generates a SCT
include SCT in the certificate directly to avoid ILS roundtrip
as the SCT generation may takes some time there are different approaches
X.509v3:
CA asks ILS for SCT with pre certificate
adds SCT to certificate before issuing it
TLS extension:
domain submits SSL certificate to ILS
adds SCT to handshake
OCSP stapling:
CA submits SSL certificate to ILS
domain queries CA for SCT, then adds it to handshake
participants of CT:
monitors of CA watch logs for suspicious activity (also read-only backups)
certificate owners verify that no others have certificates on same name
auditors of browsers verify overall logs integrity, redo log proofs
auditors & monitors communicate to detect forked logs
security of CT:
browsers demand SCT for certificate, may contact ILS to verify
deployable, no change to web server required
MitM and bogus certificates can still happen, but will be public record
Attack-Resilient PKI (ARPKI):
reduce trust in single component as domain creates own security policy
properly define events as key change, revocation, switch of CA
address adversarial events (CA, logs are compromised, attacked)
requirements:
checks and balances (distributed trust, parties monitor each other)
brief error periods (such as compromise, unavailability)
trust agility (domains & users can pick entities they trust)
privacy (connection only revealed to client & server)
efficiency (no setup time increase)
usability (secure by default)
assumptions:
browsers store authentic public keys of CA, ILS's
all parties are loosely time synchronized
advisories main goal is MitM
entities:
client (browser) establishes connection with domain
ILS logs domain certificates in Integrity Tree IT (public)
CA signs domains public keys and monitors ILS behaviour
communication:
domain obtains certificate with multiple signatures from multiple CA
CA act as validators to survey operations by ILS
n parties needed (1 ILS, n-1 CA) for valid certificate
communication flow for n=3:
domain writes CA
CA creates certificate, and adds it do a quorum of ILS servers
CA sends to CA_2
CA_2 confirms certificate and quorum of ILs
CA_2 sends certificate to CA
CA sends certificate to domain
TLS
=======
SSL TLS:
history:
SSL Secure Sockets Layer by netscape, full of bugs
TLS Transport Layer Security, standardized
TLS 1.2 deployed currently
TLS 1.3 finalized in 2017
fundamental security requirements:
secrecy, prevent eavesdropping (passive attack)
authenticity, prevent alteration of entity & message (active attack)
security assumptions:
CA assumptions (no key leaks, no singing abuse)
crypto assumptions (no hash collisions, no broken algorithms)
browser assumptions (certificates up to date / not altered, browser secure)
user assumptions (user checks for https, events treated appropriately)
cypher suite:
key exchange metrics:
m1 secure to passive attackers (eavesdropper)
m2 secure to active MitM attackers
m3 perfect forward secrecy PFS (prevent backward decryption)
m4 contributory key agreement (both parties add to the key)
PFS needs long-term key to not compromise session keys
cipher spec:
cypher algorithm for encryption (RC4, DES40, IDEA, AES, Camellia)
mac algorithm for authentication (MD5, SHA-1, SHA-256)
cypher type (stream, block)
is exportable (true, false)
hash size (0 or 16 MD5, 20 SHA-1, 32 SHA-256)
thesprawl.org/research/tls-and-ssl-cipher-suites
key exchange:
to establish session key between client & server
server has public/private keypair K
client/server establishe session key K'
RSA (case 1, server RSA key can encrypt):
client sends session-key to server
server_certificate {URL, K}_KCA-1
client_key_exchange {K'}_K
(m1 m2) fulfilled, (m3 m4) not
RSA (case 2, server RSA key cannot encrypt):
temporary keypair K_2 used to establish session key
server_certificate {URL, K}_KCA-1
server_key_exchange {URL, K_2}_K-1
client_key_exchange {K'}_K_2
(m1 m2 m3) fulfilled, (m4) not
Anonymous DiffieHellman:
DH without authentication
server_key_exchange p, g, g^S
client_key_exchange g^c mod p
(m1 m3 m4) fulfilled, (m2) not
Fixed DiffieHellman:
DH key of server in certificate
server_certificate {URL, g^s mod p}_KCA-1
client_key_exchange g^c mod p
(m1 m2 m4) fulfilled, (m3) not
Ephemeral DiffieHellman:
DH key singed with K
server_certificate {URL, K}_KCA-1
server_key_exchange p, g, g^s, {g^s}_K-1
client_key_exchange g^c mod p
(m1 m2 m3 m4) fulfilled
exchange:
multiple optional requests, marked with (o)
depending on scheme different messages are used
phase 1:
server / client agree to specific exchange
C -> S client_hello with timestamp, random, cyphers, session id
S -> C server_hello with chosen cypher
phase 2:
server authentication & key exchange
S -> C server_certificate (o)
S -> C server_key_exchange (o)
S -> C certificate_request (o) (type, list of acceptable CA)
S -> C server_hello done
phase 3:
client authentication & key exchange
C -> S client_certificate (o) (if server requests client certificate)
C -> S client_key_exchange
C -> S certificate_verify (o) (signing certificate of client, MD5 HMAC)
phase 4:
finish up (now client/server share master secret)
C -> S change_cypher_spec
C -> S finished (send SHA-1 HMAC of exchanged data)
S -> C change_cypher_spec
S -> C finished
TLS 1.3:
single-roundtrip for initial connection, zero-roundtrip for repeated
after server-hello all messages are encrypted
new key derivation with HMAC
removes optional messages to make protocol easier
new signature algorithms
removed compression because attacker gets information
cleaned-up possible cypher suites
example:
C -> S client_hello, g^c
S -> C server_hello, g^s, certificate, signature, finished, application data
C -> S finished, application data
comments:
clients assumes server capabilities, try again if guessed wrong
before client finish server already sends non-critical application data
only ephemeral DH allowed
TCP and TLS connection establishment part of QUICK
second connection:
client has cached server parameters
C -> S client_hello, g^c, server configuration, application data
S -> C server_hello, g^s, certificate, signature, finished, application data
C -> S finished
attacks:
impersonate client:
server cannot verify client as no certificates
impersonation of client easily
random number generator RNG:
undetectable attack if able to predict state of RNG
decrypt anything as able to predict any generated "secret" keys
client has to send 28bytes of random, but 16bytes would be enough
maybe done to predict state of random number generator
can't trust clients to pick random solely (often outdated)
can't trust servers to pick random solely (could be altered)
dumbing down:
replacing cypher spec of client to insecure ones
anonymous diffie hellman perfect for active attacker
Denial of Service Attacks and Availability
==================
DoS:
Denial of service (DoS) does resource starvation
deprives of CPU, network/connectivity, memory, diskspace
DDoS is for distributed, large numbers (botnets) attack
general techniques:
spoofing (hide/fake the origin)
amplification (in volume and number)
reflection (combine source spoofing and amplification)
attacks types:
volume:
consume bandwidth within the target network
consume bandwidth between target network and internet
measured in bits/sec
(malformed) ICMP, UDP, IP
reflection / amplification (like DNS, NTP)
protocol:
exhaust resources needed to handle protocol on specific devices
saturate protocol state of devices (such as TCP state table)
measured in packets/sec
RST attack (set reset bit to 1, instantly killing connection)
SYN/ACK floods (open connection a lot of connections on server)
fragmentation attacks (invalid fragmentations specified)
application layer (layer7):
attack service or protocol at layer 7
attacks difficult to detect with flow-based monitoring tools
measured in requests/sec
SMTP, DNS, SNMP, FTP, SIP