[Git][NTPsec/ntpsec][master] ntpd/nts_client.c: require EOM in NTS-KE response

Matt Selsky (@selsky) gitlab at mg.gitlab.com
Tue Oct 6 03:25:56 UTC 2026



Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
3c116538 by Matt Selsky at 2026-10-05T23:11:45-04:00
ntpd/nts_client.c: require EOM in NTS-KE response

RFC 8915 4.1.1 requires End of Message to "occur exactly once as the final
record of every NTS-KE request and response." The server enforces this, but
nts_client_process_response_core() only checked that the buffer was fully
consumed. A response with valid Next Protocol, AEAD, and cookie records that
ended on a record boundary without an EOM record was accepted.

Track whether EOM was seen and reject the response if it was not. This resolves
the "Need to check for EOM" FIXME.

- - - - -


1 changed file:

- ntpd/nts_client.c


Changes:

=====================================
ntpd/nts_client.c
=====================================
@@ -723,6 +723,7 @@ bool nts_client_process_response(SSL *ssl, struct peer* peer) {
 bool nts_client_process_response_core(uint8_t *buff, int transferred, struct peer* peer) {
         int idx;
         struct BufCtl_t buf;
+        bool sawEOM = false;
 
         peer->nts_state.cookielen = 0;
         peer->nts_state.aead = NO_AEAD;
@@ -845,6 +846,7 @@ bool nts_client_process_response_core(uint8_t *buff, int transferred, struct pee
                                 msyslog(LOG_ERR, "NTSc: EOM not at end: %d", buf.left);
                                 return false;
                         }
+                        sawEOM = true;
                         break;
                     default:
                         msyslog(LOG_ERR, "NTSc: received strange type: T=%d, C=%d, L=%d",
@@ -858,10 +860,15 @@ bool nts_client_process_response_core(uint8_t *buff, int transferred, struct pee
                 }  // case
         }   // while
 
-//      FIXME: Need to check for EOM -- read more??
         if (buf.left > 0)
                 return false;
 
+        // EOM must be last (checked above), so it appears at most once
+        if (!sawEOM) {
+                msyslog(LOG_ERR, "NTSc: No EOM.");
+                return false;
+        }
+
         if (NO_AEAD == peer->nts_state.aead) {
                 msyslog(LOG_ERR, "NTSc: No AEAD algorithm.");
                 return false;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/3c116538c2d5c9df8d899feb0c05d1d83ec28181

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/3c116538c2d5c9df8d899feb0c05d1d83ec28181
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20261006/add1dcad/attachment-0001.htm>


More information about the vc mailing list