Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

A browser circuit simulator still ships its component models and solver

In-browser electronics labs, "circuit playgrounds", and soldering-course widgets often advertise a realistic simulation: op-amps that saturate, SPICE-like transient analysis, and vendor component models. If that realism

In-browser electronics labs, "circuit playgrounds", and soldering-course widgets often advertise a realistic simulation: op-amps that saturate, SPICE-like transient analysis, and vendor component models. If that realism runs entirely in JavaScript or WebAssembly downloaded with the page, the models and the solver are sitting in the user's cache.

The work that took months — diode equations, MOSFET corners, convergence tricks — is then one pretty-print away from a competing lab or a pirated "offline edition".

What actually ships

A typical browser simulator includes more than a schematic editor:

  • Device models — Shockley diode parameters, MOSFET Level 1/3 (or compact models), op-amp macromodels, and the defaults behind each library part.
  • Solver control — Newton-Raphson iteration limits, timestep control, Gmin stepping, and the tricks you use when a circuit will not converge.
  • Vendor or course libraries — part numbers, pin maps, and the "accurate enough" models you licensed or measured.
  • Instrument logic — how the virtual scope, Bode plot, and THD measurement are computed.
  • Assessment hooks — the hidden checks a course uses to decide that a student's circuit is "correct".

That last one is a grading key. If it ships in the page, students will hook it.

How it gets lifted

People search the bundle for strings like Is =, Vth, gmin, or a function named stampMosfet.

export function stampDiode(n, anode, cathode, { Is, N, Vt }) {
  const vd = n.v[anode] - n.v[cathode];
  const id = Is * (Math.exp(vd / (N * Vt)) - 1);
  const geq = (Is / (N * Vt)) * Math.exp(vd / (N * Vt));
  n.stampConductance(anode, cathode, geq);
  n.stampCurrent(anode, cathode, id - geq * vd);
}

export const LIB = {
  "1N4148": { Is: 2.52e-9, N: 1.73, Vt: 0.026 },
  "LM358": { /* macromodel poles, gain, Ios */ },
};

Once LIB and the stamper are public, a rival product can advertise "the same models" without the measurement work. Course authors who hid an autograder in checkCircuit(netlist) will watch students submit perfect scores from a hooked function.

What actually protects you

Move what you can off the client

  • Graded labs and official results should be simulated (or at least verified) on the server. The client can animate waveforms the server already computed.
  • Licensed vendor models belong behind an authenticated API. Ship a coarse teaching model for instant dragging; fetch the accurate model after a signed request.
  • Certificate and "pass this module" decisions must not trust a boolean returned in the page.

Protect the interactive solver that must stay local

Live dragging and offline labs still need a local engine. For that chunk:

  • Bundle the solver and library separately from the schematic UI.
  • Apply stronger-than-mangling protection (control-flow flattening or VM-based compilation) to device models, the solver loop, and library decoding.
  • Keep tight numeric kernels lighter if you measure a frame-time regression; protect the model parameters and control logic first.
  • Leave source maps off the public CDN.
  • Add a few harmless, distinctive model quirks so a lifted library is recognizable.

Do not treat the client as a grading authority

If a badge is awarded because checkCircuit returned true, anyone can force the return value. Official checks need a server that ran, or independently verified, the netlist.

Practical checklist

  • [ ] Graded simulations and certificates are decided on the server, not only by the in-page solver.
  • [ ] Licensed or measured component libraries are not shipped in full in the public bundle.
  • [ ] The solver and model chunk is split from the editor UI.
  • [ ] That chunk is protected with stronger-than-Terser obfuscation (control-flow or VM).
  • [ ] Numeric performance is measured after protection; hot loops can be left lighter.
  • [ ] Source maps for the solver are not on the public CDN.
  • [ ] Distinctive, harmless model markers exist so you can recognize a copy.
  • [ ] Autograder hooks cannot be forced true from DevTools.

Honest limits

A determined engineer can still characterize your models by probing the simulator like a black box. Obfuscation raises the cost of a casual file copy; it does not hide physics. If a parameter cannot be public, do not put it in JavaScript.

Summary

A browser circuit lab ships the work that makes it feel accurate: the models, the solver, and often the course checks. Run official results on the server, protect the offline engine you have to ship, and stop treating a local stampDiode as a secret.

Disclosure: I work on VEILVM, a JavaScript VM-protection service. Free browser tier (3 runs/day, up to 5 KB) and a Pro plan at $9/month or $79/year with API access. Try the playground at vm.ldvmp.com.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.