w3c / webtransport

WebTransport is a web API for flexible data transport
https://w3c.github.io/webtransport/
Other
848 stars 50 forks source link

expose a TLS Keying Material Exporter / unique value for the TLS session #411

Open marten-seemann opened 2 years ago

marten-seemann commented 2 years ago

It would be useful to expose a TLS Key Exporter (RFC 5707), or at least a value that's derived from the TLS master secret, and therefore unique to the TLS session.

This is a useful building block for protocols running on top of TLS:

  1. The (somewhat misleadingly named) HTTP Transport Authentication draft uses a TLS Keying Material Exporter. Note that I'm not suggesting to implement exactly this draft, just something along these lines.
  2. In the p2p setting, peers might run a secondary handshake on top of a WebTransport session. Having access to a value unique to the TLS session would allow one to bind the that handshake to the TLS session.
jan-ivar commented 2 years ago

Meeting:

marten-seemann commented 2 years ago

It might be helpful to have an example of what this would be useful for.

I already listed the HTTP Transport Authentication draft before. I'm happy to expand on my use case: In libp2p, a general-purpose p2p networking library, we're planning to use WebTransport to allow browsers to connect to the rest of the network. Specifically, we'll use the serverCertificateHashes API to be able to use self-signed certificates. We run a secondary handshake on one stream after to make sure the connection wasn't MITMed (as the address exchange, which includes the server's certificate hash, is not necessarily authenticated).

Is there any API precedent for this in the web platform we could follow?

Not that I'm aware of. However, in WebRTC the same can be achieved using the tuple of the certificate hashes from both SDPs.

What JS API surface do you have in mind?

I don't have a lot of experience designing browser APIs, but these two options would work:

jan-ivar commented 2 years ago

@martinthomson any concerns with exposing keying material like this?

martinthomson commented 2 years ago

That's what exporters are for, so, not in that respect.

pthatcher commented 2 years ago

This seems like a reasonable API request to me, and would be fairly simple:

.exportKeyMaterial(label, context, len)

However, I worry about a label being reused. So, you go get key material and use it, but another tab (when using WebTransport pooling) uses the same label and learns your key material. Or some built-in browser thing in the future uses a label and then you learn key material by using the same label.

Perhaps we could fix this with a rule like "you can't reuse the same label more than once for the same WebTransport".

martinthomson commented 2 years ago

With pooling, we might need to add something extra (based on the session ID probably) to the exporter label or context so that different sessions get different keys.

I would also look to webcrypto for the API. It might be that we only need to export a single, fixed value, which can then be used as input to webcrypto functions.

jan-ivar commented 1 year ago

Meeting:

vasilvv commented 1 year ago

Note: I've filed ietf-wg-webtrans/draft-ietf-webtrans-http3#116 to possibly describe the actual operation in the IETF spec.

Neustradamus commented 1 year ago

To follow.

Neustradamus commented 1 year ago

Any progress on it?

I think that you have seen the jabber.ru MITM and Channel Binding is the solution:

Little details, to know easily:

Thanks in advance.

jan-ivar commented 11 months ago

@vasilvv it appears https://github.com/ietf-wg-webtrans/draft-ietf-webtrans-http3/issues/116#issuecomment-1767275566 was closed "due to lack of interest". What are next steps here?

vasilvv commented 11 months ago

It's either (1) we find developers who can provide an explanation of how they're going to use this feature, or (2) we close this issue for the same reason.

wilaw commented 10 months ago

Closing per https://github.com/ietf-wg-webtrans/draft-ietf-webtrans-http3/issues/116#issuecomment-1767275566

sukunrt commented 10 months ago

Hi, apologies for the delay. I'm taking over the work @marten-seemann mentioned for libp2p. We'd like to have this feature. The requirement is the same as Marten has shared before.

In libp2p, we identify nodes by their peer ID which is hash(public key). Currently, we use WebTransport with the serverCertificateHashes API. The client obtains the peer's peer ID and its WebTransport address (including the certificate hash). After establishing the WebTransport session, we run a Noise handshake on a WebTransport stream, which verifies that the peer does actually have the private key corresponding to its peer ID. In order to make sure the connection wasn't MITM-ed, the WebTransport certificate hash is hashed into the Noise handshake, which cryptographically ties the Noise handshake to the underlying WebTransport session.

We would like to extend our use of WebTransport to use the web PKI. Here, being able to derive a unique value would allow us to bind the TLS session to the Noise handshake, similar to how we use cert hashes above.

hlandau commented 10 months ago

I would also definitely like to see this. There's some use cases I've wanted to be able to do on the web platform for some time, but the lack of this functionality still holds things back.

jan-ivar commented 9 months ago

Meeting:

wilaw commented 8 months ago

See this PR https://github.com/ietf-wg-webtrans/draft-ietf-webtrans-http3/pull/148 from Victor

wilaw commented 6 months ago

https://github.com/ietf-wg-webtrans/draft-ietf-webtrans-http3/pull/148 was merged. How should W3C API surface change?

jan-ivar commented 6 months ago

Meeting:

jan-ivar commented 4 months ago

Meeting:

vasilvv commented 4 months ago

I don't think we can make this an attribute given that generating an exporter needs three arguments.

I'd also prefer making this async, since it makes it much easier to implement (it's possible to implement this synchronously, but it requires some cooperation from the TLS library, and has some unfortunate security implications).

jan-ivar commented 4 months ago

Meeting:

wilaw commented 2 months ago

Note comments in https://github.com/ietf-wg-webtrans/draft-ietf-webtrans-http3/issues/170#issue-2465995393

I would strongly suggest not to expose TLS exporters in client API as it will lead to inconsistent user experience depending on presence of a TLS proxy. These issues will be quite hard to troubleshoot for application developers as TLS proxies are typically deployed on client side.

vasilvv commented 2 months ago

Three things to note here before I forget:

  1. That's part of the intended effect.
  2. We already ship features that require direct connection (serverCertificateHashes)
  3. At least in Chrome, we don't allow WebTransport when a proxy is configured for the URL in question, and I'm not sure at what point we'd support it. There are a lot of unclear implications when it comes to forward proxies, since WebTransport is an intentionally low-level networking API.
jan-ivar commented 1 month ago

Discussed at TPAC:

jan-ivar commented 1 month ago

Meeting:

jan-ivar commented 1 month ago

Covered by SESSION ID in https://github.com/ietf-wg-webtrans/draft-ietf-webtrans-http3/issues/116