-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdraft-irtf-pearg-numeric-ids-generation-02.txt
1904 lines (1232 loc) · 70.8 KB
/
draft-irtf-pearg-numeric-ids-generation-02.txt
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
Internet Research Task Force (IRTF) F. Gont
Internet-Draft SI6 Networks
Intended status: Informational I. Arce
Expires: November 15, 2020 Quarkslab
May 14, 2020
On the Generation of Transient Numeric Identifiers
draft-irtf-pearg-numeric-ids-generation-02
Abstract
This document performs an analysis of the security and privacy
implications of different types of "numeric identifiers" used in IETF
protocols, and tries to categorize them based on their
interoperability requirements and the associated failure severity
when such requirements are not met. Subsequently, it provides advice
on possible algorithms that could be employed to satisfy the
interoperability requirements of each identifier category, while
minimizing the security and privacy implications, thus providing
guidance to protocol designers and protocol implementers. Finally,
this describes a number of algorithms that have been employed in real
implementations to generate transient numeric identifiers and
analyzes their security and privacy properties.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on November 15, 2020.
Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved.
Gont & Arce Expires November 15, 2020 [Page 1]
Internet-Draft Generation of Transient Numeric IDs May 2020
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4
3. Threat Model . . . . . . . . . . . . . . . . . . . . . . . . 5
4. Issues with the Specification of Identifiers . . . . . . . . 5
5. Protocol Failure Severity . . . . . . . . . . . . . . . . . . 6
6. Categorizing Identifiers . . . . . . . . . . . . . . . . . . 6
7. Common Algorithms for Transient Numeric Identifier Generation 9
7.1. Category #1: Uniqueness (soft failure) . . . . . . . . . 9
7.2. Category #2: Uniqueness (hard failure) . . . . . . . . . 11
7.3. Category #3: Uniqueness, stable within context (soft
failure) . . . . . . . . . . . . . . . . . . . . . . . . 12
7.4. Category #4: Uniqueness, monotonically increasing within
context (hard failure) . . . . . . . . . . . . . . . . . 13
8. Common Vulnerabilities Associated with Transient Numeric
Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . 19
8.1. Network Activity Correlation . . . . . . . . . . . . . . 19
8.2. Information Leakage . . . . . . . . . . . . . . . . . . . 20
8.3. Exploitation of Semantics of Transient Numeric
Identifiers . . . . . . . . . . . . . . . . . . . . . . . 21
8.4. Exploitation of Collisions of Transient Numeric
Identifiers . . . . . . . . . . . . . . . . . . . . . . . 21
8.5. Cryptanalysis . . . . . . . . . . . . . . . . . . . . . . 21
9. Vulnerability Analysis of Specific Transient Numeric
Identifiers Categories . . . . . . . . . . . . . . . . . . . 22
9.1. Category #1: Uniqueness (soft failure) . . . . . . . . . 22
9.2. Category #2: Uniqueness (hard failure) . . . . . . . . . 23
9.3. Category #3: Uniqueness, stable within context (soft
failure) . . . . . . . . . . . . . . . . . . . . . . . . 23
9.4. Category #4: Uniqueness, monotonically increasing within
context (hard failure) . . . . . . . . . . . . . . . . . 23
10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 25
11. Security Considerations . . . . . . . . . . . . . . . . . . . 25
12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 26
13. References . . . . . . . . . . . . . . . . . . . . . . . . . 26
13.1. Normative References . . . . . . . . . . . . . . . . . . 26
13.2. Informative References . . . . . . . . . . . . . . . . . 27
Appendix A. Flawed Algorithms . . . . . . . . . . . . . . . . . 30
A.1. Predictable Linear Identifiers Algorithm . . . . . . . . 30
A.2. Random-Increments Algorithm . . . . . . . . . . . . . . . 32
Gont & Arce Expires November 15, 2020 [Page 2]
Internet-Draft Generation of Transient Numeric IDs May 2020
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 34
1. Introduction
Network protocols employ a variety of numeric identifiers for
different protocol entities, ranging from DNS Transaction IDs (TxIDs)
to transport protocol ports (e.g. TCP ports) or IPv6 Interface
Identifiers (IIDs). These identifiers usually have specific
properties (e.g. uniqueness during a specified period of time) that
must be satisfied such that they do not result in negative
interoperability implications, and an associated failure severity
when such properties are not met, ranging from soft to hard failures.
For more than 30 years, a large number of implementations of the TCP/
IP protocol suite have been subject to a variety of attacks, with
effects ranging from Denial of Service (DoS) or data injection, to
information leakages that could be exploited for pervasive monitoring
[RFC7258]. The root cause of these issues has been, in many cases,
the poor selection of transient numeric identifiers in such
protocols, usually as a result of insufficient or misleading
specifications. While it is generally trivial to identify an
algorithm that can satisfy the interoperability requirements of a
given identifier, empirical evidence exists that doing so without
negatively affecting the security and/or privacy properties of the
aforementioned protocols is prone to error
[I-D.irtf-pearg-numeric-ids-history].
For example, implementations have been subject to security and/or
privacy issues resulting from:
o Predictable TCP Initial Sequence Numbers (ISNs)
o Predictable transport protocol ephemeral port numbers
o Predictable IPv4 or IPv6 Fragment Identifiers (Fragment IDs)
o Predictable IPv6 Interface Identifiers (IIDs)
o Predictable DNS Transaction Identifiers (TxIDs)
Recent history indicates that when new protocols are standardized or
new protocol implementations are produced, the security and privacy
properties of the associated identifiers tend to be overlooked, and
inappropriate algorithms to generate transient numeric identifiers
are either suggested in the specification or selected by
implementers. As a result, it should be evident that advice in this
area is warranted.
Gont & Arce Expires November 15, 2020 [Page 3]
Internet-Draft Generation of Transient Numeric IDs May 2020
This document contains a non-exhaustive survey of identifiers
employed in various IETF protocols, and aims to categorize such
identifiers based on their interoperability requirements, and the
associated failure severity when such requirements are not met.
Subsequently, it provides advice on possible algorithms that could be
employed to satisfy the interoperability requirements of each
category, while minimizing the associated security and privacy
implications. Finally, it analyzes several algorithms that have been
employed in real implementations to meet such requirements and
analyzes their security and privacy properties.
2. Terminology
Transient Numeric Identifier:
A data object in a protocol specification that can be used to
definitely distinguish a protocol object (a datagram, network
interface, transport protocol endpoint, session, etc) from all
other objects of the same type, in a given context. Transient
numeric identifiers are usually defined as a series of bits, and
represented using integer values. These identifiers are typically
dynamically selected, as opposed to statically-assigned numeric
identifiers (see e.g. [IANA-PROT]). We note that different
identifiers may have additional requirements or properties
depending on their specific use in a protocol. We use the term
"transient numeric identifier" (or simply "numeric identifier" or
"identifier" as short forms) as a generic term to refer to any
data object in a protocol specification that satisfies the
identification property stated above.
Failure Severity:
The consequences of a failure to comply with the interoperability
requirements of a given identifier. Severity considers the worst
potential consequence of a failure, determined by the system
damage and/or time lost to repair the failure. In this document
we define two types of failure severity: "soft failure" and "hard
failure".
Soft Failure:
A soft failure is a recoverable condition in which a protocol does
not operate in the prescribed manner but normal operation can be
resumed automatically in a short period of time. For example, a
simple packet-loss event that is subsequently recovered with a
retransmission can be considered a soft failure.
Hard Failure:
A hard failure is a non-recoverable condition in which a protocol
does not operate in the prescribed manner or it operates with
excessive degradation of service. For example, an established TCP
Gont & Arce Expires November 15, 2020 [Page 4]
Internet-Draft Generation of Transient Numeric IDs May 2020
connection that is aborted due to an error condition constitutes,
from the point of view of the transport protocol, a hard failure,
since it enters a state from which normal operation cannot be
resumed.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [RFC2119].
3. Threat Model
Throughout this document, we assume an attacker does not have
physical or logical access to the device(s) being attacked. We
assume the attacker can simply send any traffic to the target
device(s), to e.g. sample identifiers employed by such device(s).
4. Issues with the Specification of Identifiers
While assessing protocol specifications regarding the use of
identifiers, we found that most of the issues discussed in this
document arise as a result of one of the following conditions:
o Protocol specifications which under-specify the requirements for
their identifiers
o Protocol specifications that over-specify their identifiers
o Protocol implementations that simply fail to comply with the
specified requirements
A number of protocol specifications (too many of them) have simply
overlooked the security and privacy implications of transient numeric
identifiers [I-D.irtf-pearg-numeric-ids-history]. Examples of them
are the specification of TCP port numbers in [RFC0793], the
specification of TCP sequence numbers in [RFC0793], or the
specification of the DNS TxID in [RFC1035].
On the other hand, there are a number of protocol specifications that
over-specify some of their associated transient numeric identifiers.
For example, [RFC4291] essentially overloads the semantics of IPv6
Interface Identifiers (IIDs) by embedding link-layer addresses in the
IPv6 IIDs, when the interoperability requirement of uniqueness could
be achieved in other ways that do not result in negative security and
privacy implications [RFC7721]. Similarly, [RFC2460] suggested the
use of a global counter for the generation of Fragment Identification
values, when the interoperability properties of uniqueness per {Src
IP, Dst IP} could be achieved with other algorithms that do not
result in negative security and privacy implications [RFC7739].
Gont & Arce Expires November 15, 2020 [Page 5]
Internet-Draft Generation of Transient Numeric IDs May 2020
Finally, there are protocol implementations that simply fail to
comply with existing protocol specifications. For example, some
popular operating systems (notably Microsoft Windows) still fail to
implement transport protocol ephemeral port randomization, as
recommended in [RFC6056].
5. Protocol Failure Severity
Section 2 defines the concept of "Failure Severity", along with two
types of failure severities that we employ throughout this document:
soft and hard.
Our analysis of the severity of a failure is performed from the point
of view of the protocol in question. However, the corresponding
severity on the upper application or protocol may not be the same as
that of the protocol in question. For example, a TCP connection that
is aborted may or may not result in a hard failure of the upper
application protocol: if the upper application can establish a new
TCP connection without any impact on the application, a hard failure
at the TCP protocol may have no severity at the application level.
On the other hand, if a hard failure of a TCP connection results in
excessive degradation of service at the application layer, it will
also result in a hard failure at the application.
6. Categorizing Identifiers
This section includes a non-exhaustive survey of transient numeric
identifiers, and proposes a number of categories that can accommodate
these identifiers based on their interoperability requirements and
their failure modes (soft or hard)
Gont & Arce Expires November 15, 2020 [Page 6]
Internet-Draft Generation of Transient Numeric IDs May 2020
+--------------+------------------------------------+---------------+
| Identifier | Interoperability Requirements | Failure |
| | | Severity |
+--------------+------------------------------------+---------------+
| IPv6 Frag ID | Uniqueness (for IP address pair) | Soft/Hard (1) |
+--------------+------------------------------------+---------------+
| IPv6 IID | Uniqueness (and stable within IPv6 | Soft (3) |
| | prefix) (2) | |
+--------------+------------------------------------+---------------+
| TCP ISN | Monotonically-increasing | Hard (4) |
+--------------+------------------------------------+---------------+
| TCP eph. | Uniqueness (for connection ID) | Hard |
| port | | |
+--------------+------------------------------------+---------------+
| IPv6 Flow | Uniqueness | None (5) |
| Label | | |
+--------------+------------------------------------+---------------+
| DNS TxID | Uniqueness | None (6) |
+--------------+------------------------------------+---------------+
Table 1: Survey of Identifiers
Notes:
(1)
While a single collision of Fragment ID values would simply lead
to a single packet drop (and hence a "soft" failure), repeated
collisions at high data rates might trash the Fragment ID space,
leading to a hard failure [RFC4963].
(2)
While the interoperability requirements are simply that the
Interface ID results in a unique IPv6 address, for operational
reasons it is typically desirable that the resulting IPv6 address
(and hence the corresponding Interface ID) be stable within each
network [RFC7217] [RFC8064].
(3)
While IPv6 Interface IDs must result in unique IPv6 addresses,
IPv6 Duplicate Address Detection (DAD) [RFC4862] allows for the
detection of duplicate addresses, and hence such Interface ID
collisions can be recovered.
(4)
In theory, there are no interoperability requirements for TCP
Initial Sequence Numbers (ISNs), since the TIME-WAIT state and
TCP's "quiet time" concept take care of old segments from previous
incarnations of the connection. However, a widespread
Gont & Arce Expires November 15, 2020 [Page 7]
Internet-Draft Generation of Transient Numeric IDs May 2020
optimization allows for a new incarnation of a previous connection
to be created if the ISN of the incoming SYN is larger than the
last sequence number seen in that direction for the previous
incarnation of the connection. Thus, monotonically-increasing TCP
sequence numbers allow for such optimization to work as expected
[RFC6528], since otherwise such connections-establishment attempts
would fail.
(5)
The IPv6 Flow Label is typically employed for load sharing
[RFC7098], along with the Source and Destination IPv6 addresses.
Reuse of a Flow Label value for the same set {Source Address,
Destination Address} would typically cause both flows to be
multiplexed onto the same link. However, as long as this does not
occur deterministically, it will not result in any negative
implications.
(6)
DNS TxIDs are employed, together with the Source Address,
Destination Address, Source Port, and Destination Port, to match
DNS requests and responses. However, since an implementation
knows which DNS requests were sent for that set of {Source
Address, Destination Address, Source Port, and Destination Port,
DNS TxID}, a collision of TxID would result, if anything, in a
small performance penalty (the response would nevertheless be
discarded when it is found that it does not answer the query sent
in the corresponding DNS query).
Based on the survey above, we can categorize identifiers as follows:
+-----+---------------------------------------+---------------------+
| Cat | Category | Sample Proto IDs |
| # | | |
+-----+---------------------------------------+---------------------+
| 1 | Uniqueness (soft failure) | IPv6 Flow L., DNS |
| | | TxIDs |
+-----+---------------------------------------+---------------------+
| 2 | Uniqueness (hard failure) | IPv6 Frag ID, TCP |
| | | ephemeral port |
+-----+---------------------------------------+---------------------+
| 3 | Uniqueness, stable within context | IPv6 IIDs |
| | (soft failure) | |
+-----+---------------------------------------+---------------------+
| 4 | Uniqueness, monotonically increasing | TCP ISN |
| | within context (hard failure) | |
+-----+---------------------------------------+---------------------+
Table 2: Identifier Categories
Gont & Arce Expires November 15, 2020 [Page 8]
Internet-Draft Generation of Transient Numeric IDs May 2020
We note that Category #4 could be considered a generalized case of
category #3, in which a monotonically increasing element is added to
a stable (within context) element, such that the resulting
identifiers are monotonically increasing within a specified context.
That is, the same algorithm could be employed for both #3 and #4,
given appropriate parameters.
7. Common Algorithms for Transient Numeric Identifier Generation
The following subsections describe some sample algorithms that can be
employed for generating transient numeric identifiers for each of the
categories above.
7.1. Category #1: Uniqueness (soft failure)
The requirement of uniqueness with a soft failure mode can be
complied with a Pseudo-Random Number Generator (PRNG). In scenarios
where ongoing use of previously selected numeric IDs is possible and
desirable, an implementation may opt to select the next available
identifier in the same sequence, or select another random number.
Section 7.1.1 is an implementation of the former strategy, while
Section 7.1.2 is an implementation of the later.
We note that since the premise is that collisions of numeric
identifiers of this category only leads to soft failures, in many (if
not most) cases, the algorithm will not need to check the suitability
of a selected identifier (i.e., check_suitable_id() would always be
"true").
7.1.1. Simple Randomization Algorithm
Gont & Arce Expires November 15, 2020 [Page 9]
Internet-Draft Generation of Transient Numeric IDs May 2020
/* Numeric ID selection function */
id_range = max_id - min_id + 1;
next_id = min_id + (random() % id_range);
count = next_id;
do {
if(check_suitable_id(next_id))
return next_id;
if (next_id == max_id) {
next_id = min_id;
} else {
next_id++;
}
count--;
} while (count > 0);
return ERROR;
NOTE:
random() is a function that returns a pseudo-random unsigned
integer number of appropriate size. Note that the output needs to
be unpredictable, and typical implementations of the POSIX
random() function do not necessarily meet this requirement. See
[RFC4086] for randomness requirements for security. Beware that
that "adapting" the length of the output of random() with a modulo
operator (e.g., C language's "%") may change the distribution of
the PRNG.
The function check_suitable_id() can check, when possible and
desirable, whether this identifier is suitable (e.g. it is not
already in use). Depending on how/where the numeric identifier is
used, it may or may not be possible (or even desirable) to check
whether the numeric identifier is in use (or whether it has been
recently been employed). When an identifier is found to be
unsuitable, this algorithm selects the next available numeric
identifier in sequence.
All the variables (in this and all the algorithms discussed in
this document) are unsigned integers.
This algorithm does not suffer from any of the issues discussed in
Section 8.
Gont & Arce Expires November 15, 2020 [Page 10]
Internet-Draft Generation of Transient Numeric IDs May 2020
7.1.2. Another Simple Randomization Algorithm
The following pseudo-code illustrates another algorithm for selecting
a random numeric identifier which, in the event a selected identifier
is found to be unsuitable (e.g., already in use), another identifier
is randomly selected:
/* Numeric ID selection function */
id_range = max_id - min_id + 1;
next_id = min_id + (random() % id_range);
count = id_range;
do {
if(check_suitable_id(next_id))
return next_id;
next_id = min_id + (random() % id_range);
count--;
} while (count > 0);
return ERROR;
This algorithm might be unable to select an identifier (i.e., return
"ERROR") even if there are suitable identifiers available, in cases
where a large number of identifiers are unsuitable (e.g. "in use").
The same considerations from Section 7.1.1 with respect to the
properties of random() and the adaptation of its output length apply
to this algorithm.
This algorithm does not suffer from any of the issues discussed in
Section 8.
7.2. Category #2: Uniqueness (hard failure)
One of the most trivial approaches for achieving uniqueness for an
identifier (with a hard failure mode) is to reduce the identifier
reuse frequency by generating the numeric identifiers with a linear
function. As a result, all of the algorithms described in
Section 7.4 ("Category #4: Uniqueness, monotonically increasing
within context (hard failure)") can be readily employed for complying
with the requirements of this numeric identifier category.
Gont & Arce Expires November 15, 2020 [Page 11]
Internet-Draft Generation of Transient Numeric IDs May 2020
7.3. Category #3: Uniqueness, stable within context (soft failure)
The goal of the following algorithm is to produce identifiers that
are stable for a given context (identified by "CONTEXT"), but that
change when the aforementioned context changes.
In order to avoid storing in memory the numeric identifier computed
for each CONTEXT value, the following algorithm employs a calculated
technique (as opposed to keeping state in memory) to generate a
stable identifier for each given context.
/* Numeric ID selection function */
id_range = max_id - min_id + 1;
counter = 0;
do {
offset = F(CONTEXT, counter, secret_key);
next_id = min_id + (offset % id_range);
if(check_suitable_id(next_id))
return next_id;
counter++;
} while (counter <= MAX_RETRIES);
return ERROR;
In the following algorithm, the function F() provides a stateless and
stable per-CONTEXT numeric identifier, where CONTEXT is the
concatenation of all the elements that define the given context.
For example, if this algorithm is expected to produce IPv6 IIDs
that are unique per network interface card (NIC) and SLAAC
autoconfiguration prefix, the CONTEXT should be the concatenation
of e.g. the interface index and the SLAAC autoconfiguration prefix
(please see [RFC7217] for an implementation of this algorithm for
generation of stable IPv6 IIDs).
F() must be a cryptographically-secure hash function (e.g. SHA-256
[FIPS-SHS]), that is computed over the concatenation of its
arguments. The result of F() is no more secure than the secret key,
and therefore 'secret_key' must be unknown to the attacker, and must
be of a reasonable length. 'secret_key' must remain stable for a
given CONTEXT, since otherwise the numeric identifiers generated by
Gont & Arce Expires November 15, 2020 [Page 12]
Internet-Draft Generation of Transient Numeric IDs May 2020
this algorithm would not have the desired stability properties (i.e.,
stable for a given CONTEXT). In most cases, 'secret_key' can be
selected with a PRNG (see [RFC4086] for recommendations on choosing
secrets) at an appropriate time, and stored in stable or volatile
storage for future use.
The result of F() is stored in the variable 'offset', which may take
any value within the storage type range, since we are restricting the
resulting identifier to be in the range [min_id, max_id] in a similar
way as in the algorithm described in Section 7.1.1.
check_suitable_id() checks that the candidate identifier has suitable
uniqueness properties. Collisions (i.e., an identifier that is not
unique) are recovered by incrementing the 'counter' variable and
recomputing F().
For obvious reasons, the transient network identifiers generated with
this algorithm allow for network activity correlation within
"CONTEXT". However, this is essentially a design goal of this
category of transient numeric identifiers.
7.4. Category #4: Uniqueness, monotonically increasing within context
(hard failure)
7.4.1. Per-context Counter Algorithm
One possible way to achieve low identifier reuse frequency while
still avoiding predictable sequences would be to employ a per-context
counter, as opposed to a global counter. Such an algorithm could be
described as follows:
Gont & Arce Expires November 15, 2020 [Page 13]
Internet-Draft Generation of Transient Numeric IDs May 2020
/* Initialization code */
id_inc = 1;
/* Numeric ID selection function */
count = max_id - min_id + 1;
if(lookup_counter(CONTEXT) == ERROR){
create_counter(CONTEXT);
}
next_id = lookup_counter(CONTEXT);
do {
if (next_id == max_id) {
next_id = min_id;
}
else {
next_id = next_id + id_inc;
}
if (check_suitable_id(next_id)){
store_counter(CONTEXT, next_id);
return next_id;
}
count--;
} while (count > 0);
store_counter(CONTEXT, next_id);
return ERROR;
NOTE:
lookup_counter() returns the current counter for a given context,
or an error condition if such a counter does not exist.
create_counter() creates a counter for a given context, and
initializes such counter to a random value.
store_counter() saves (updates) the current counter for a given
context.
check_suitable_id() is a function that checks whether the
resulting identifier is acceptable (e.g., whether it is not
already in use, etc.).
Gont & Arce Expires November 15, 2020 [Page 14]
Internet-Draft Generation of Transient Numeric IDs May 2020
Essentially, whenever a new identifier is to be selected, the
algorithm checks whether there there is a counter for the
corresponding context. If there is, such counter is incremented to
obtain the new identifier, and the new identifier updates the
corresponding counter. If there is no counter for such context, a
new counter is created an initialized to a random value, and used as
the new identifier. This algorithm produces a per-context counter,
which results in one linear function for each context. Since each
counter is initialized to a random value, the resulting values are
unpredictable by an off-path attacker.
This algorithm has the following drawbacks:
o This algorithm requires an implementation to store each per-
CONTEXT counter in memory. If, as a result of resource
management, the counter for a given context must be removed, the
last identifier value used for that context will be lost. Thus,
if subsequently an identifier needs to be generated for the same
context, that counter will need to be recreated and reinitialized
to random value, thus possibly leading to reuse/collision of
numeric identifiers.
o An implementation may map more than one context to the same
counter, such the amount of memory required to store counters is
reduce, at the expense of a possible unnecessary increase in the
numeric identifier reuse frequency. In such cases, if the
identifiers are predictable by the destination system (e.g., the
destination host represents the "context"), a vulnerable host
might possibly leak to third parties the identifiers used by other
hosts to send traffic to it (i.e., a vulnerable Host B could leak
to Host C the identifier values that Host A is using to send
packets to Host B). Appendix A of [RFC7739] describes one
possible scenario for such leakage in detail.
Otherwise, the identifiers produced by this algorithm do not suffer
from the other issues discussed in Section 8.
7.4.2. Simple Hash-Based Algorithm
The goal of this algorithm is to produce monotonically-increasing
sequences, with a randomized initial value, for each given context.
For example, if the identifiers being generated must be unique for
each {src IP, dst IP} set, then each possible combination of {src IP,
dst IP} should have a corresponding "next_id" value.
Keeping one counter for each possible "context" may in many cases be
considered too onerous in terms of memory requirements. As a
workaround, the following algorithm employs a calculated technique
Gont & Arce Expires November 15, 2020 [Page 15]
Internet-Draft Generation of Transient Numeric IDs May 2020
(as opposed to keeping state in memory) to maintain the random offset
for each possible context.
In the following algorithm, the function F() provides a (stateless)
unpredictable offset for each given context (as identified by
'CONTEXT').
/* Initialization code */
counter = 0;
/* Numeric ID selection function */
id_range = max_id - min_id + 1;
offset = F(CONTEXT, secret_key);
count = id_range;
do {
next_id = min_id +
(counter + offset) % id_range;
counter++;
if(check_suitable_id(next_id))
return next_id;
count--;
} while (count > 0);
return ERROR;
The function F() provides a "per-CONTEXT" fixed offset within the
numeric identifier "space". Both the 'offset' and 'counter'
variables may take any value within the storage type range since we
are restricting the resulting identifier to be in the range [min_id,
max_id] in a similar way as in the algorithm described in
Section 7.1.1. This allows us to simply increment the 'counter'
variable and rely on the unsigned integer to wrap around.
The function F() should be a cryptographically-secure hash function
(e.g. SHA-256 [FIPS-SHS]). CONTEXT is the concatenation of all the
elements that define a given context. For example, if this algorithm
is expected to produce identifiers that are monotonically-increasing
for each set (Source IP Address, Destination IP Address), CONTEXT
should be the concatenation of these two IP addresses.
Gont & Arce Expires November 15, 2020 [Page 16]
Internet-Draft Generation of Transient Numeric IDs May 2020
The result of F() is no more secure than the secret key, and
therefore 'secret_key' must be unknown to the attacker, and must be
of a reasonable length. 'secret_key' must remain stable for a given
CONTEXT, since otherwise the numeric identifiers generated by this
algorithm would not have the desired stability properties (i.e.,
stable for a given CONTEXT). In most cases, 'secret_key' can be
selected with a PRNG (see [RFC4086] for recommendations on choosing
secrets) at an appropriate time, and stored in stable or volatile
storage for future use.
It should be noted that, since this algorithm uses a global counter
("counter") for selecting identifiers (i.e., all counters share the
same increments space), this algorithm produces an information
leakage (as described in Section 8.2). For example, if this
algorithm were used for selecting TCP ephemeral ports, and an
attacker could force a client to periodically establish a new TCP
connection to an attacker-controlled machine (or through an attacker-
observable routing path), the attacker could subtract consecutive
source port values to obtain the number of outgoing TCP connections
established globally by the target host within that time period (up
to wrap-around issues and five-tuple collisions, of course).
7.4.3. Double-Hash Algorithm
A trade-off between maintaining a single global 'counter' variable
and maintaining 2**N 'counter' variables (where N is the width of the
result of F()), could be achieved as follows. The system would keep
an array of TABLE_LENGTH integers, which would provide a separation
of the increment space into multiple buckets. This improvement could
be incorporated into the algorithm from Section 7.4.2 as follows:
Gont & Arce Expires November 15, 2020 [Page 17]
Internet-Draft Generation of Transient Numeric IDs May 2020
/* Initialization code */
for(i = 0; i < TABLE_LENGTH; i++)
table[i] = random();
id_inc = 1;
/* Numeric ID selection function */
id_range = max_id - min_id + 1;
offset = F(CONTEXT, secret_key1);
index = G(CONTEXT, secret_key2) % TABLE_LENGTH;
count = id_range;
do {
next_id = min_id + (offset + table[index]) % id_range;
table[index] = table[index] + id_inc;
if(check_suitable_id(next_id))
return next_id;
count--;
} while (count > 0);
return ERROR;
'table[]' could be initialized with random values, as indicated by
the initialization code in the pseudo-code above.
Both F() and G() should be a cryptographically-secure hash functions
(e.g. SHA-256 [FIPS-SHS]) computed over the concatenation of each of
their respective arguments. Both F() and G() would employ the same
CONTEXT (the concatenation of all the elements that define a given
context), and would use separate secreted keys (secret_key1, and
secret_key2, respectively).
The results of F() and G() are no more secure than their respective
secret keys ('secret_key1' and 'secret_key2', respectively), and
therefore both secret keys must be unknown to the attacker, and must
be of a reasonable length. Both secret keys must remain stable for
the given CONTEXT, since otherwise the numeric identifiers generated