Chapters

CoAP DTLS/OSCORE Security: Reference

Return to the parent chapter.

Related reference: CoAP message types.

Start With the Proxy Boundary

Follow One Protected Reading Across Every Stop

A clinic sensor sends a reading to a care service through a relay. The relay forwards requests as a proxy: an intermediary acting for another endpoint. The clinic permits the service to read the value but permits the relay only to forward it. Can an encrypted connection to the relay meet that rule?

The Constrained Application Protocol (CoAP) carries the request. Datagram Transport Layer Security (DTLS) encrypts the CoAP message between the endpoints of a protected connection. Suppose the sensor establishes DTLS with the relay, which decrypts the request and opens a second protected connection to the service. An observer on either protected connection cannot read the request, but the relay can. Two encrypted connections therefore fail this clinic rule.

Object Security for Constrained RESTful Environments (OSCORE) can instead protect the request between the sensor and service. Give those endpoints the keys needed to protect and recover the content; do not give those keys to the relay. The relay then forwards an outer message while the reading and protected resource path remain encrypted inside it.

Your task is to mark who can read the reading, choose the protection endpoints, and specify a restart test. A replay is a copied protected message sent again. Encryption alone does not show that a received message is new, so the test must also establish how the recipient rejects a replay.

Learning Objectives

After this page, you should be able to:

  • Decide whether a terminating DTLS proxy satisfies a stated reading-access rule.
  • Mark the CoAP fields concealed on a DTLS connection and those exposed at its endpoint.
  • Explain how endpoint OSCORE protection changes the proxy’s access.
  • Specify credential and replay-state evidence needed after a restart.

Why This Contract Comes After Security and Applications

CoAP Security and Applications introduces deployment choices. Here, use the clinic route to separate three questions: who holds the keys, where plaintext becomes available, and how a recipient distinguishes a new request from a replay. A successful connection answers only part of that review.

Overview: Four Security Modes, and What DTLS Actually Protects

On the clinic's sensor-to-relay connection, DTLS conceals the CoAP method, resource path, options and payload. Options are named CoAP fields, such as Uri-Path, that describe the request. The relay is the DTLS endpoint, so it recovers those fields. A passive observer still sees network addresses and ports; hiding the request does not hide the communication route.

Now choose how the DTLS endpoints authenticate each other: how they establish the peer's identity. RFC 7252 names four CoAP security modes. NoSec has no DTLS protection and uses coap://, with default UDP port 5683. The DTLS modes use coaps://, with default UDP port 5684. PreSharedKey uses a secret shared in advance. RawPublicKey uses a public/private key pair without a certificate. Certificate uses certificates validated against a trust anchor, a key or authority the deployment already trusts.

Changing the credential mode does not move the protection endpoint. A certificate-authenticated relay still reads the request when it terminates DTLS. First decide whether the relay may read it; then choose credentials that the deployment can provision, replace and retire.

Inspect the figure in the parent chapter at the proxy: the change from DTLS to TLS marks where the first protected connection ends.

Read the figure in the parent chapter as two connections. The sensor sends CoAP over DTLS to a terminating proxy, and the proxy opens TLS to the cloud service. The proxy is an endpoint of both protected connections, so it can access plaintext without separate object protection. An observer on either protected connection cannot read the request, but the relay can. Two encrypted connections therefore fail the clinic rule. If the relay may only forward, the clinic needs content protection whose keys belong to the sensor and service. TLS is Transport Layer Security, used for the onward connection.

NoSec

No DTLS. Plain coap:// on 5683. Any required protection must be supplied separately.

PreSharedKey

DTLS with symmetric keys shared in advance. Record how each peer receives and replaces its shared key.

RawPublicKey

DTLS with an asymmetric key pair and no certificate authority — record how each peer verifies the other public key.

Certificate

DTLS with an X.509 chain validated to a trust anchor — record the trust anchor and certificate validation policy.

Practitioner: DTLS Is Point-to-Point and Terminates at Proxies

Apply the same reasoning to a building meter whose operator explicitly permits the gateway to read and aggregate readings. DTLS ending at that gateway can meet the stated access rule, provided the onward connection and service are also protected as required. If the operator later changes the rule to exclude gateway access, changing from a shared key to certificates will not satisfy it: the endpoint boundary must change or the content needs endpoint protection such as OSCORE.

A DTLS handshake establishes security state before protected requests can flow. Reusing that state avoids repeating a full handshake for every reading, but the deployment must decide how long it remains valid. If a sleeping sensor loses memory, verify what credentials and session state survive before choosing reuse or resumption. OSCORE also needs safe security-state recovery; switching layers does not remove that obligation.

In the clinic's DTLS-only route, the terminating proxy holds the keys for its connections and sees plaintext. Ask who owns the content-protection keys before trusting the route. Merely forwarding encrypted traffic does not make an intermediary a DTLS endpoint.

Mode
Credential
Trust basis required?
Best fit
PreSharedKey
Shared symmetric key
Pre-provisioned shared secret
Closed fleet with pre-provisioned keys.
RawPublicKey
Bare key pair
Trusted peer public key, for example a pinned key; no certificate required
Asymmetric security without certificate operations.
Certificate
X.509 chain
Trust anchor and certificate validation policy; no separate CA service required
Open, multi-vendor ecosystems needing trust anchors.
OSCORE
Derived content-protection keys
Established security context; OSCORE itself does not require certificates
Sensor-to-service content protection when the proxy lacks those keys.

Under the Hood: OSCORE Protects the Message Object End-to-End

Return to the clinic rule. The sensor and service share an OSCORE security context: keys and associated state used to protect and verify messages. The sensor protects the reading, request method and inner Uri-Path. The relay forwards the outer CoAP message without those content keys. The service verifies and decrypts the protected content. The relay can still observe traffic and visible outer fields, so this design does not make the route anonymous.

Choose endpoints from the access rule. DTLS conceals CoAP on its protected connection. OSCORE can preserve protected content through an intermediary that is not a content-security endpoint. The two can be used together.

OSCORE uses COSE, the CBOR Object Signing and Encryption framework. CBOR is a compact binary data representation. Authenticated encryption with associated data (AEAD) encrypts content and checks integrity, including associated data covered by the protection. OSCORE carries protected content within an outer CoAP message marked by its OSCORE option. Required outer forwarding fields remain visible; do not assume every option is encrypted or every visible field is unprotected. Proxy routing and caching behavior must be checked for the actual option handling in use.

For protected requests, sender sequence state contributes to the nonce, a value used by authenticated encryption that must not be reused with the same key. The recipient tracks accepted requests with replay state, including a replay window that identifies duplicates while allowing the configured range of reordered requests. After a restart, test both sides: the sender must avoid unsafe sequence reuse, and the recipient must not accept an old request merely because its remembered state was lost. A message can also be old without being a duplicate; application age checks remain separate.

COSE object

The message carries the protected method, payload and inner options using COSE-based authenticated encryption.

OSCORE option (9)

Marks OSCORE processing; its fields depend on the message and security context.

Inner vs outer options

Protected inner fields conceal content; visible outer fields support forwarding. Verify the actual option handling.

Sequence-number replay guard

Sender sequence state contributes to nonce uniqueness; recipient replay state detects repeated protected requests.

Release Checklist

For the clinic route, keep a record that another reviewer can use to test the access rule:

  • Name the DTLS credential mode and, separately, whether OSCORE protects the content. OSCORE is not a fifth RFC 7252 DTLS credential mode.

  • Name each authenticated identity, key owner, trusted authority where applicable, and credential replacement or retirement procedure.

  • Mark DTLS endpoints, any onward protected connection, and OSCORE endpoints. State whether the proxy can recover the reading and protected path.

  • Record which session and sequence state survives sleep or restart, and how lost state is recovered safely.

  • Run this numbered replay experiment in an isolated test deployment:

    1. Send a fresh OSCORE-protected Confirmable request for a harmless test operation. Capture the outer CoAP request after OSCORE protection and before any DTLS encryption; replay it through a valid transport connection, not as a captured DTLS record. Record its security-context identifier, sender sequence value and one application operation in the service audit trace. Keep secret keys and sensitive plaintext out of the record.
    2. Resend the captured CoAP request unchanged. A CoAP duplicate cache may return a cached acknowledgement or response without another application operation. Record that outcome separately; receiving a response does not prove replay acceptance.
    3. Exercise OSCORE replay validation with a test harness that gives the captured request an unused outer CoAP Message ID while preserving the OSCORE option and protected content. This changes the CoAP duplicate identifier without creating a newly protected request. Verify in the recipient trace that the request reaches OSCORE replay validation and is rejected as already seen, and verify that no second application operation occurs. If only duplicate-cache handling or a transport error is observed, replay validation remains untested.
    4. Restart the sensor and service under the documented recovery policy. Record whether the same security context is retained or replaced. For a retained context, repeat step 3 with another unused outer Message ID and require replay-check rejection plus no second application operation. For a replaced context, verify that the obsolete context cannot authorize the captured request and that no second operation occurs; record obsolete-context rejection separately, because it does not demonstrate persistence of the old replay window. If the old context remains usable, test its replay handling as well.
    5. Send a newly OSCORE-protected valid request using the recovered sender state and active context. Record successful verification and a new application operation separately from replay results. A second application operation from the captured request indicates a replay failure; failure of the new valid request means usable recovery has not been demonstrated. A cached response alone establishes neither outcome.
  • Repeat with an unauthorized credential and record rejection. Keep endpoint acceptance/rejection evidence without logging secret keys or sensitive plaintext.

See Also

Return to the applications chapter for deployment choices, then review the message fields those protections cover.

Next

Return to CoAP Security and Applications, then continue to CoAP Implementation Labs for operational practice.

Hi, I’m Broker Bex. What do you need?

Find help

Let’s find what you need

Find a lesson or return to your module guide.

Give feedback

Help improve this chapter

Tell us what helped or what needs fixing.

Tips

Try a small next step

A few ways to get more from this chapter.

Ask AI

Continue the conversation

Take the conversation further with your preferred assistant.

AI help is available in supported modules when enabled in Settings.

No live person answers on independent study. Feedback does not promise a personal reply.

For welfare or safety concerns, follow your school’s procedures outside IoTClass.