w3c / wot-profile

Web of Things (WoT) Profile
http://w3c.github.io/wot-profile/
Other
16 stars 8 forks source link

Security Requirements for WebHook Consumer #222

Open egekorkan opened 2 years ago

egekorkan commented 2 years ago

Given that a WebHook consumer also acts as a server, what are its security scheme requirements? If there is any flexibility on this, the Consumer needs to communicate these with a certain format, maybe a TD with no affordance but only security information?

egekorkan commented 1 year ago

In the call of 01.02.2022, there was a mention that the Consumer would have the security of the Thing. I don't think this is realistic given that a Consumer can be a cloud service and the Thing is something in the local network. They can use the same one but making it mandatory that they are the same seems a bit off to me. Do we have any examples?

mmccool commented 1 year ago

Will discuss in next Security TF call.

mmccool commented 1 year ago

We put a lot of comments related to webhooks under #224 but want to move that discussion here.

To summarize:

benfrancis commented 1 year ago

I (the Security TF is still reviewing and will comment here) suggests that we could adopt the approach outlined for Cloud Events in https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/http-webhook.md, with some modifications

I agree that using Bearer tokens in an Authorization header in event requests sent from a Thing to a Consumer is a reasonable solution.

Some observations:

benfrancis commented 1 year ago

One solution to this problem might be for a Consumer to provide security credentials in the payload of a subscribeevent operation request (as @mmccool suggested above), but following a similar format to that used in a TD.

Example payload:

POST /things/lamp/events/overheated
Host: mythingserver.com
Content-Type: application/json
{
  callbackURI: "http://myConsumer.com/myEventListener",
  security: {
    "scheme": "bearer",
    "in": "header",
    "name": "Authorization"
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}

As I mentioned above, there's also the issue of what to do if and when a token expires.

benfrancis commented 1 year ago

Another source of inspiration could be the W3C WebSub specification. That specification is a little different because in WebSub all Webhooks are managed by a "hub" which acts as an intermediary between publishers and subscribers. Such hubs may have more resources than some Things and therefore may be able to process more complex cryptography.

Anyway, the approach they use for "authenticated content distribution" is for a subscriber to supply a "secret" in their subscription request which is used by the hub to create an HMAC signature of each event payload, which is then included in a request header of each event notification. Subscribers can verify event notifications by using the shared secret to recompute the signature for a given payload and check that it matches.

As @mmccool notes above, the signing of individual payloads would provide an additional layer of protection when compared with the simple Bearer authentication token approach (by guarding against man-in-the-middle and replay attacks), but would also be more computationally expensive.

Perhaps signing of payloads could be explored as an optional layer of security at the same time as signing Thing Descriptions.