[core] Reviewing KUDOS (draft-ietf-core-oscore-key-update-08)

Chistian Amsüss <christian@amsuess.com> Fri, 19 July 2024 21:50 UTC

Return-Path: <christian@amsuess.com>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 76654C14F5F2; Fri, 19 Jul 2024 14:50:29 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.909
X-Spam-Level:
X-Spam-Status: No, score=-6.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LJw4XTco8nt8; Fri, 19 Jul 2024 14:50:27 -0700 (PDT)
Received: from smtp.akis.at (smtp.akis.at [IPv6:2a02:b18:500:a515::f455]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 9D2E8C14F686; Fri, 19 Jul 2024 14:50:12 -0700 (PDT)
Received: from poseidon-mailhub.amsuess.com ([IPv6:2a02:b18:c13b:8010:a800:ff:fede:b1bd]) by smtp.akis.at (8.17.2/8.17.2) with ESMTPS id 46JLo6gr091496 (version=TLSv1.2 cipher=ECDHE-ECDSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jul 2024 23:50:06 +0200 (CEST) (envelope-from christian@amsuess.com)
X-Authentication-Warning: smtp.akis.at: Host [IPv6:2a02:b18:c13b:8010:a800:ff:fede:b1bd] claimed to be poseidon-mailhub.amsuess.com
Received: from poseidon-mailbox.amsuess.com (hermes.lan [10.13.13.254]) by poseidon-mailhub.amsuess.com (Postfix) with ESMTP id 5E91C3F1EE; Fri, 19 Jul 2024 23:50:04 +0200 (CEST)
Received: from hephaistos.amsuess.com (unknown [91.113.201.1]) by poseidon-mailbox.amsuess.com (Postfix) with ESMTPSA id 06618386F8; Fri, 19 Jul 2024 23:50:02 +0200 (CEST)
Received: (nullmailer pid 14198 invoked by uid 1000); Fri, 19 Jul 2024 21:50:02 -0000
Date: Fri, 19 Jul 2024 23:50:02 +0200
From: Chistian Amsüss <christian@amsuess.com>
To: draft-ietf-core-oscore-key-update@ietf.org, core@ietf.org
Message-ID: <DDAEE0FF-CE24-44BE-BA49-3A88CCF549EA@amsuess.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="ni8/481At4H0f6VQ"
Content-Disposition: inline
X-Scanned-By: MIMEDefang 2.86
Message-ID-Hash: 2XVHC4SATPPZXYAEZYJIEHOJS63QAGSQ
X-Message-ID-Hash: 2XVHC4SATPPZXYAEZYJIEHOJS63QAGSQ
X-MailFrom: christian@amsuess.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-core.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
X-Mailman-Version: 3.3.9rc4
Precedence: list
Reply-To: NS00OWI1LWFmZDktNGU5OWIyNmZkNjZk%3ANQ%3D%3D%3AMjI3MQ%3D%3D&p=1317&q=NONE@hephaistos.amsuess.com
Subject: [core] Reviewing KUDOS (draft-ietf-core-oscore-key-update-08)
List-Id: "Constrained RESTful Environments (CoRE) Working Group list" <core.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/core/QGS8QfeySlrTKYRvFnEH7laxBDk>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Owner: <mailto:core-owner@ietf.org>
List-Post: <mailto:core@ietf.org>
List-Subscribe: <mailto:core-join@ietf.org>
List-Unsubscribe: <mailto:core-leave@ietf.org>

Hello KUDOS authors, hello group,

I've read the KUDOS draft, and have some comments. Next to many small
ones, I think that we could do a bit better on the mechanisms's
simplicity and robustness -- in particular, one item in this list (with
the working title "vector agreement") makes a concrete proposal on how
to enhance it.

* 3: Given what core-responses generalizes, might it male sense to roll
  those into one and say that a respose nonce may only be used if the
  seqno was just removed from the context used to protect?

* 3: "which is secure although not complying with the above.": I'd
  appreciate some more explaination, "which is secure without this by
  deriving a new key for the relevant message."

* Preserving observations (or long-running requests in general?) uses a
  different mechanism than Group OSCORE. Was it whether it'd make sense
  to negotiate KUDOS support ahead of context setup (AIU that's needed
  anyway lest the first use results in unprotected failures), and then
  use the Group OSCORE AAD for KUDOS contexts? I think it'd be a step
  that keeps OSCORE's evolution linear.

  I haven't thought through all effects, but one may be that it could
  obsolete the need for a b flag.

  This would require pre-agreement of whether or not KUDOS will be
  available for a given OSCORE context, but that doesn't sound
  unreasonable to me -- after all, any OSCORE setup is subject to a lot
  of agreement (eg. on the algorithm) already.

* What's the point of having discoverable core.kudos resources? The
  kudos resource is already effectively just a no-op resource (because
  OSCORE processing happens before application processing), what'd be
  the point in discovering any other? FWIW, a server should legitimately
  be allowed to just not implement the KUDOS resource (just 4.04 it),
  and things would still work out just as fine. The discovery mechanism
  and the additional mentions of the resource ("If the corresponding
  CoAP request has targeted a KUDOS resource") make the document more
  verbose than it needs to be.

* Figure 2 is an odd mix of pseudocode and CDDL. Unless all of this can
  be expressed in CDDL (eg. using .cat instead of |), I think this would
  be more readable if sticking to the pseudocode style (or consistent
  CDDL style if it can be expressed that way).

* 4.3: Contains a lot of text that is not FS related (eg all of 4.3.1).
  I don't have concrete suggestions there, but I wonder whether an
  integrated text with some "if"s or a small 4.5 that just describes the
  delta might be preferable.

* Handling of messages: "MUST reply to the first KUDOS message [...]
  with a CoAP Reset message": This message is not available on all
  transports (eg. not on CoAP-over-TCP), and not end-to-end. I'd make
  suggestions on how to enhance it if not for item "vector agreement".

* In the distinction between capable devices and non-capable devices, it
  may be lost that even a non-capable device may be running in
  persistent mode sometimes:

  Take a "flash-less" device that creates its OSCORE context by being
  the RS of an ACE-OSCORE exchange. The device would keep the created
  context only in RAM anyway. (Another ACE-OSCORE RS may store them, but
  it's generally not assumed that those contexts live forever). If that
  device does then advertise 'p' mode, no harm comes of it: The whole
  context is only in RAM, so if the device reboots, it will not fall
  back to the originally established OSCORE context (which would be bad
  b/c the peers would be out of sync) but to not even knowing that
  context, and the client just sends the token again.

* I'm not sure the lockstepping works fully:

  What happens if a client initiates forward flow, the server
  contributes a nonce, and the client receives confirmation in the form
  of a response. The client thus confirms CTX_NEW and discards CTX_OLD.
  But the server has not achieved confirmation, and both devices lose
  power. When the client comes up, it assumes all is in working shape
  and does not send KUDOS. Will the server have persisted enough
  information to recover all state? It may well work, but I think some
  rules on when which state is committed to would help.

* Having forward flow, reverse flow and the simultaneous execution
  fallback mechanism appears a bit more complex to me than it may need
  to be -- especially because it needs care to avoid deadlocks, which
  are resolved in rare code paths (eg. "Note that the server achieves",
  where I'm not convinced by the text that it is deadlock free if both
  parties constantly try to update the context simultaneously, as it may
  happen with long RTTs).

  I'd like to suggest an alternative pattern that achieves the same end
  goal (working title "vector agreement"; this is a sketch, and not fully
  thought through):

  * The capable parties only ever persist
    * the old context or the new context
    * the number of nonces either party has contributed contributed modulo 2
    * the nonce it contributed (until it has been confirmed)

  * As soon as a party decides on a nonce to send, it commits to that
    nonce (persisting it before sending it). It sends that latest nonce in the
    "N" field until it has been confirmed, and the modulo bits of the
    parties in "X".

    As any confirmation of a nonce is coupled with the peer's nonce, the
    number of nonces the peers have contributed differ by at most 1.
    (And they may have temporary contexts that diverge in which nonces
    have been contributed).

  * Rather than concatenating a distinct X with a distinct Y, the
    parties' nonces are sorted.

  * As soon as a party sees that both parties have contributed the same
    number of nonces, it can discard the old state. As soon as a party
    sees that the peer has acknowledged this number of nonces, it may
    discard the nonce and stop sending it. Only then, the party may
    restart KUDOS.

  This is not yet fully thought through for non-capable parties (nor
  for the capable case, I hope to play this through during the
  hackathon or IETF week with you, but the non-capable even more so),
  but I think it works for those too and simplifies their handling: They
  indicate their unwillingness to persist, store whatever would be
  persisted in RAM instead, and key derivations where both parties have
  contributed the same number of nonces (and thus know whether either
  party didn't want it persisted), rules change slightly and the old
  state will still be the base for the next round.

  This has some desirable properties:

  * No message ever needs to carry two nonces (no "y" and "old_nonce"
    fields)

  * It completes successfully even when both parties initiate
    simultaneously, and the only overhead introduced by it are the cost
    of the nonces being sent in the responses as well. (So both
    initiating messages carry KUDOS nonces, and both subsequent messages
    carry KUDOS nonces).

  * It is explicit in what is persisted when.

  * The persistent storage requirements for the devices are lower: Only
    one context is stored at a time, plus a few bits, plus the latest
    own nonce (which can be generated deterministically, eg. using an
    in-device secret and the previous key). While typically embedded
    config updates take double-buffering, it takes a very
    smart-possibly-brittle system to keep both the old and the new
    alive, and allowing an atomic switch is easier (especially if
    failed-write loss of both the old and the new are acceptable, as is
    the case when there is EDHOC to fall back to).

  * It can be described without a forward or reverse flow.

  * Due to how the nonces are persisted, a server-initiated KUDOS run as
    in figure 6 does not necessitate an immediate request to
    /.well-known/kudos. The client can just decrypt the response with
    the CTX_1, roll up a new nonce, persist the nonce and the CTX_NEW
    replacing CTX_OLD (without even having confirmation of the full
    KUDOS run -- but it can trust that the server committed to the nonce
    it sent), and whenever they next talk, they continue from there --
    either by the client using the new context and sending the nonce, or
    by the server sending a request in role reversal mode (sending its
    nonce once more -- but it's still cheaper to send a nonce twice than
    to have an extra flight).

  * It does not strictly require the limitation on not doing more
    requests while KUDOS is running. Yes, those requests will all carry
    KUDOS nonces, but they can continue.

    Especially in situation with a high bandwidth-latency product (which
    in our case is mostly from high latency, as in CoAP-over-BP), this
    should be desirable.

    (Or does the latest paragraph of 4.3.4.1 just mean that sending more
    messages is permitted, but they all need to have a KUDOS option?)

  * If the persistence flag works out as I think it does with this mode,
    the whole topic of memorizing whether the peer is capable becomes
    unnecessary. This is especially convenient when a device has a
    limited budget for flash writes, and only in some situations can
    afford to persist.

    In particular, this does away with the dilemma of either storing
    whether the peer is capable or suffering a retried KUDOS run, and a
    lot of text in 4.5.2 (including the lengthy "As an exception" clause
    there), as well as simplify EDHOC signaling.

  * It opens up the possibility of using KUDOS with only one party
    contributing nonces, eg. when a server is entropy starved. Whether
    that's a good idea is a different story -- you can still forbid
    processing of a nonce acknowledgement without the acknowledging
    party's nonces also having the same count mod 2. Needs more thought
    anyway, but seems possible with only minor adjustments, if even
    desirable.

  (The working title is motivated by the image of the contexts being
  graphed upwards in some key space with one party moving the context up
  and right and the other party moving it up and left, with the amount
  up varying a bit by the nonce. Most of the time, one party initiates
  and the other follows, creating a zig-zag pattern. Occasionally, it's
  the other party that initiates, then the zig-zag goes in the other
  direction. If both start simultaneously, it diverges, but by
  commutativity of vector addition, they arrive at the same point, and
  can continue zig-sagging, or doing more diversions if they're very
  well synchronized. At all times, the both-parties-contributing-equally
  rule ensures that the braid doesn't leave the [-1, 1] corridor.)

* The need to cancel requests is unfortunate, especially in the context
  of CoAP-over-BP. OSCORE has a replay window, CoAP has an
  EXCHANGE_LIFETIME. Would it make sense for an old OSCORE context to be
  permitted for decryption for some more time? KUDOS recommends
  initiating the key update ahead of the events that force the key
  update -- until that event happens, the context can still be good.

* "It might be the case that the server is only a CoAP server": I expect
  this to be even a common case :-)

  Even if the server can not decrypt the request, does it have enough
  information to send an protected response anyway? It'd be an OSCORE
  protected 4.01 Unauthorized in any case, and access to the plain text
  of the request is not required to generate an OSCORE response.

  (I think it's still better than sending an unprotected response and
  hope that the client takes the hint to do KUDOS).

* (More an observation): I think we can't do anything for devices with
  low startup entropy for nonces: If they are capable, they can just use
  their persistence mechanism to keep their RNG well seeded (or employ a
  counter), and if they are not capable, they'd be prone to replays
  where an attacker can force them to encrypt twice with the same nonce
  (and being very deterministic in the KUDOS response they send doesn't
  help, because then the attacker can replay them up to the point where
  their data changes, and then see the delta in the bit pattern).

* Overhead calculations: I think those are missing that the OSCORE
  option's length is encoded in an extended way once the OSCORE option
  exceeds 12 bytes.

* Signaling KUDOS: Should there be a flag for that not only in EDHOC
  EADs but also in some ACE format, eg. for use with ACE-OSCORE?

Best regards
Christian