Draft: draft-ietf-ace-oscore-profile

Commentary: restructuring for readability adding a section for protocol overview adding examples for each message adding details about updating clients rights ( request new token with only scope different ) where before there were ref to the framework , explicitly state all the normative text add mechanism during OSCORE Setup for making sure the context is not reused on the server if token is re - posted after it has been lost / removed ( nonces ) section about access rights verification between OSCORE layer and CoAP ( handling of the resource ) layer
Paragraph (version A):
This memo specifies a profile of the ACE framework I-D.ietf-ace-
oauth-authz.  In this profile, a client and a resource server use
CoAP RFC7252 to communicate.  The client uses an access token, bound
to a key (the proof-of-possession key) to authorize its access to the
resource server.  In order to provide communication security, proof
of possession, and server authentication they use Object Security for
Constrained RESTful Environments (OSCORE) I-D.ietf-core-object-
security.  Optionally the client and the resource server may also use
CoAP and OSCORE to communicate with the authorization server.
Paragraph (version A):
OSCORE specifies how to use CBOR Object Signing and Encryption (COSE)
RFC8152 to secure CoAP messages.  In order to provide replay and
reordering protection OSCORE also introduces sequence numbers that
are used together with COSE.
Paragraph (version A):
Note that OSCORE can be used to secure CoAP messages, as well as HTTP
and combinations of HTTP and CoAP; a profile of ACE similar to the
one described in this document, with the difference of using HTTP
instead of CoAP as communication protocol, could be specified
analogously to this one.
Paragraph (version B):
This memo specifies a profile of the ACE framework I-D.ietf-ace-
oauth-authz.  In this profile, a client and a resource server use
CoAP RFC7252 to communicate.  The client uses an access token, bound
to a key (the proof-of-possession key) to authorize its access to the
resource server.  In order to provide communication security, proof
of possession, and server authentication they use Object Security for
Constrained RESTful Environments (OSCORE) I-D.ietf-core-object-
security.
Paragraph (version B):
OSCORE specifies how to use CBOR Object Signing and Encryption (COSE)
RFC8152 to secure CoAP messages.  Note that OSCORE can be used to
secure CoAP messages, as well as HTTP and combinations of HTTP and
CoAP; a profile of ACE similar to the one described in this document,
with the difference of using HTTP instead of CoAP as communication
protocol, could be specified analogously to this one.
Paragraph (version A):
Since we describe exchanges as RESTful protocol interactions HTTP
RFC7231 offers useful terminology.
Paragraph (version A):
Terminology for entities in the architecture is defined in OAuth 2.0
RFC6749 and I-D.ietf-ace-actors, such as client (C), resource server
(RS), and authorization server (AS).  It is assumed in this document
that a given resource on a specific RS is associated to a unique AS.
Paragraph (version A):
The use of OSCORE for arbitrary CoAP messages is specified in I-
D.ietf-core-object-security.  This section defines the specific uses
and their purpose for securing the communication between a client and
a resource server, and the parameters needed to negotiate the use of
this profile with the token resource at the authorization server as
specified in section 5.6 of I-D.ietf-ace-oauth-authz.
Paragraph (version A):
A client requests a token at an AS via the /token resource.  This
follows the message formats specified in section 5.6.1 of I-D.ietf-
ace-oauth-authz.
Paragraph (version A):
The AS responding to a successful access token request as defined in
section 5.6.2 of I-D.ietf-ace-oauth-authz can signal that the use of
OSCORE is REQUIRED for a specific access token by including the
"profile" parameter with the value "coap_oscore" in the access token
response.  This means that the client MUST use OSCORE towards all
resource servers for which this access token is valid, and follow
oscore-only to derive the security context to run OSCORE.
Paragraph (version A):
Note the the client and the authorization server MAY OPTIONALLY use
OSCORE to protect the interaction via the /token resource.  See c-as
for details.
Paragraph (version A):
Section 3.2 of I-D.ietf-core-object-security defines how to derive a
security context based on a shared master secret and a set of other
parameters, established between client and server.  The proof-of-
possession key (pop-key) provisioned from the AS MAY, in case of pre-
shared keys, be used directly as master secret in OSCORE.
Paragraph (version A):
Additionally, the AS MAY provision the following data, in the same
response.  In case these parameters are omitted, the default values
are used as described in section 3.2 of I-D.ietf-core-object-
security.
Paragraph (version B):
RESTful terminology follows HTTP RFC7231.
Paragraph (version B):
Terminology for entities in the architecture is defined in OAuth 2.0
RFC6749, such as client (C), resource server (RS), and authorization
server (AS).  It is assumed in this document that a given resource on
a specific RS is associated to a unique AS.
Paragraph (version B):
This section gives an overview on how to use the ACE Framework I-
D.ietf-ace-oauth-authz to secure the communication between a client
and a resource server using OSCORE I-D.ietf-core-object-security.
The parameters needed to negotiate the use of this profile with the
token resource at the authorization server as specified in section
5.6 of I-D.ietf-ace-oauth-authz are described in detail in the
following sections.
Paragraph (version B):
This profile requires a client to retrieve an access token from the
AS for the resource it wants to access on a RS, using the token
endpoint, as specified in section 5.6.1 of I-D.ietf-ace-oauth-authz.
To determine the AS in charge of a resource hosted at the RS, the
client C MAY send an initial Unauthorized Resource Request message to
the RS.  The RS then denies the request and sends the address of its
AS back to the client C as specified in section 5.1 of I-D.ietf-ace-
oauth-authz.  The access token request and response MUST be
confidentiality-protected and ensure authenticity.  This profile
RECOMMENDS the use of OSCORE between client and AS, but TLS or DTLS
MAY be used additionally or instead.
Paragraph (version B):
Once the client has retrieved the access token, it forwards it to the
RS using the authz-info endpoint and mechanisms specified in section
5.8.1. of I-D.ietf-ace-oauth-authz.  If the access token is valid,
the RS replies to this request with a 2.01 (Created) response, which
contains a nonce N1.
Paragraph (version B):
After receiving the nonce N1, the client generates a nonce N2,
concatenates it with N1 and sets the ID Context in its Security
Context (see section 3 of I-D.ietf-core-object-security) to N1
concatenated with N2.  The client then derives the complete Security
Context from the ID Context plus the parameters received from the AS.
Paragraph (version B):
Finally, the client sends a request protected with OSCORE to the RS.
This message contains the ID Context value.  When receiving this
request after the 2.01 (Created) response, the server extract the ID
Context from it, verifies that the first part is equal to the nonce
N1 it previously sent, and if so, sets its own ID Context and derives
the complete Security Context from it plus the parameters received in
the AS, following section 3.2 of I-D.ietf-core-object-security.  If
the request verifies, then this Security Context is stored in the
server, and used in the response, and in further communications with
the client, until token expiration.  The client will not include the
ID Context value in further requests.
Paragraph (version B):
An overview of the profile flow for the OSCORE profile is given in
prof-overview.
Paragraph (version B):
The following subsections describe the details of the POST /token
request and response between client and AS.  Section 3.2 of I-D.ietf-
core-object-security defines how to derive a security context based
on a shared master secret and a set of other parameters, established
between client and server, which the client receives from the AS in
this exchange.  The proof-of-possession key (pop-key) provisioned
from the AS MUST be used as master secret in OSCORE.
Paragraph (version B):
The client-to-AS request is specified in Section 5.6.1 of I-D.ietf-
ace-oauth-authz.
Paragraph (version B):
If the client wants to update its access rights using the same OSCORE
Security Context, it MUST include in its POST /token request a cnf
object carrying the Sender ID in the kid field.  This identifier can
be used by the AS to determine the shared secret to construct the
proof-of-possession token and therefore MUST specify a symmetric key
that was previously generated by the AS as a shared secret for the
communication between the client and the RS.
Paragraph (version B):
The client MUST send this POST /token request over a secure channel
that guarantees authentication, message integrity and confidentiality
(see introsp).
Paragraph (version B):
After verifying the POST /token request and that the client is
authorized to obtain an access token corresponding to its access
token request, the AS responds as defined in section 5.6.2 of I-
D.ietf-ace-oauth-authz.  It signals that the use of OSCORE is
REQUIRED for a specific access token by including the "profile"
parameter with the value "coap_oscore" in the access token response.
This means that the client MUST use OSCORE towards all resource
servers for which this access token is valid, and follow oscore-setup
to derive the security context to run OSCORE.
Paragraph (version B):
Additionally, the AS MAY provision the following data, in the same
response.
Paragraph (version A):
The same parameters MUST be included as metadata of the access token;
if the token is a CWT RFC8392, the same COSE_Key structure MUST be
placed in the 'cnf' claim of this token.  If a CWT is used it MUST be
encrypted, since the token is transferred from the client to the RS
over an unprotected channel.
Paragraph (version A):
The AS MUST also assign identifiers to both client and RS, which are
then used as Sender ID and Recipient ID in the OSCORE context as
described in section 3.1 of I-D.ietf-core-object-security.  These
identifiers MUST be unique in the set of all clients and RS
identifiers for a certain AS.  Moreover, these MUST be included in
the COSE_Key as header parameters, as defined in table 1.
Paragraph (version B):
The master secret MUST be communicated as COSE_Key in the 'cnf'
parameter of the access token response as defined in Section 5.6.4.5
of I-D.ietf-ace-oauth-authz.  The AEAD algorithm MAY be included as
the 'alg' parameter in the COSE_Key; the HKDF algorithm MAY be
included as the 'hkdf' parameter of the COSE_Key and the salt MAY be
included as the 'slt' parameter of the COSE_Key as defined in tab1.
Paragraph (version B):
The same parameters MUST be included as metadata of the access token.
This profile RECOMMENDS the use of CBOR web token (CWT) as specified
in RFC8392.  If the token is a CWT, the same COSE_Key structure
defined above MUST be placed in the 'cnf' claim of this token.
Paragraph (version B):
The AS MUST also assign identifiers to both client and RS, which are
then used as Sender ID and Recipient ID in the OSCORE context as
described in section 3.1 of I-D.ietf-core-object-security.  These
identifiers MUST be unique in the set of all clients and RS
identifiers for a certain AS.  Moreover, these MUST be included in
the COSE_Key as header parameters, as defined in tab1.
Paragraph (version A):
Figure 1 shows an example of such an AS response, in CBOR diagnostic
notation without the tag and value abbreviations.
Paragraph (version A):
Figure 2 shows an example CWT, containing the necessary OSCORE
parameters in the 'cnf' claim, in CBOR diagnostic notation without
tag and value abbreviations.
Paragraph (version A):
Note that the proof-of-possession required to bind the access token
to the client is implicitly performed by generating the shared OSCORE
context using the pop-key as master secret, both on the client and RS
side.  An attacker using a stolen token will not be able to generate
a valid OSCORE context and thus not be able to prove possession of
the pop-key.
Paragraph (version A):
As specified in the ACE framework (section 5.6 of I-D.ietf-ace-oauth-
authz), the Client and AS can also use CoAP instead of HTTP to
communicate via the token resource.  This section specifies how to
use OSCORE between Client and AS together with CoAP.  The use of
OSCORE for this communication is OPTIONAL in this profile, other
security protocols (such as DTLS) MAY be used instead.
Paragraph (version A):
The client and the AS are expected to have pre-established security
contexts in place.  How these security contexts are established is
out of scope for this profile.  Furthermore the client and the AS
communicate using OSCORE (I-D.ietf-core-object-security) through the
introspection resource as specified in section 5.7 of I-D.ietf-ace-
oauth-authz.
Paragraph (version A):
As specified in the ACE framework (section 5.7 of I-D.ietf-ace-oauth-
authz), the RS and AS can also use CoAP instead of HTTP to
communicate via the introspection resource.  This section specifies
how to use OSCORE between RS and AS.  The use of OSCORE for this
communication is OPTIONAL in this profile, other security protocols
(such as DTLS) MAY be used instead.
Paragraph (version A):
The RS and the AS are expected to have pre-established security
contexts in place.  How these security contexts are established is
out of scope for this profile.  Furthermore the RS and the AS
communicate using OSCORE (I-D.ietf-core-object-security) through the
introspection resource as specified in section 5.7 of I-D.ietf-ace-
oauth-authz.
Paragraph (version B):
ex1 shows an example of such an AS response, in CBOR diagnostic
notation without the tag and value abbreviations.
Paragraph (version B):
ex2 shows an example CWT, containing the necessary OSCORE parameters
in the 'cnf' claim, in CBOR diagnostic notation without tag and value
abbreviations.
Paragraph (version B):
If the client has requested an update to its access rights using the
same OSCORE Security Context, and the token associated with it is not
expired, the AS MAY omit the master secret and server identifier both
in the COSE_Key in the 'cnf' parameter and in the token.  The client
identifier needs to be provisioned, in order for the RS to identify
the previously generated Security Context.
Paragraph (version B):
ex5 shows an example of such an AS response, in CBOR diagnostic
notation without the tag and value abbreviations.
Paragraph (version B):
ex6 shows an example CWT, containing the necessary OSCORE parameters
in the 'cnf' claim for update of access rights, in CBOR diagnostic
notation without tag and value abbreviations.
Paragraph (version B):
The following subsections describe the details of the POST /authz-
info request and response between client and RS.  The client posts
the token that includes the materials provisioned by the AS to the
RS, which can then use Section 3.2 of I-D.ietf-core-object-security
to derive a security context based on a shared master secret and a
set of other parameters, established between client and server.
Paragraph (version B):
Note that the proof-of-possession required to bind the access token
to the client is implicitly performed by generating the shared OSCORE
Security Context using the pop-key as master secret, for both client
and RS.  An attacker using a stolen token will not be able to
generate a valid OSCORE context and thus not be able to prove
possession of the pop-key.
Paragraph (version B):
The client MUST use CoAP and the Authorization Information endpoint
as described in section 5.8.1 of I-D.ietf-ace-oauth-authz to
transport the token to the RS.
Paragraph (version B):
The authz-info endpoint is not protected, nor are the responses from
this endpoint.
Paragraph (version B):
The access token MUST be encrypted, since it is transferred from the
client to the RS over an unprotected channel.
Paragraph (version B):
ex3 shows an example of the request sent from the client to the RS.
Paragraph (version B):
The RS MUST follow the procedures defined in section 5.8.1 of I-
D.ietf-ace-oauth-authz: the RS MUST verify the validity of the token.
If the token is valid, the RS MUST respond to the POST request with
2.01 (Created).  This response MAY contain an identifier of the token
(e.g., the cti for a CWT) as a payload, in order to allow the client
to refer to the token.  If the token is valid but is associated to
claims that the RS cannot process (e.g., an unknown scope) the RS
MUST respond with a response code equivalent to the CoAP code 4.00
(Bad Request).  In the latter case the RS MAY provide additional
information in the error response, in order to clarify what went
wrong.  The RS MAY make an introspection request to validate the
token before responding to the POST request to the authz-info
endpoint.
Paragraph (version B):
Additionally, the RS MUST generate a nonce (N1) with a good amount of
randomness, and include it in the payload of the 2.01 (Created)
response as a CBOR byte string.  This profile RECOMMENDS to use a
nonce of 64 bits.  The RS MUST store this nonce as long as the access
token related to it is still valid.
Paragraph (version B):
As specified in section 5.8.3 of I-D.ietf-ace-oauth-authz, the RS
MUST notify the client with an error response with code 4.01
(Unauthorized) for any long running request before terminating the
session, when the access token expires.
Paragraph (version B):
Once receiving the 2.01 (Created) response from the RS, following the
POST /authz-info request, the client MUST extract the nonce N1 from
the CBOR byte string in the payload of the response.  The client MUST
generate itself a nonce (N2) with a good amount of randomness.  This
profile RECOMMENDS to use a nonce of 64 bits.  Then, the client MUST
set the ID Context of the Security Context created to communicate
with the RS to the concatenation of N1 and N2, in this order: ID
Context = N1 | N2, where | denotes byte string concatenation.  The
client MUST set the Master Secret, Sender ID and Recipient ID from
the parameters received from the AS in as-c.  The client MUST set the
AEAD Algorithm, Master Salt, HKDF and Replay Window from the
parameters received from the AS in as-c, if present.  In case these
parameters are omitted, the default values are used as described in
section 3.2 of I-D.ietf-core-object-security.  After that, the client
MUST derive the complete Security Context following section 3.2.1 of
I-D.ietf-core-object-security.  From this point on, the client MUST
use this Security Context to communicate with the RS when accessing
the resources as specified by the authorization information.
Paragraph (version B):
The client then uses this Security Context to send requests to RS
using OSCORE.  In the first request sent to the RS, the client MUST
include the kid context, with value ID Context, i.e. N1 concatenated
with N2.  The client needs to make sure the RS receives the kid
context, possibly adding the kid context to later requests, until it
receives a valid OSCORE response from the RS using the same Security
Context.
Paragraph (version B):
When the RS receives this first OSCORE-protected request, it MUST
extract the kid context from the message first.  Then, it needs to
verify that the first part of the kid context corresponds to the
nonce N1 it previously sent, and that it is followed by a non-zero-
length byte string.  If that is verified, the RS MUST set the ID
Context to the kid context value.  Then, the RS MUST set the Master
Secret, Sender ID and Recipient ID from the parameters received from
the client in the access token in c-rs.  The RS MUST set the AEAD
Algorithm, Master Salt, HKDF and Replay Window from the parameters
received from the client in the access token in c-rs, if present.  In
case these parameters are omitted, the default values are used as
described in section 3.2 of I-D.ietf-core-object-security.  After
that, the RS MUST derive the complete Security Context following
section 3.2.1 of I-D.ietf-core-object-security, and MUST associate
this Security Context with the authorization information from the
access token.  Then, the RS MUST delete the nonce N1 from memory.
Paragraph (version B):
The RS then uses this Security Context to verify the request and send
responses to RS using OSCORE.  If OSCORE verification fails, error
responses are used, as specified in section 8 of I-D.ietf-core-
object-security.  Additionally, if OSCORE verification succeeds, the
verification of access rights is performed as described in section
tok-ver.  The RS MUST NOT use the Security Context after the related
token has expired, and MUST respond with a unprotected 4.01
(Unauthorized) error message.
Paragraph (version B):
The RS MUST follow the procedures defined in section 5.8.2 of I-
D.ietf-ace-oauth-authz: if an RS receives a OSCORE-protected request
from a client, then it processes according to I-D.ietf-core-object-
security.  If OSCORE verification succeeds, and the target resource
requires authorization, the RS retrieves the authorization
information from the access token associated to the Security Context.
The RS then MUST verify that the authorization information covers the
resource and the action requested.
Paragraph (version B):
The response code MUST be 4.01 (Unauthorized) in case the client has
not used the Security Context associated with the access token, or if
RS has no valid access token for the client.  If RS has an access
token for the client but not for the resource that was requested, RS
MUST reject the request with a 4.03 (Forbidden).  If RS has an access
token for the client but it does not cover the action that was
requested on the resource, RS MUST reject the request with a 4.05
(Method Not Allowed).
Paragraph (version B):
As specified in the ACE framework (section 5.7 of I-D.ietf-ace-oauth-
authz), the requesting entity (RS and/or client) and the AS
communicates via the introspection or token endpoint.  The use of
CoAP and OSCORE for this communication is RECOMMENDED in this
profile, other protocols (such as HTTP and DTLS or TLS) MAY be used
instead.
Paragraph (version B):
TODO: explain the rationale for the nonces construction, and the
security implications for Man-in-the-Middle attacks.