News for hackers. Stuff that matters.
Re:Show HN: Sandboxing untrusted code using WebAssembly by mavdol04 on Tuesday February 03, 2026 @11:41AM (#46873326)
Thanks! Got it, I will add more examples for that. Currently you can do both: run dynamically untrusted code with eval, or run fully encapsulated logic (like in the existing examples).

I made a small example that might give you a better idea (it's not eval, but shows how to isolate a specific data processing task): https://github.com/mavdol/capsule/tree/main/examples/javascr...

And yes, you are spot on regarding LeetCode platforms. The resource limits are also designed for that kind of usage.

Re:Show HN: Sandboxing untrusted code using WebAssembly by zachrip on Tuesday February 03, 2026 @12:26PM (#46873992)
Would like to see the eval version - the dialogue version just seems like normal code with extra steps?
Re:Show HN: Sandboxing untrusted code using WebAssembly by mavdol04 on Tuesday February 03, 2026 @12:49PM (#46874359)
yeah, the previous example was quite basic. I will write a complete example for that, but here is how you can run dynamic code:

   import { task } from "@capsule-run/sdk";

   export default task({
     name: "main",
     compute: "HIGH",
   }, async () => {
     const untrustedCode = "const x = 10; x * 2 + 5;";
     const result = eval(untrustedCode);
     return result;
   });
Hope that helps!
Re:Show HN: Sandboxing untrusted code using WebAssembly by zachrip on Thursday February 05, 2026 @08:16AM (#46899297)
Is the code in the eval also turned into wasm first then? Does this work as a JIT for wasm?
Re:Show HN: Sandboxing untrusted code using WebAssembly by mavdol04 on Thursday February 05, 2026 @06:40PM (#46907046)
It actually works a bit differently. The eval is executed by the interpreter running inside the isolated wasm sandbox (StarlingMonkey). You can think of it as each sandbox having its own dedicated JavaScript engine.
Re:Show HN: Sandboxing untrusted code using WebAssembly by fix4fun on Tuesday February 03, 2026 @05:26PM (#46878235)
yep, more examples with agents use will be helpful