<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced. 
     An alternate method (rfc include) is described in the references. -->
<!ENTITY RFC5905 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5905.xml">
<!ENTITY RFC2827 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2827.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2434 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2434.xml">
<!ENTITY RFC3552 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3552.xml">
<!ENTITY RFC4786 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4786.xml">
<!ENTITY RFC7094 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7094.xml">
<!ENTITY I-D.narten-iana-considerations-rfc2434bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.narten-iana-considerations-rfc2434bis.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="bcp" docName="draft-reilly-ntp-bcp-02" ipr="trust200902">
  <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the 
         full title is longer than 39 characters -->

    <title abbrev="Network Time Protocol BCP">Network Time Protocol Best
    Current Practices</title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <!-- Another author who claims to be an editor -->

    <author fullname="Denis Reilly" initials="D." surname="Reilly">
      <organization>Spectracom Corporation</organization>

      <address>
        <postal>
          <street>1565 Jefferson Road, Suite 460</street>

          <!-- Reorder these if your country does things differently -->

          <city>Rochester, NY</city>

          <region/>

          <code>14623</code>

          <country>US</country>
        </postal>

        <phone/>

        <email>denis.reilly@spectracom.orolia.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <author fullname="Harlan Stenn" initials="H." surname="Stenn">
      <organization>Network Time Foundation</organization>

      <address>
        <postal>
          <street>P.O. Box 918</street>

          <city>Talent, OR</city>

          <region/>

          <code>97540</code>

          <country>US</country>
        </postal>

        <phone/>

        <email>stenn@nwtime.org</email>
      </address>
    </author>

    <author fullname="Dieter Sibold" initials="D." surname="Sibold">
      <organization abbrev="PTB">Physikalisch-Technische
      Bundesanstalt</organization>

      <address>
        <postal>
          <street>Bundesallee 100</street>

          <city>Braunschweig</city>

          <code>D-38116</code>

          <region/>

          <country>Germany</country>
        </postal>

        <phone>+49-(0)531-592-8420</phone>

        <facsimile>+49-531-592-698420</facsimile>

        <email>dieter.sibold@ptb.de</email>
      </address>
    </author>

    <!-- Leave Sam as a ghost contributor for the moment  -->

    <!--    <author fullname="Samuel Weiler" initials="H."
            surname="Weiler">
      <organization></organization>

      <address>
        <postal>
          <street></street>
          <city></city>
          <region></region>
          <code></code>
          <country>US</country>
          </postal>
        <phone></phone>
        <email>weiler+ietf@watson.org</email>
      </address>
    </author>
-->

    <date month="June" year="2016"/>

    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill 
         in the current day for you. If only the current year is specified, xml2rfc will fill 
         in the current day and month for you. If the year is not the current one, it is 
         necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the 
         purpose of calculating the expiry date).  With drafts it is normally sufficient to 
         specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>General</area>

    <workgroup>Internet Engineering Task Force</workgroup>

    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.  
         If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->

    <keyword>NTP</keyword>

    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>NTP Version 4 (NTPv4) has been widely used since its publication as
      <xref target="RFC5905">RFC 5905</xref>. This documentation is a
      collection of Best Practices from across the NTP community.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>NTP Version 4 (NTPv4) has been widely used since its publication as
      <xref target="RFC5905">RFC 5905</xref>. This documentation is a
      collection of Best Practices from across the NTP community.</t>

      <section title="Requirements Language">
        <t>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 <xref
        target="RFC2119">RFC 2119</xref>.</t>
      </section>
    </section>

    <section title="Keeping NTP up to date">
      <t>The best way to protect your computers and networks against 
          undefined behavior and security threats related to time is to keep 
          your NTP implementation current.</t>
          
      <t>There are always new ideas about security on the Internet, and an
      application which is secure today could be insecure tomorrow once an
      unknown bug (or a known behavior) is exploited in the right way. 
      Even our definition of what is secure has evolved over the years, so
      code which was considered secure when it was written can be considered
      insecure after some time.</t>
          
      <t> Many security mechanisms rely on time as part of their operation. 
          If an attacker can spoof the time, they may be able to bypass or 
          neutralize other security elements. For example, incorrect time can 
          disrupt the ability to reconcile logfile entries on the affected system 
          with events on other systems.</t>
          
          <t>Thousands of individual bugs have been found and fixed in the NTP
      Project's reference implementation since the first NTPv4 release in
      1997. Each version release contains at least a few bug fixes. The best 
          way to stay in front of these issues is to keep your NTP implementation 
          current.</t>

      <t>There are multiple versions of the NTP protocol in use, and multiple 
          implementations in use, on many different platforms. It is recommended 
          that NTP users actively monitor wherever they get their software to find
          out if their versions are vulnerable to any known attacks, and deploy 
          updates containing security fixes as soon as practical.</t>

      <t>The reference implementation of NTP Version 4 from Network Time
      Foundation (NTF) continues to be actively maintained and developed by
      NTF's NTP Project, with help from volunteers and NTF's supporters. The
      NTP software can be downloaded from <eref
      target="http://www.ntp.org/downloads.html">ntp.org</eref> and also from
      <eref target="https://github.com/ntp-project/ntp">NTF's github page
      </eref>.</t>
    </section>

    <section title="General Network Security Best Practices">
<!--      <t>NTP deployments are only as secure as the networks they are deployed
             on.</t> -->

      <section anchor="bcp38" title="BCP 38">
        <t>Many network attacks rely on modifying the IP source address of a
        packet to point to a different IP address than the computer which
        originated it. This modification/abuse vector has been known for quite
        some time, and <xref target="RFC2827">BCP 38</xref> was approved in
        2000 to address this. <xref target="RFC2827">BCP 38</xref> calls for
        filtering outgoing and incoming traffic to make sure that the source
        and destination IP addresses are consistent with the expected flow of
        traffic on each network interface. It is recommended that all networks
        (and ISP's of any size) implement this. If a machine on your network
        is sending out packets claiming to be from an address that is not on
        your network, this could be the first indication that you have a
        machine that has been compromised, and is being used abusively. If 
                packets are arriving on an external interface with a source address 
                that should only be seen on an internal network, that's a strong 
                indication that an attacker is trying to inject spoofed packets into 
                your network. More information is available at http://www.bcp38.info .</t>
      </section>
    </section>

    <section title="NTP Configuration Best Practices">
      <t>NTP can be made more secure by making a few simple changes to the
      ntp.conf file.</t>

      <!-- See https://support.ntp.org/bin/view/Support/ConfiguringNTP -->

      <section title="Use enough time sources">
        <t>NTP takes the available sources of time and submits their timing
        data to intersection and clustering algorithms, looking for the best
        idea of the correct time. If there is only 1 source of time, the
        answer is obvious. It may not be a good source of time, but it's the
        only one. If there are 2 sources of time and they agree well enough,
        that's good. But if they don't, then ntpd has no way to know which
        source to believe. This gets easier if there are 3 sources of time.
        But if one of those 3 sources becomes unreachable or unusable, we're
        back to only having 2 time sources. 4 sources of time is another
        interesting choice, assuming things go well. If one of these sources
        develops a problem there are still 3 others. Seems good. Until the
        leap second we had in June of 2015, where several operators
        implemented leap smearing while others did not. See <xref
        target="leap_smear"/> for more information.
        </t> 

        <t>Starting with ntp-4.2.6, the 'pool' directive will spin up "enough"
        associations to provide robust time service, and will disconnect poor
        servers and add in new servers as-needed.</t>

        <t>Monitor your ntpd instances. If your times sources do not generally
        agree, find out why and either correct the problems or stop using
        defective servers. See <xref target="Monitoring"/> for more
        information.</t>
      </section>

      <section title="Use a diversity of Reference Clocks">
        <t>If you are using servers with attached hardware reference
        clocks, it is recommended that you use several different types of 
        reference clocks. Having a diversity of sources means that any
        one issue is less likely to cause a service interruption.</t>
        <t>Are all your clocks from the same vendor? Are they using the same
        base chipset, regardless of whether or not the finished products are
        from different vendors? Are they all running the same version of
        firmware?  Chipset and firmware bugs can happen, but is often more
                difficult to diagnose than a standard software bug.</t>
                <t>GA systemic problem with time from any satellite navigation
        service is possible and has happened. Sunspot activity can render
        satellite or radio-based time source unusable.</t>
      </section>

      <section anchor="mode67" title="Mode 6 and 7">
        <t>NTP Mode 6 (ntpq) and Mode 7 (ntpdc) packets are designed to permit
        monitoring and optional authenticated control of ntpd and its
        configuration. Used properly, these facilities provide vital debugging
        and performance information and control. Used improperly, these
        facilities can be an abuse vector.</t>

        <t>Mode 7 queries have been disabled by default since 4.2.7p230,
        released on 2011/11/01. Unless you have a good reason for using ntpdc,
        do not enable Mode 7.</t>

        <t>The ability to use Mode 6 beyond its basic monitoring capabilities
        can be limited to authenticated sessions that provide a 'controlkey',
        and similarly, if Mode 7 has been explicitly enabled its use for more
        than masic monitoring can be limited to authenticated sessions that
        provide a 'requestkey'.</t>

        <t>Older versions of the reference implementation of NTP could be
        abused to participate in high-bandwidth DDoS attacks. Starting with
        ntp-4.2.7p26, released in April of 2010, ntpd requires the use of a
        nonce before replying with potentially large response packets. <!-- Cite relevant CVEs, NTP bug reports, and release notes? --></t>

        <t>As mentioned above, there are two general ways to use Mode 6 and
        Mode 7 requests. One way is to query ntpd for information, and this
        mode can be disabled with:</t>

        <t>restrict ... noquery</t>

        <t>The second way to use Mode 6 and Mode 7 requests is to modify
        ntpd's behavior. Modification of ntpd ordinarily requires an
        authenticated session. By default, if no authentication keys have been
        specified no modifications can be made. For additional protection, the
        ability to perform these modifications can be controlled with:</t>

        <t>restrict ... nomodify</t>

        <!-- Should we talk about notrap ? -->

        <!-- the following ntp.conf fragment examples are version-specific.
             Which versions should we show examples for? -->

        <t>Users can prevent their NTP servers from participating by adding
        the following to their ntp.conf file:</t>

        <t>restrict default -4 nomodify notrap nopeer noquery</t>

        <t>restrict default -6 nomodify notrap nopeer noquery</t>

        <t>restrict source nomodify notrap noquery # nopeer is OK if you don't
        use the 'pool' directive</t>
      </section>

      <section anchor="Monitoring" title="Monitoring">
        <t>The reference implementation of NTP allows remote monitoring. The
        access to this service is controlled by the restrict statement in
        NTP's configuration file (ntp.conf). The syntax reads:</t>

        <figure>
          <artwork><![CDATA[restrict address mask address_mask nomodify]]></artwork>
        </figure>

        <t>Monitor your ntpd instances so machines that are "out of sync" can
        be quickly identified. Monitor your system logs for messages from ntpd
        so abuse attempts can be quickly identified.</t>

        <t>If your system starts getting unexpected time replies from its time
        servers, that can be an indication that the IP address of your server
        is being forged in requests to that time server, and these abusers are
        trying to convince your time servers to stop serving time to you.</t>

        <!-- Cite CVEs, BU paper, bug reports? -->

        <t>If your system is a broadcast client and your syslog shows that you
        are receiving "early" time messages from your server, that is an
        indication that somebody may be forging packets from a broadcast
        server.</t>

        <!-- Cite CVEs, BU paper, bug reports? -->

        <t>If your syslog shows messages that indicate you are receiving
        timestamps that are earlier than the current system time, then either
        your system clock is unusually fast or somebody is trying to launch a
        replay attack against your server.</t>

        <!-- Cite CVEs, BU
        paper, bug reports? -->

        <t>If you are using broadcast mode and have ntp-4.2.8p6 or later, use
        the 4th field of the ntp.keys file to identify the IPs of machines
        that are allowed to serve time to the group.</t>

        <!-- Cite
        CVEs, BU paper, bug reports? -->
      </section>

      <section title="Using Pool Servers">
        <t>It only takes a small amount of bandwidth and system resources to
        synchronize one NTP client, but NTP servers that can service tens of
        thousands of clients take more resources to run. Users who want to
        synchronize their computers should only synchronize to servers that
        they have permission to use.</t>

        <t>The NTP pool project is a collection of volunteers who have donated
        their computing and bandwidth resources to provide time on the
        Internet for free. The time is generally of good quality, but comes
        with no guarantee whatsoever. If you are interested in using the pool,
        please review their instructions at <eref
        target="http://www.pool.ntp.org/en/use.html">
        http://www.pool.ntp.org/en/use.html</eref>.</t>

        <t>If you want to synchronize many computers using the pool, consider
        running your own NTP servers, synchronizing them to the pool, and
        synchronizing your clients to your in-house NTP servers. This reduces
        the load on the pool.</t>

        <t>Set up or sponsor one or more pool servers.</t>
      </section>

      <section title="Leap Second Handling">
        <t>The UTC timescale is kept in sync with the rotation of the earth
        through the use of leap seconds. NTP time is based on the UTC
        timescale, and the protocol has the capability to broadcast leap
        second information. Some GNSS systems (like GPS) broadcast leap second
        information, so if you have a Stratum-1 server synced to GNSS (or you
        are synced to a lower stratum server that is ultimately synced to
        GNSS), you will get advance notification of impending leap seconds
        automatically.</t>

        <t>While earlier versions of NTP contained some ambiguity regarding when
        leap seconds could occur, RFC 5905 is clear that leap seconds are 
        processed at the end of a month. If an upstream server is broadcasting 
        that a leap second is pending, RFC5905-compliant servers should apply
        it at the end of the last minute of the last day of the month.</t>

        <t>The IETF maintains a leap second list 
        (https://www.ietf.org/timezones/data/leap-seconds.list) for NTP users who
        are not receiving leap second information through an automatic source.
        The use of leap second files requires ntpd 4.2.6 or later.  
        After fetching the leap seconds file onto the server, add this line to
        ntpd.conf to apply the file:</t>

        <t>leapfile "/path/to your/leap-file"</t>

        <t>You will need to restart to apply the changes.</t>

        <t>Files are also available from other sources:</t>
        <t>NIST: ftp://time.nist.gov/pub/leap-seconds.list</t>
        <t>US Navy (maintains GPS Time): ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list</t>
        <t>IERS (announces leap seconds): https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</t>

        <t>Servers with a manually configured leap second file will ignore
        leap second information broadcast from upstream NTP servers until the 
        leap second file expires.</t>

        <section anchor="leap_smear" title="Leap Smearing">
          <t>Some NTP installations may instead make use of a technique called
          "Leap Smearing". With this method, instead of introducing an extra
          second (or eliminating a second), NTP time will be slewed in small
          increments over a comparably large window of time around the leap
          second event. The amount of the slew should be small enough that
          clients will follow the smeared time without objecting. During the
          adjustment window, the NTP server's time may be offset from UTC by
          as much as .5 seconds. This is done to enable software that doesn't
          deal with minutes that have more or less than 60 seconds to function
          correctly, at the expense of fidelity to UTC during the smear
          window.</t>

          <!--find a reference, possibly Google or Meinberg -->

          <t>Leap Smearing was introduced in ntpd versions 4.2.8.p3 and
          4.3.47. Support is not configured by default and must be added at
          compile time. In addition, no leap smearing will occur unless a leap
          smear interval is specified in ntpd.conf . For more information,
          refer to <eref
          target="http://bk1.ntp.org/ntp-stable/README.leapsmear?PAGE=anno">
          http://bk1.ntp.org/ntp-stable/README.leapsmear?PAGE=anno</eref>.</t>

          <t>Leap Smearing must not be used for 
          public-facing NTP servers, as they will disagree with non-smearing 
          servers (as well as UTC) during the leap smear interval. However, 
          be aware that some public-facing servers may be configured this way 
          anyway in spite of this guidance. </t>
          
          <t>System Administrators are advised to be 
          aware of impending leap seconds and how the servers (inside and 
          outside their organization) they are using deal with them. 
          Individual clients must never be configured to use a mixture of 
          smeared and non-smeared servers.</t>

        </section>
      </section>
    </section>
      <section title="NTP Security Mechanisms">
        <t>In the standard configuration NTP packets are exchanged unprotected
        between client and server. An adversary that is able to become a
        Man-In-The-Middle is therefore able to drop, replay or modify the
        content of the NTP packet, which leads to degradation of the time
        synchronization or the transmission of false time information. A
        profound threat analysis for time synchronization protocols are given
        in <xref target="RFC7384">RFC 7384</xref>. NTP provides two internal 
        security mechanisms to protect authenticity and integrity of the NTP packets.
        Both measures protect the NTP packet by means of a Message
        Authentication Code (MAC). Neither of them encrypts the NTP's payload,
        because it is not considered to be confidential.</t>

        <section title="Pre-Shared Key Approach">
          <t>This approach applies a symmetric key for the calculation of the
          MAC, which protects authenticity and integrity of the exchanged
          packets for a association. NTP does not provide a mechanism for the
          exchange of the keys between the associated nodes. Therefore, for
          each association, keys have to be exchanged securely by external
          means. It is recommended that each association is protected by its
          own unique key. NTP does not provide a mechanism to automatically
          refresh the applied keys. It is therefore recommended that the
          participants periodically agree on a fresh key. The calculation of
          the MAC may always be based on an MD5 hash. If the NTP daemon is
          built against an OpenSSL library, NTP can also base the calculation
          of the MAC upon the SHA-1 or any other digest algorithm supported by
          each side's OpenSSL library.</t>

          <t>To use this approach the communication partners have to exchange
          the key, which consists of a keyid with a value between 1 and 65534,
          inclusive, and a label which indicates the chosen digest algorithm.
          Each communication partner adds this information to their key file
          in the form:</t>

          <figure>
            <artwork><![CDATA[keyid label key]]></artwork>
          </figure>

          <t>The key file contains the key in clear text. Therefore it should
          only be readable by the NTP process. Different keys are added line
          by line to the key file.</t>

          <t>A NTP client establishes a protected association by appending the
          option "key keyid" to the server statement in the NTP configuration
          file:</t>

          <figure>
            <artwork><![CDATA[server address key keyid]]></artwork>
          </figure>

          <t>Note that the NTP process has to trust the applied key. An NTP
          process explicitly has to add each key it want to trust to a list of
          trusted keys by the "trustedkey" statement in the NTP configuration
          file.</t>

          <figure>
            <artwork><![CDATA[trustedkey keyid_1 keyid_2 ... keyid_n]]></artwork>
          </figure>

          <t/>
        </section>

        <section title="Autokey">
          <t>Autokey was designed in 2003 to provide a means for clients to
          authenticate servers. By 2011, security researchers had identified
          computational areas in the Autokey protocol that, while secure at
          the time of its original design, were no longer secure. Work was
          begun on an enhanced replacement for Autokey, which was called <eref
          target="https://tools.ietf.org/html/draft-ietf-ntp-network-time-security-00">
          Network Time Security (NTS)</eref>. NTS was published in the summer
          of 2013. As of February 2016, this effort was at draft #13, and
          about to begin 'final call'. The first unicast implementation of NTS
          was started in the summer of 2015 and is expected to be released in
          the summer of 2016.</t>

          <t>We recommend that Autokey NOT BE USED. Know that as of the fall
          of 2011, a common(?) laptop computer could crack the security cookie
          used in the Autokey protocol in 30 minutes' time. If you must use
          Autokey, know that your session keys should be set to expire in
          under 30 minutes' time. If you have reason to believe your
          autokey-protected associations will be attacked, you should read
          https://lists.ntp.org/pipermail/ntpwg/2011-August/001714.html and
          decide what resources your attackers might be using, and adjust the
          session key expiration time accordingly.</t>
        </section>

        <section title="External Security Means">
          <t>TBD</t>
        </section>
      </section>

    <section title="NTP Security Best Practices">
      <section title="Minimizing Information Leakage">
        <t>The base NTP packet leaks important information (including reference
           ID and reference time) that can be used in attacks 
           <xref target="NDSS16"></xref>, <xref target="CVE-2015-8138"></xref>, 
           <xref target="CVE-2016-1548"></xref>.  A remote attacker can learn 
           this information by sending mode 3 queries to a target system and 
           inspecting the fields in the mode 4 response packet.  NTP control 
           queries also leak important information (including reference ID, 
           expected origin timestamp, etc) that can be used in attacks 
           <xref target="CVE-2015-8139"></xref>.  A remote attacker can learn 
           this information by sending control queries to a target system and 
           inspecting the response.</t>

           <t>As such, access control should be used to limit the exposure of 
           this information to third parties.</t> 

           <t>All hosts should only respond to NTP control queries from 
           authorized parties.  One way to do this is to only allow control 
           queries from authorized IP addresses.</t>

           <t>A host that is not supposed to act as an NTP server that provides 
           timing information to other hosts should additionally drop incoming 
           mode 3 timing queries.</t>

           <t>An "end host" is host that is using NTP solely for the purpose of 
           setting its own local clock.  Such a host is not expected to provide 
           time to other hosts, and relies exclusively on NTP's basic mode to 
           take time from a set of servers. (That is, the host sends mode 3 
           queries to its servers and receives mode 4 responses from these 
           servers containing timing information.) To minimize information 
           leakage, end hosts should drop all incoming NTP packets except mode 4 
           response packets that come from its configured servers.</t>
      </section>
      <section title="Avoiding Reboot Attacks">
          <t><xref target="RFC5905"></xref> says NTP clients should not accept 
          time shifts greater than the panic threshold. Specifically, RFC5905 
          says "PANIC means the offset is greater than the panic threshold 
          PANICT (1000 s) and SHOULD cause the program to exit with a diagnostic 
          message to the system log.</t>

          <t>However, this behavior can be exploited by attackers 
          <xref target="NDSS16"></xref>, when the following two conditions hold:
          </t>

          <t><list style="numbers">
            <t>The operating system automatically restarts the NTP daemon when 
            it quits. (Modern *NIX operating systems are replacing traditional 
            init systems with process supervisors, such as systemd, which can 
            be configured to automatically restart any daemons that quit. This 
            behavior is the default in CoreOS and Arch Linux. It is likely to 
            become the default behavior in other systems as they migrate legacy 
            init scripts to systemd.)</t>
          
            <t>The NTP daemon ignores the panic threshold when it first reboots. 
            (This is sometimes called the -g option.)</t>
          </list></t>

          <t>In such cases, the attacker can send the target an offset that 
          exceeds the panic threshold, causing the client to quit.  Then, when 
          the client reboots, it ignores the panic threshold and accepts the 
          attacker's large offset.</t>

          <t>Hosts running with the above two conditions should be aware that 
          the panic threshold does not protect them from attacks. A natural 
          solution is not to run hosts with these conditions.</t>

          <t>As an alternative, the following steps could be taken to mitigate 
          he risk of attack.</t>
          <t><list style="symbols">
             <t>Monitor NTP system log to detect when the NTP daemon has quit 
             due to a panic event, as this could be a sign of an attack.</t>

             <t>Request manual intervention when a timestep larger than the 
             panic threshold is detected.</t> 
             <t>Prevent the NTP daemon from taking time steps that set the 
             clock to a time earlier than the compile date of the NTP 
             daemon.</t>
            
             <t>Modify the NTP daemon so that it "hangs" (ie does not quit, 
             but just waits for a better timing samples but does not modify 
             the local clock) when it receives a large offset.</t>
          </list></t>

      </section>
      
      <section title="Detection of Attacks Through Monitoring">
        <t>Users should monitor their NTP instances to detect attacks. Many 
        known attacks on NTP have particular signatures.  Common attack 
        signatures include:</t>
        
        <t><list style="numbers">
          <t>"Bogus packets" -  A packet whose origin timestamp does not match 
             the value that expected by the client.</t>
          <t>"Zero origin packet" -  A packet with a origin timestamp set to 
             zero <xref target="CVE-2015-8138"></xref>.</t>
          <t>A packet with an invalid cryptographic MAC <xref target="CCR16">
          </xref>.</t>
        </list></t>

        <t>The observation of many such packets could indicate that the client 
        is under attack. </t>

        <t>Also, Kiss-o'-Death (KoD) packets can be used in denial of service 
        attacks.  Thus, the observation of even just one KoD packet with a high 
        poll value (e.g. poll>10) could be sign that the client is under attack. 
        </t>
      </section>

      <section title="Broadcast Mode Should Only Be Used On Trusted Networks">
        <t>Per <xref target="RFC5905"></xref>, NTP's broadcast mode is 
        authenticated using symmetric key cryptography.  The broadcast server 
        and all of its broadcast clients share a symmetric cryptographic key, 
        and the broadcast server uses this key to append a message 
        authentication code (MAC) to the broadcast packets it sends.</t>

        <t>Importantly, all broadcast clients that listen to this server 
        must know the cryptographic key. This mean that any client can use this 
        key to send valid broadcast messages that look like they come from the 
        broadcast server. Thus, a rogue broadcast client can use its knowledge 
        of this key to attack the other broadcast clients.</t>

        <t>For this reason, an NTP broadcast server and all its client must 
        trust each other.  Broadcast mode should only be run from within a 
        trusted network. </t>
      </section>

      <section title="Symmetric Mode Should Only Be Used With Trusted Peers">
        <t>In symmetric mode, two peers Alice and Bob can both push and pull 
        synchronization to and from each other using either ephemeral symmetric 
        passive (mode 2) or persistent symmetric active (NTP mode 1) packets. 
        The persistent association is preconfigured and initiated at the active 
        peer but not preconfigured at the passive peer (Bob). Upon arrival of a 
        mode 1 NTP packet from Alice, Bob mobilizes a new ephemeral association 
        if he does not have one already.  This is a security risk for Bob 
        because an arbitrary attacker can attempt to change Bob's time by asking 
        Bob to become its symmetric passive peer.</t>

        <t>For this reason, a host (Bob) should only allow symmetric passive 
        associations to be established with trusted peers.  Specifically, Bob 
        should require each of its symmetric passive association to be 
        cryptographically authenticated.  Each symmetric passive association 
        should be authenticated under a different cryptographic key.</t>

        <t>The use of a different cryptographic key per peer prevents Sybil 
        attacks.  If a target host uses the same key is to authenticate all 
        symmetric peers, then a malicious peer could attempt to set up multiple 
        symmetric associations with the target host in order to bias the result 
        of the target's Byzantine fault tolerant selection algorithms. </t>
      </section>
    </section>

    <section title="NTP in Embedded Devices">
      <t>Readers of this BCP already understand how important accurate time is
      for network computing. And as computing becomes more ubiquitous, there
      will be many small "Internet of Things" devices that require accurate
      time. These embedded devices may not have a traditional user interface,
      but if they connect to the Internet they will be subject to the same
      security threats as traditional deployments.</t>

      <section title="Updating Embedded Devices">
        <t>Vendors of embedded devices have a special responsibility to pay
        attention to the current state of NTP bugs and security issues,
        because their customers usually don't have the ability to update their
        NTP implementation on their own. Those devices may have a single
        firmware upgrade, provided by the manufacturer, that updates all
        capabilities at once. This means that the vendor assumes the
        responsibility of making sure their devices have the latest NTP
        updates applied.</t>

        <t>This should also include the ability to update the NTP server
        address.</t>

        <t>(Note: do we find specific historical instances of devices behaving
        badly and cite them here?)</t>
      </section>

      <section title="KISS Packets">
        <t>The "Kiss-o'-Death" (KoD) packet is a rate limiting mechanism where
        a server can tell a misbehaving client to "back off" its query rate.
        It is important for all NTP devices to respect these packets and back
        off when asked to do so by a server. It is even more important for an
        embedded device, which may not have exposed a control interface for
        NTP.</t>

        <t>The KoD mechanism relies on clients behaving properly in order to
        be effective. Some clients ignore the KoD packet entirely, and other
        poorly-implemented clients might unintentionally increase their poll
        rate and simulate a denial of service attack. Server administrators
        should be prepared for this and take measures outside of the NTP
        protocol to drop packets from misbehaving clients.</t>
      </section>

      <section title="Server configuration">
        <t>Vendors of embedded devices that need time synchronization should
        also carefully consider where they get their time from. There are
        several public-facing NTP servers available, but they may not be
        prepared to service requests from thousands of new devices on the
        Internet.</t>

        <t>Vendors are encouraged to invest resources into providing their own
        time servers for their devices.</t>

        <section title="Get a vendor subdomain for pool.ntp.org">
          <t>The NTP Pool Project offers a program where vendors can obtain
          their own subdomain that is part of the NTP Pool. This offers
          vendors the ability to safely make use of the time distributed by
          the Pool for their devices. Vendors are encouraged to support the
          pool if they participate. For more information, visit <eref
          target="http://www.pool.ntp.org/en/vendors.html">
          http://www.pool.ntp.org/en/vendors.html</eref> .</t>
        </section>
      </section>
    </section>

    <section title="NTP Deployment Examples">
      <t>A few examples of interesting NTP Deployments</t>

      <!-- These should likely be version-specific. -->

      <section title="Client-Only configuration">
        <t>TBD</t>
      </section>

      <section title="Server-Only Configuration">
        <t>TBD</t>
      </section>

      <section title="Anycast">
        <t>Anycast is described in <xref target="RFC4786">BCP 126</xref>.
        (Also see <xref target="RFC7094">RFC 7094</xref>). With anycast, a
        single IP address is assigned to multiple interfaces, and routers
        direct packets to the closest active interface.</t>

        <t>Anycast is often used for Internet services at known IP addresses,
        such as DNS. Anycast can also be used in large organizations to
        simplify configuration of a large number of NTP clients. Each client
        can be configured with the same NTP server IP address, and a pool of
        anycast servers can be deployed to service those requests. New servers
        can be added to or taken from the pool, and other than a temporary
        loss of service while a server is taken down, these additions can be
        transparent to the clients.</t>

        <t>If clients are connected to an NTP server via anycast, the client
        does not know which particular server they are connected to. As
        anycast servers may arbitrarily enter and leave the network, the
        server a particular client is connected to may change. This may cause
        a small shift in time from the perspective of the client when the
        server it is connected to changes. It is recommended that anycast be
        deployed in environments where these small shifts can be
        tolerated.</t>

        <t>Configuration of an anycast interface is independent of NTP.
        Clients will always connect to the closest server, even if that server
        is having NTP issues. It is recommended that anycast NTP
        implementations have an independent method of monitoring the
        performance of NTP on a server. In the event the server is not
        performing to specification, it should remove itself from the Anycast
        network. It is also recommended that each Anycast NTP server have at
        least one Unicast interface, so its performance can be checked
        independently of the anycast routing scheme.</t>

        <t>One useful application in large networks is to use a hybrid
        unicast/anycast approach. Stratum 1 NTP servers can be deployed with
        unicast interfaces at several sites. Each site may have several
        Stratum 2 servers with a unicast interface and an anycast interface
        (with a shared IP address per location). The unicast interfaces can be
        used to obtain time from the Stratum 1 servers globally (and perhaps
        peer with the other Stratum 2 servers at their site). Clients at each
        site can be configured to use the shared anycast address for their
        site, simplifying their configuration. Keeping the anycast routing
        restricted on a per-site basis will minimize the disruption at the
        client if its closest anycast server changes.</t>

        <!-- Should there be a diagram here? -->
      </section>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The authors wish to acknowledge the contributions of Sue Graves,
      Samuel Weiler, Lisa Perdue, Karen O'Donoghue, David Malone, and
      Sharon Goldberg.</t>
    </section>

    <!-- Possibly a 'Contributors' section ... -->

    <section anchor="IANA" title="IANA Considerations">
      <t>This memo includes no request to IANA.</t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>TBD</t>

      <!--This entire document is one big Security Consideration. Do we 
          just reference the appropriate sections? -->

      <!-- SW: We need to also say that 1) NTP security
            considerations, in general, are discussed in RFC XXX; and
            2) the suggestions in this doc do not have security
            impacts (to the extent that is true).  -->
    </section>
  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->

      &RFC2119;

      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5905.xml"?-->

      &RFC5905;

      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2827.xml"?-->

      &RFC2827;

      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2827.xml"?-->

      &RFC4786;

      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2827.xml"?-->

      &RFC7094;

      <?rfc include='reference.RFC.7384'?>
    </references>

    <!-- Here we use entities that we defined at the beginning. -->

    <references title="Informative References">

<!-- DPR TODO: figure out the right way to list these references -->

<!-- [NDSS16] Attacking the Network Time Protocol. Aanchal Malhotra, Isaac E. Cohen, Erik Brakke and Sharon Goldberg NDSS'16, San Diego, CA. Feb 2016.    https://eprint.iacr.org/2015/1020.pdf -->

      <reference anchor="NDSS16"
                 target="https://eprint.iacr.org/2015/1020.pdf">
        <front>
          <title>Attacking the Network Time Protocol</title>
          <author surname="Malhotra">
            <organization></organization>
          </author>
          <author surname="Cohen">
            <organization></organization>
          </author>
          <author surname="Brakke">
            <organization></organization>
          </author>
          <author surname="Goldberg">
            <organization></organization>
          </author>
          <date year="2016" />
        </front>
      </reference>

<!--
[CCR16] 
Attacking NTP's Authenticated Broadcast Mode. Aanchal Malhotra and Sharon Goldberg. SIGCOMM Computer Communications Review (CCR), April 2016.
-->

      <reference anchor="CCR16">
        <front>
          <title>Attacking NTP's Authenticated Broadcast Mode</title>
          <author surname="Malhotra">
            <organization></organization>
          </author>
          <author surname="Goldberg">
            <organization></organization>
          </author>
          <date year="2016" />
        </front>
      </reference>

<!--
[CVE-2015-8138] 
NETWORK TIME PROTOCOL ORIGIN TIMESTAMP CHECK IMPERSONATION VULNERABILITY.  Matthew Van Gundy, Jonathan Gardner. JANUARY 19, 2016 http://www.talosintel.com/reports/TALOS-2016-0077/
-->

      <reference anchor="CVE-2015-8138" target="http://www.talosintel.com/reports/TALOS-2016-0077">
        <front>
          <title>NETWORK TIME PROTOCOL ORIGIN TIMESTAMP CHECK IMPERSONATION VULNERABILITY</title>
          <author surname="Van Gundy">
            <organization></organization>
          </author>
          <author surname="Gardner">
            <organization></organization>
          </author>
          <date year="2016" />
        </front>
      </reference>

<!--
[CVE-2016-1548] Xleave Pivot: NTP Basic Mode to Interleaved. Jonathan Gardner, Miroslav Lichvar. April 27, 2016. http://blog.talosintel.com/2016/04/vulnerability-spotlight-further-ntpd_27.html
-->

      <reference anchor="CVE-2016-1548" target="http://blog.talosintel.com/2016/04/vulnerability-spotlight-further-ntpd_27.html">
        <front>
          <title>Xleave Pivot: NTP Basic Mode to Interleaved</title>
          <author surname="Gardner">
            <organization></organization>
          </author>
          <author surname="Lichvar">
            <organization></organization>
          </author>
          <date year="2016" />
        </front>
      </reference>

<!--
[CVE-2015-8139] 
NETWORK TIME PROTOCOL NTPQ AND NTPDC ORIGIN TIMESTAMP DISCLOSURE VULNERABILITY
Matthew Van Gundy. JANUARY 19, 2016
http://www.talosintel.com/reports/TALOS-2016-0078/
-->

      <reference anchor="CVE-2015-8139" target="http://www.talosintel.com/reports/TALOS-2016-0078">
        <front>
          <title>NETWORK TIME PROTOCOL NTPQ AND NTPDC ORIGIN TIMESTAMP DISCLOSURE VULNERABILITY</title>
          <author surname="Van Gundy">
            <organization></organization>
          </author>
          <date year="2016" />
        </front>
      </reference>
 
    </references> 
   

    <!--
    <section anchor="app-additional" title="Additional Stuff">
      <t>This becomes an Appendix.</t>
    </section>
-->

    <!-- Change Log

v00 2015-09-18  DPR Initial Submission   
v01 2016-03-09  DPR 1st Rev after submissions from Harlan, Dieter
v02 2016-06-08  DPR 2nd Rev, incudes input from David Malone, Sharon Goldberg
                                                                                        -->
  </back>
</rfc>
