Skip to content

webassembly platform #139

Open
Open

Description

@unicomp21

Wow, amazing stuff. Why can't we create a webassembly based virtual nic which runs in the browser? Route the packets over websocket. Doesn't Rust compile to webassembly?

My intention in submitting this issue is to figure out if I'm crazy or not.

Activity

  1. unicomp21 commented on Aug 9, 2020

    @unicomp21
    Author

    Eventually, it should also be possible to route packets over the QUIC RTCDataChannel getting added to Chrome.

  2. unicomp21 commented on Aug 9, 2020

    @unicomp21
    Author

    This would also create the need for a webassembly implementation of the HTTP2, HTTP3(QUIC), and websocket protocols. Initially, I think websocket protocol (over wireguard) should be pretty quick/simple. The others could follow later.

  3. vkrasnov commented on Aug 11, 2020

    @vkrasnov
    Contributor

    That doesn't sound crazy at all. There is also a Rust implementation of QUIC https://github.com/cloudflare/quiche
    So yeah, that is definitely doable, with a simple NAT.

  4. unicomp21 commented on Aug 12, 2020

    @unicomp21
    Author

    Yes! Let's do it! Does this need to be approved as a feature or something? Once we have a webassembly build, I'm thinking another repo could be dedicated to the layers on top of wasm-boringtun-client, such as http-vpn, ws-vpn, etc. In addition there would be the ws-wireguard-vpn proxy (which forwards wireguard packets) for the wasm-boringtun-client to connect with.

  5. unicomp21 commented on Aug 12, 2020

    @unicomp21
    Author

    If we get this thing working, and it catches on, it will beg a very large question. Browsers might be forced to introduce a vpn_wireguard_url w/ a vpn client embedded in the browser. Exciting times.

  6. unicomp21 commented on Aug 12, 2020

    @unicomp21
    Author

    Wow, the future is starting to look a LOT simpler from a security perspective.

  7. unicomp21 commented on Aug 12, 2020

    @unicomp21
    Author

    I wonder if we could get Mozilla to jump on board early.

  8. vkrasnov commented on Aug 13, 2020

    @vkrasnov
    Contributor

    Ha, your excitement is contagious! Yeah it doesn’t seem super complicated, definitely doable. Obviously if you want to send the packets over ws you need a server that can accept them, but this is almost trivial.

  9. unicomp21 commented on Aug 13, 2020

    @unicomp21
    Author

    Lol, to quote someone, "You wanna make a dent in the planet?"

  10. Mohsen7s commented on Jan 22, 2022

    @Mohsen7s

    I guess this will be the first VPN client over wasm since no other VPN protocol implemented to wasm. Is there any hope or its forgotten ?

  11. Noah-Kennedy commented on Jan 24, 2022

    @Noah-Kennedy
    Collaborator

    This issue was largely forgotten, but if there is interest, this can be pursued. I do not have the bandwidth to pursue this sadly, but contributions are welcome. If someone wants to look into what would be required to make this work, that would be a good first step here.

  12. unicomp21 commented on Jan 24, 2022

    @unicomp21
    Author

    I think the CheerpX guys have something working internally over RTCDatachannel. Wouldn't this effort be best served by webtransport? Does cloudflare support webtransport yet? I think webtransport just went GA in chrome recently?

  13. Noah-Kennedy commented on Feb 14, 2022

    @Noah-Kennedy
    Collaborator

    This would be interesting with webtransport. I don't have the bandwidth to do this right now, but I would welcome any PRs.

  14. XChikuX commented on Feb 1, 2023

    @XChikuX

    I hear that WebAssembly is going to support 'components' i.e. a secure way for different webassembly applications to securely talk to each other in the browser.
    Not sure if that would kill the need for a virtual nic.

  15. jeffparsons commented on Feb 2, 2023

    @jeffparsons

    @XChikuX That's not quite what Wasm Components are for, and they don't obviate the need for a virtual NIC. If anything, a virtual VPN-integrated NIC would be implemented as a Wasm Component, and could be inserted at link time between an "application component" and the underlying runtime without the application component needing to have any knowledge of this.

    (EDIT: you could think of this use case as LD_PRELOAD on steroids.)

  16. justin13888 commented on Mar 7, 2024

    @justin13888

    Wondering if there are any updates on this?? Would porting boringtun to webassembly be too much of a technical effort given scope of the project?

  17. Downchuck commented on Sep 27, 2025

    @Downchuck

    Going down this technical path here's what I see:

    • WebAssembly wide arithmetic is in Phase 3 and only implemented in one spot, behind a flag.
    • This key gen step, the x25519 is then fastest implemented by watsign using 29 or 30 bit arithmetic - though tweetnacl-js is far more accessible. Using BigInt is much simpler in modern Javascript, while bigint is fast for the math, creating bigint objects is slow.
    • wireguard-go has been compiled out by tailscale for their SSH terminal some time ago.
    • there are quite a few blake2s implementations, works fine enough.

    So -- yes, there are components one could glue together to do this in WASM and/or Javascript; for blake2s, x25519, chacha20 and poly1305 -- they're fast enough for client side use, but it's messy.

    With BigInt being both "insecure" to timing attacks, and the Uint64BigInt being too tiny anyway, and without a u64 * u64 option in webassembly that's going to work, it's a bit complicated and inefficient.

    I don't see a cross-compile from boringtun working out anyway - but if it were going to happen, I wouldn't really suggest championing the idea until and unless wide arithmetic is brought into standard use with webassembly.

    All that set aside, it's just more likely to just use these things in JavaScript like x25519 in the web crypto API - and eventually chacha20-poly1305 in the api.

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

Metadata

Metadata

Assignees

No one assigned

    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