Skip to content

Please require a secure origin (Bug 25972) #28

Closed

Description

@mwatson2

Bug 25972 from bugzilla:

As with service workers implementations want to require a secure origin in order to get access to cryptographic functionality. We should make that a requirement in the specification so that implementations do not have to reverse engineer each other.

In particular you want to refer to the origin of http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#entry-settings-object

Secure origin is defined by https://w3c.github.io/webappsec/specs/mixedcontent/

Ryan probably knows which flavor of secure origin is to be used here.

Activity

  1. hhalpin commented on Jun 20, 2016

    @hhalpin

    Add text saying "Developers should use Secure Origins, although this is not strictly required."

  2. self-assigned this
    on Jul 11, 2016
  3. mwatson2 commented on Jul 11, 2016

    @mwatson2
    CollaboratorAuthor

    Discussion on 7/11 call suggest requiring a secure origin, in the stronger sense of requiring the top-level browsing context to be secure.

  4. mwatson2 commented on Jul 12, 2016

    @mwatson2
    CollaboratorAuthor

    I assume that the secure origin test should be performed as the first step in each WebCrypto method. This would mean that errors due to WebIDL type conversion would still occur on insecure origins, but then you would get the secure origin test failure.

    IIUC, Chrome's current implementation does algorithm normalization and possibly other parameter validation before checking for the secure origin.

  5. added a commit that references this issue on Jul 12, 2016
    5222c26
  6. mwatson2 commented on Jul 12, 2016

    @mwatson2
    CollaboratorAuthor

    PR #122

  7. bdhess commented on Jul 14, 2016

    @bdhess
    Contributor

    -1 for requiring a secure origin (though I'm okay with it being recommended).

    The "Secure Messaging" use case, for example, doesn't require TLS in order to preserve the privacy of the exchange, so long as only ciphertext is transmitted. Simply put, we don't want the extra roundtrips associated with establishing a TLS session when they are superfluous to the actual security solution, since this leads to a worse end-user experience with no tangible benefit.

  8. domenic commented on Jul 14, 2016

    @domenic

    Whatever you do, please do not use the incumbent or entry settings objects here. Current settings object is more correct. See https://readable-email.org/list/public-script-coord/topic/multiple-globals-and-you

  9. ddorwin commented on Jul 14, 2016

    @ddorwin

    Looking at https://w3c.github.io/webappsec-secure-contexts/#new, would it be simpler to add [SecureContext] to GlobalCrypto, Crypto, and/or SubtleCrypto?

  10. domenic commented on Jul 14, 2016

    @domenic

    That would probably work, although it would have different normative effects than adding a guard. (Adding a guard causes errors at call time, whereas [SecureContext] prevents the interfaces from existing at all.)

  11. 75 remaining items

  12. twiss commented on Jul 4, 2022

    @twiss
    Member

    But I don't see how it would solve the MITM issue if, suddenly, the LAN address space became a secure context. Since HTTPS security is based on a verification done with an external server (the CA), and on a local address space you can't have a CA, allowing 192.168.1.0/24 to be secure without a CA, means that any device could replace the some other device's web service and scripts by just impersonating/spoofing the other device's IP address.

    In the subclause "if the user has indicated that they're on a private network" is hidden the assumption that the user trusts their local network and the devices in it. For example, if you don't trust your own device, HTTPS is also not secure, as malware on your device can MITM that as well.

    Considering local devices as secure origins (if the user trusts them) addresses the use case that was brought up as then you can use Web Crypto (and other APIs that require secure origins). At the very least, it's not less secure than allowing Web Crypto to be used on HTTP in general ;)

    If you want more security than that, indeed a separate proposal would be needed.

  13. X-Ryl669 commented on Jul 4, 2022

    @X-Ryl669

    At the very least, it's not less secure than allowing Web Crypto to be used on HTTP in general ;)

    That's true. So why deny it at first ?

  14. twiss commented on Jul 4, 2022

    @twiss
    Member

    What did I deny, exactly? I never argued against allowing Web Crypto on LAN. I was merely arguing against allowing Web Crypto on HTTP in general.

  15. robofearth commented on Jul 5, 2022

    @robofearth

    I’ve been following this topic for years and am astounded at those few supporting the requirements for https, regardless of how prevalent it is.

    A good encryption library should not rely on having certificates from centralised issuing authorities, when it isn’t needed for that library’s internal logic. That’s insane.

  16. X-Ryl669 commented on Jul 5, 2022

    @X-Ryl669

    Ok, so that's where I disagree with you. Webcrypto should be allowed on HTTP, maybe only on LAN, but it should be accessible. Because on LAN, it's not possible to have HTTPS (unless without horrible DNS tricks and an internet connection, so a WAN).
    Maybe getting LAN recognized as a secure context is enough for this (and I'm with you if it's your opinion).

    However having Webcrypto on HTTP anywhere else (WAN) doesn't decrease security (I think it's the opposite). Because when something needs to be done, it'll be done and we don't live in a world of unicorn and fairies. Without Webcrypto, the result is sending crypto code as unsecure JS, unauthenticated, uncertified. With Webcrypto, at least, the crypto toolbox is standard and secure, and not tempered. The code that's using these web crypto primitives can be modified by a MITM in HTTP unless some addition is added to the proposal/specification.

    With few modifications (like I've described above), it can even be made secure against MITM after first contact.

    It's not really complex to add, since we already have script's signature checking in browser (with subresource integrity specification), adding a secret per-browser salt token and a dictionary of token=>HMAC(script, secret||token) in local storage and using it before allowing the script to run is few lines of code, the most difficult part is to add a dialog to ask the user if she wants to trust the server initially (but again, we already have those for setting up bad HTTPS certificate exceptions).

    As you said, it can be a new proposal, I think it's too small to make a proposal, and I don't think it'll be baked up by Google, that's why I think it should be in this proposal.

  17. X-Ryl669 commented on Jul 5, 2022

    @X-Ryl669

    A good encryption library should not rely on having certificates from centralised issuing authorities

    A crypto toolbox that's only doing what's already done/required in HTTPS is useless anyway, since you can already use HTTPS to send one to the browser. A crypto toolbox should allow making crypto algorithms and applications ever with a centralized architecture or a decentralized architecture. Right now, the specification is centralized only, since if Let's Encrypt server is DDOS, the whole web will collapse (and no, the fact that there are other CA is not a justification for decentralization, when one actor is free vs paying competitors, it's the main actor).

    To allow decentralization of the web, one should not rely on a technology that mandate a unique (or few) hosts to be alive, but instead provide way to trust other & any hosts and a crypto toolbox is mandatory to achieve this. It's a shame that webcrypto doesn't run on HTTP, because this large area of possibilities is denied to us.

  18. twiss commented on Jul 5, 2022

    @twiss
    Member

    Ok, so that's where I disagree with you. Webcrypto should be allowed on HTTP, maybe only on LAN, but it should be accessible. Because on LAN, it's not possible to have HTTPS (unless without horrible DNS tricks and an internet connection, so a WAN).
    Maybe getting LAN recognized as a secure context is enough for this (and I'm with you if it's your opinion).

    Yes, that's what I meant. And that's what w3c/webappsec-secure-contexts#60 is :)

    As you said, it can be a new proposal, I think it's too small to make a proposal, and I don't think it'll be baked up by Google, that's why I think it should be in this proposal.

    Well - at the very least it should be outside of this issue :) As you'll notice this issue isn't even about allowing Web Crypto on insecure origins, it's about allowing Web Crypto on secure origins only. As that has been done, this issue is closed and will never be reopened. So if you want to have an open issue to discuss this stuff in, you should create a new one. But, apart from that, whether Google implements something doesn't depend on whether it's included in a big specification or a small one. And in fact, additions to this standard have to go through incubation, anyway, so you'd have to write a (small) specification anyway. But that's a good thing, not a bad thing - if you just sneak something into an existing specification, without gaining consensus on it, nobody will notice or implement it.

    A crypto toolbox that's only doing what's already done/required in HTTPS is useless anyway, since you can already use HTTPS to send one to the browser.

    That's not entirely true. Web Crypto can be used to implement end-to-end encryption, which HTTPS can't offer. There are some challenges around trusting the code if you don't trust the origin, but that's again orthogonal to this issue. Additionally, in a web extension (which is also a secure origin), you can use Web Crypto to send encrypted data to a server if you trust the web extension but not the server, for example.

    A crypto toolbox should allow making crypto algorithms and applications ever with a centralized architecture or a decentralized architecture. Right now, the specification is centralized only, since if Let's Encrypt server is DDOS, the whole web will collapse (and no, the fact that there are other CA is not a justification for decentralization, when one actor is free vs paying competitors, it's the main actor).

    If it's your position that it should be possible to make secure decentralized web apps, then that's reasonable, however, for that you need secure code distribution, which comes before Web Crypto, not after. If you want to have a mechanism where the code is signed and trusted by the user with a trust-on-first-use model, that's potentially possible, but again the "index.html" should then be signed also (and the signature be verified by the browser). If that's implemented, then the origin could be considered as secure, and then Web Crypto could be used there. However, using Web Crypto (which is run by the code of the web app) to verify the code of the web app is not possible.

  19. X-Ryl669 commented on Jul 5, 2022

    @X-Ryl669

    That's probably the main point here.

    You don't need secure code distribution, unless you consider that the browser's internal code is a distribution. Secure code distribution is what HTTPS is doing and we can safely say it's working well, but it doesn't mean other way to distribute code over unsafe channel won't work. The trust-on-first-use is an example of a secure code assertion over an insecure channel. It requires a secure / non falsifiable tool and web crypto can provide it since it resides in the web browser, not on the code that's sent over the wire. There are other methods to send secure code over an un-secure channel, (typically TLS is one of them too). They all rely on a trusted implementation of some primitive and web crypto should be this implementation.

    It's not possible to verify the web app right now on HTTP but it can be made possible with 2 changes to the specifications:

    1. Allowing web crypto everywhere
    2. Allowing a taint mode for security. Once a web page tries to instantiate web crypto, a secret (to the javascript implementation and the server) is generated that's used to verify/sign/assert the content of the web page against a web page's own token. I think you've got that part, so I won't repeat how (that should be part of a new proposal).

    So if you think it's worth it, I'll bootstrap another issue, but I don't know if it should be on this repo or on another one.

  20. 7heMech commented on May 5, 2024

    @7heMech

    Why was this even accepted :/

  21. sedghi commented on Jul 14, 2025

    @sedghi

    So you are the root of all issues, thanks

  22. Wren6991 commented on Apr 27, 2026

    @Wren6991

    Oh, so this is why people are still rolling their own SHA-256 for local web apps.

    Apparently the smoke-filled rooms at W3C were being hotboxed in 2016

  23. 7heMech commented on Apr 27, 2026

    @7heMech

    Oh, so this is why people are still rolling their own SHA-256 for local web apps.

    Apparently the smoke-filled rooms at W3C were being hotboxed in 2016

    It's crazy, not supporting a library which could make your environment more secure, because... Your environment is not secure‽

  24. 7heMech commented on Apr 27, 2026

    @7heMech

    Also I don't believe any API should be restricted by SSL context, it doesn't make sense for implementors as well, that's just more unnecessary logic.

  25. twiss commented on Apr 28, 2026

    @twiss
    Member

    Hi all,

    If you have a reasoned, argued proposal for allowing the use of Web Crypto in insecure contexts, please open a new issue.

    Please also note that "what were they smoking?" is not a reasoned, argued proposal that can be debated :)

    Finally, if your issue is with (the definition or implementation of) secure contexts in general, please consider discussing that in https://github.com/w3c/webappsec-secure-contexts, such as in w3c/webappsec-secure-contexts#60 (or another or new issue if it doesn't cover your use case).

  26. Wren6991 commented on Apr 28, 2026

    @Wren6991

    Sorry, I take back that comment. I'll open a fresh issue to try and make the case for at least digest being allowed outside of secure contexts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions