Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we want to enforce HTTPS request? #27

Closed
mingyc opened this issue Aug 31, 2022 · 7 comments
Closed

Do we want to enforce HTTPS request? #27

mingyc opened this issue Aug 31, 2022 · 7 comments

Comments

@mingyc
Copy link
Collaborator

mingyc commented Aug 31, 2022

One of the requirement listed in the "Privacy" section is "Beacons must be sent over HTTPS."

But would it conflict with the goal to make it easy for developers to migrate to use this API? (this wasn't a requirement for navigator.sendBeacon()).

mingyc added a commit that referenced this issue Sep 14, 2022
Update Privacy section to clarify why beacon needs to be stopped when network changes (#27 #28)

Also added links to related privacy discussions: #3, #27, #30, #34
Updated beacon TTL to 30min per suggestion in #16 (comment)
@letitz
Copy link

letitz commented Oct 4, 2022

Hi there! Chrome web platform security reviewer here, we believe that it would be best not to build new APIs that allow HTTP communications. HTTPS is well established and its deployment has never been easier.

@mingyc
Copy link
Collaborator Author

mingyc commented Oct 7, 2022

@letitz We could update the API to only accept HTTPS endpoints, i.e. setURL('https://...');

However the API itself can still be run on a page with HTTP orign. In such case, the API cannot enforce HTTPS for relative URLs:

// In http://not-safe.com
let p = PendingGetBeacon('/target');
// p is expected to sent to http://not-safe.com/target

I am not familar with other APIs yet. Are there any examples about how to deal with this kind of issues?

@letitz
Copy link

letitz commented Oct 7, 2022

I imagine the constructor could construct the full URL of the target and check that the scheme is https?

In JS (though this would likely be handled by the browser itself):

function checkUrl(url) {
  const absoluteUrl = new URL(url, window.location);
  if (absoluteUrl.protocol !== "https:") {
    throw new TypeError("scheme is not https");
  }
}

class PendingGetBeacon {
  constructor(url, ...) {
    checkUrl(url);
    ...
  }

  setUrl(url) {
    checkUrl(url);
    ...
  }
}

This behavior would have to be specified as well.

@Sora2455
Copy link

@letitz We could update the API to only accept HTTPS endpoints, i.e. setURL('https://...');

However the API itself can still be run on a page with HTTP orign. In such case, the API cannot enforce HTTPS for relative URLs:

// In http://not-safe.com
let p = PendingGetBeacon('/target');
// p is expected to sent to http://not-safe.com/target

I am not familar with other APIs yet. Are there any examples about how to deal with this kind of issues?

If you try to call navigator.geolocation.getCurrentPosition(() => {}) in a http page, it logs an error and never fires the callback. crypto.subtle, on the other hand, returns undefined on http pages. My suggestion would be that PendingGetBeacon and PendingPostBeacon are undefined on http pages, which would mean that feature detection would fall back with no further effort.

@clelland
Copy link
Collaborator

crypto.subtle, on the other hand, returns undefined on http pages.

There are a large number of APIs that are only available on https pages -- we usually do this with a SecureContext attribute in the IDL.

@letitz
Copy link

letitz commented Oct 11, 2022

That's true, and we could consider restricting this API to secure contexts. However, the point of this issue is slightly different: whether requests to http URLs should be allowed or not.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 17, 2022
According to the [discussion][1], this CL makes the API only available in [secure context][2], and blocks all non-HTTPS request URLs in the PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs are not HTTPs. Note that relative URLs or URLs without schema still work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
@mingyc
Copy link
Collaborator Author

mingyc commented Oct 17, 2022

Thanks for all your help. I am going to also update the explainer to only support this API in secure contexts.

mingyc added a commit to mingyc/pending-beacon that referenced this issue Oct 17, 2022
@mingyc mingyc closed this as completed in 8dd5bd3 Oct 17, 2022
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 18, 2022
According to the [discussion][1], this CL makes the API only available in [secure context][2], and blocks all non-HTTPS request URLs in the PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs are not HTTPs. Note that relative URLs or URLs without schema still work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 19, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 19, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 26, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 26, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
aarongable pushed a commit to chromium/chromium that referenced this issue Oct 26, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3955986
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ming-Ying Chung <mych@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1063911}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 26, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3955986
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ming-Ying Chung <mych@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1063911}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 26, 2022
According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3955986
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ming-Ying Chung <mych@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1063911}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 12, 2022
…d make API secure-context only, a=testonly

Automatic update from web-platform-tests
[beacon-api] Allow only HTTPS targets and make API secure-context only

According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3955986
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ming-Ying Chung <mych@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1063911}

--

wpt-commits: 97cd7633f583bff5b856f816eba1de189c7c3903
wpt-pr: 36491
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 14, 2022
…d make API secure-context only, a=testonly

Automatic update from web-platform-tests
[beacon-api] Allow only HTTPS targets and make API secure-context only

According to the [discussion][1], this CL makes the API only available
in [secure context][2], and blocks all non-HTTPS request URLs in the
PendingBeacon API:

1. The API throws `TypeError` when url provided to the following APIs
   are not HTTPs. Note that relative URLs or URLs without schema still
   work:
   A. ctor: `PendingGetBeacon(url)` & `PendingPostBeacon(url)`
   B. `PendingGetBeacon.setURL(url)`
2. The entire `PendingBeacon` API becomes only available in
   SecureContext, i.e. on an HTTPS page.

[1]: WICG/pending-beacon#27
[2]: https://w3c.github.io/webappsec-secure-contexts/

Bug: 1293679
Change-Id: I20b2ece0fe490decea80ead6f4740b65c9a36845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3955986
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ming-Ying Chung <mych@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1063911}

--

wpt-commits: 97cd7633f583bff5b856f816eba1de189c7c3903
wpt-pr: 36491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants