]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
auth: allow zero value replay detection data
authorRoy Marples <roy@marples.name>
Sun, 29 Apr 2018 20:28:15 +0000 (21:28 +0100)
committerRoy Marples <roy@marples.name>
Sun, 29 Apr 2018 20:28:15 +0000 (21:28 +0100)
It seems one ISP doesn't use Replay Data and always sets it to zero.
See the comment in the commit as to why this is technically legal,
even if it goes against the intent of the RFC.

src/auth.c

index be7dd7ad7cf9318b3e5fb6c1dc2c4a9d3c1bdb72..93e8b774857f4edad5094eabc98077460327b1ca 100644 (file)
@@ -151,7 +151,24 @@ dhcp_auth_validate(struct authstate *state, const struct auth *auth,
 
        memcpy(&replay, d, sizeof(replay));
        replay = ntohll(replay);
-       if (state->token) {
+       /*
+        * Test for a replay attack.
+        *
+        * NOTE: Some servers always send a replay data value of zero.
+        * This is strictly compliant with RFC 3315 and 3318 which say:
+        * "If the RDM field contains 0x00, the replay detection field MUST be
+        *    set to the value of a monotonically increasing counter."
+        * An example of a monotonically increasing sequence is:
+        * 1, 2, 2, 2, 2, 2, 2
+        * Errata 3474 updates RFC 3318 to say:
+        * "If the RDM field contains 0x00, the replay detection field MUST be
+        *    set to the value of a strictly increasing counter."
+        *
+        * Taking the above into account, dhcpcd will only test for
+        * strictly speaking replay attacks if it receives any non zero
+        * replay data to validate against.
+        */
+       if (state->token && state->replay != 0) {
                if (state->replay == (replay ^ 0x8000000000000000ULL)) {
                        /* We don't know if the singular point is increasing
                         * or decreasing. */