quickjs-emscripten VS SES-shim

Compare quickjs-emscripten vs SES-shim and see what are their differences.

quickjs-emscripten

Safely execute untrusted Javascript in your Javascript, and execute synchronous code that uses async functions (by justjake)
SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
quickjs-emscripten SES-shim
21 13
1,130 736
- 0.7%
9.4 9.9
20 days ago about 17 hours ago
TypeScript JavaScript
GNU General Public License v3.0 or later Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

quickjs-emscripten

Posts with mentions or reviews of quickjs-emscripten. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-12-09.
  • New QuickJS Release
    6 projects | news.ycombinator.com | 9 Dec 2023
    Based on your comment below I think you figured out the difference - but if you're looking to execute JS, you can pick between ShadowRealm (where available, or using a polyfill) or my library quickjs-emscripten.

    Pros of quickjs-emscripten over ShadowRealm:

    - You can use quickjs today in any browser with WASM. ShadowRealm isn't available yet, and polyfills have had security issues in the past. See https://www.figma.com/blog/an-update-on-plugin-security/

    - In ShadowRealm eval, untrusted code can consume arbitrary CPU cycles. With QuickJS, you can control the CPU time used during an `eval` using an [interrupt handler] that's called periodically during the eval.

    - In ShadowRealm eval, untrusted code can allocate arbitrary amounts of memory. With QuickJS, you can control both the [stack size] and the [heap size] available inside the runtime.

    - quickjs-emscripten can do interesting things with custom module loaders and facades that allow synchronous code inside the runtime to call async code on the host.

    Pros of ShadowRealm over QuickJS:

    - ShadowRealm will (presumably?) execute code using your native runtime, probably v8, JavaScriptCore, or SpiderMonkey. Quickjs is orders of magnitude slower than JIT'd javascript performance of v8 etc. It's also slower than v8/JSC's interpreters, although not by a huge amount. See [benchmarks] from 2019.

    - You can easily call and pass values to ShadowRealm imported functions. Talking to quickjs-emscripten guest code requires a lot of fiddly and manual object building.

    - Overall the quickjs(-emscripten) API is verbose, and requires manual memory management of references to values inside the quickjs runtime.

    [interrupt handler]: https://github.com/justjake/quickjs-emscripten/blob/main/doc...

    [stack size]: https://github.com/justjake/quickjs-emscripten/blob/main/doc...

    [heap size]: https://github.com/justjake/quickjs-emscripten/blob/main/doc...

    [benchmarks]: https://bellard.org/quickjs/bench.html

  • Extism Makes WebAssembly Easy
    13 projects | news.ycombinator.com | 4 Oct 2023
    The thing I want to achieve with WebAssembly is still proving a lot harder than I had anticipated.

    I want to be able to take strings of untrusted code provided by users and execute them in a safe sandbox.

    I have all sorts of things I want this for - think custom templates for a web application, custom workflow automation scripts (Zapier-style), running transformations against JSON data.

    When you're dealing with untrusted code you need a really robust sandbox. WebAssembly really should be that sandbox.

    I'd like to support Python, JavaScript and maybe other languages too. I want to take a user-provided string of code in one of those languages and execute that in a sandbox with a strict limit on both memory usage and time taken (so I can't be crashed by a "while True" loop). If memory or time limit are exceeded, I want to get an exception which I can catch and return an error message to the user.

    I've been exploring options for this for quite a while now. The furthest I've got was running Pyodide inside of Deno: https://til.simonwillison.net/deno/pyodide-sandbox

    Surprisingly I've not found a good pattern for running a JavaScript interpreter in a WASM sandbox yet. https://github.com/justjake/quickjs-emscripten looks promising but I've not found the right recipe to call it from server-side Python or Deno yet.

    Can Extism help with this? I'm confident I'm not the only person who's looking for a solution here!

  • Node on Web. Use Nodejs freely in your browser with Linux infrastructure.
    8 projects | /r/node | 3 Jul 2023
    "Safely execute untrusted Javascript in your Javascript, and execute synchronous code that uses async functions" quickjs-emscripten, NPM
  • Sandboxing JavaScript Code
    2 projects | news.ycombinator.com | 19 Apr 2023
    This maybe, as a start?

    https://github.com/justjake/quickjs-emscripten

  • Hacker News top posts: Nov 20, 2022
    5 projects | /r/hackerdigest | 20 Nov 2022
    QuickJS Running in WebAssembly\ (17 comments)
  • QuickJS Running in WebAssembly
    1 project | /r/hypeurls | 19 Nov 2022
    4 projects | news.ycombinator.com | 19 Nov 2022
    The library was inspired by Figma’s blog posts about their plug-in system: https://github.com/justjake/quickjs-emscripten#background
  • Show HN: Run unsafe user generated JavaScript in the browser
    14 projects | news.ycombinator.com | 19 Nov 2022
    If you need to call into user-generated Javascript synchronously or have greater control over the sandbox environment, you can use WebAssembly to run a Javascript interpreter: https://github.com/justjake/quickjs-emscripten#quickjs-emscr...

    QuickJS in WebAssembly is much slower than your browser's native Javascript runtime, but possibly faster than async calls using postMessage. As an added bonus, it can make async functions in the host appear to be synchronous inside the sandbox using asyncify: https://emscripten.org/docs/porting/asyncify.html.

  • Why Would Anyone Need JavaScript Generator Functions?
    19 projects | news.ycombinator.com | 7 Nov 2022
    You can use One Weird Trick with generator functions to make your code "generic" over synchronicity. I use this technique to avoid needing to implement both sync and async versions of some functions in my quickjs-emscripten library.

    The great part about this technique as a library author is that unlike choosing to use a Promise return type, this technique is invisible in my public API. I can write a function like `export function coolAlgorithm(getData: (request: I) => O | Promise): R | Promise`, and we get automatic performance improvement if the user's function happens to return synchronously, without mystery generator stuff showing up in the function signature.

    Helper to make a function that can be either sync or async: https://github.com/justjake/quickjs-emscripten/blob/ff211447...

    Uses: https://cs.github.com/justjake/quickjs-emscripten?q=yield*+l...

  • Why Am I Excited About WebAssembly?
    9 projects | news.ycombinator.com | 17 Jul 2022
    This seems like a pretty nice, recently enabled way of getting a sandboxed js environment: QuickJS compiled to WASM: https://github.com/justjake/quickjs-emscripten.

SES-shim

Posts with mentions or reviews of SES-shim. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-06-02.
  • Malicious libraries can steal all your application secrets in Elixir
    1 project | news.ycombinator.com | 22 Jul 2023
    I used E in the 90s: http://erights.org/

    I haven't kept up with newer systems but I've heard of https://github.com/endojs/endo and just came across http://reports-archive.adm.cs.cmu.edu/anon/home/anon/isr2017... (which says "in the style of the E programming language" -- that's as far as I've read) while looking that up.

    WebAssembly was designed to follow the same capability security principles. CHERI too as someone else just brought up.

  • Building an Extension System on the Web
    7 projects | dev.to | 2 Jun 2023
    There are other potential solutions I haven’t explored close enough (like Endo and SES), or completely omitted as they’re based on an imperfect blacklist-based approach to security (like sandboxed WebWorkers). However, the mentioned 4 solutions are the top contenders, at least in my mind.
  • Harvesting credit card numbers and passwords from your site
    1 project | news.ycombinator.com | 14 Feb 2023
    I don't know why you are being silently downvoted, as I think it is worth talking about the potential of using static analysis to improve things.

    One promising approach is Endo[0] which "uses LavaMoat to automatically generate reviewable policies that determine what capabilities will be distributed to third party dependencies."

    [0] https://github.com/endojs/endo

  • Show HN: Run unsafe user generated JavaScript in the browser
    14 projects | news.ycombinator.com | 19 Nov 2022
    Agoric moved forward and Realms gave way to SES

    https://github.com/endojs/endo/tree/master/packages/ses

    And Endo is a set of tools (being) built around it to make it more practical for particular usecases

  • Deno 1.26
    4 projects | news.ycombinator.com | 29 Sep 2022
    Yea you could restrict the app by whitelisting only the network services and folders that it will use and that's pretty valuable though at least on Linux could already easily be achieved otherwise. It's good that Deno makes it easy but let's be honest, most people will just pass -A.

    I'd love to see a permissions system on a library basis. It would ask the first time a dependency is added and when a new permission is requested after an update. Javascript doesn't make that easy though by being so dynamic. SES could maybe help: https://github.com/endojs/endo/blob/master/packages/ses/READ...

  • Node runtime that sandboxes all NPM dependencies by default
    2 projects | news.ycombinator.com | 9 Feb 2022
    I was poking around on the internet a bit earlier and I found this project. It looks pretty cool, and I figured perhaps a few of y'all might find it cool too!

    I have no idea if it actually sandboxes networking by default. This other project, endo[0], seems to add some of that functionality.

    Regardless of the maturity though, it makes me excited to see this type of work getting done now!

    (What made me want to research it was this[1] thread from the other day.)

    0: https://github.com/endojs/endo

    1: https://news.ycombinator.com/item?id=30215212

  • Open source maintainer pulls the plug on NPM packages colors and faker, now what
    8 projects | news.ycombinator.com | 9 Jan 2022
    Fortunately the problem could become more tractable if something like SES / Endo takes off:

    "Endo protects program integrity both in-process and in distributed systems. SES protects local integrity, defending an application against supply chain attacks: hacks that enter through upgrades to third-party dependencies. Endo does this by encouraging the Principle of Least Authority. ... Endo uses LavaMoat to automatically generate reviewable policies that determine what capabilities will be distributed to third party dependencies."

    https://github.com/endojs/endo

  • Is metamask running on JavaScript?
    3 projects | /r/Metamask | 20 Dec 2021
  • Embedded malware in RC (NPM package)
    7 projects | news.ycombinator.com | 5 Nov 2021
  • Researcher hacks over 35 tech firms in novel supply chain attack
    11 projects | news.ycombinator.com | 10 Feb 2021
    Yeah. JavaScript is probably the closest to being there (with things like SES[0], LavaMoat[1], etc.) but we're not quite there yet. It's just shocking that this sort of thing is as seemingly obscure as it is; it's like the whole industry has collectively thrown up their hands and said code execution is unavoidably radioactively dangerous. (While simultaneously using package managers that... well.) But it doesn't have to be!

    [0] https://github.com/Agoric/ses-shim

    [1] https://github.com/LavaMoat/LavaMoat

What are some alternatives?

When comparing quickjs-emscripten and SES-shim you can also consider the following projects:

wasmtime - A fast and secure runtime for WebAssembly

rfcs - Public change requests/proposals & ideation

wasmer - 🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten

Swift Argument Parser - Straightforward, type-safe argument parsing for Swift

wizer - The WebAssembly Pre-Initializer

GHSA-g2q5-5433-rhrf

rr - Record and Replay Framework

colors.js - get colors in your node.js console

go - The Go programming language

sandworm-guard-js - Easy auditing & sandboxing for your JavaScript dependencies 🪱

iPlug2 - C++ Audio Plug-in Framework for desktop, mobile and web

linux - Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/