-
Notifications
You must be signed in to change notification settings - Fork 121
Switch from SpiderMonkey 1.7 to Duktape #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Note that the Duktape used is 2.7 and built with default options. It could perhaps be made unvendored and rely on a system Duktape, but that seems hairy with the current makefile. |
|
@NattyNarwhal Sorry for super late review, but this looks great to me. Thanks so much. Do you want to send it for review? |
|
I'd appreciate review; I'm uncertain about lifetimes myself, though it seems to be OK with the unit tests. Windows support is also untested, as is unvendoring Duktape for i.e. distro packaging. |
pacparser currently vendors SpiderMonkey 1.7, a JavaScript engine that predates the Obama presidency. There's been a ton of changes to JavaScript and best practices when it comes to security and portability, so using this old version of SM doesn't make sense anymore. People are [trivially able to write exploits][ancientmonkey] against this old version, and seeing as PAC files could come from untrusted networks, that doesn't seem like a wise decision. To replace it, I've used duktape, a popular compact and embeddable JS runtime. There are a lot, but duktape seems popular; for example, polkit switched from (newer) SpiderMonkey to duktape. The only change I've needed to make to JS code is that RegExps don't seem to be callable under duktape; they aren't under V8 either though, so this might have been a Mozilla-ism. The massively smaller codebase of duktape is hopefully better security and maintainability wise, but also results in much smaller binaries. For example, pactester goes from 1.5M to 687K on my system. Passes unit tests on macOS. Not tested on Linux/Windows yet. However, I'm not certain about i.e. string lifetimes with duktape. They didn't seem clear with SpiderMonkey either though; perhaps it'd be an opportunity to i.e. explicitly strdup them? [ancientmonkey]: https://blog.pspaul.de/posts/ancient-monkey-pwning-a-17-year-old-version-of-spidermonkey/
pacparser currently vendors SpiderMonkey 1.7, a JavaScript engine that predates the Obama presidency. There's been a ton of changes to JavaScript and best practices when it comes to security and portability, so using this old version of SM doesn't make sense anymore.
People are trivially able to write exploits against this old version, and seeing as PAC files could come from untrusted networks, that doesn't seem like a wise decision.
To replace it, I've used duktape, a popular compact and embeddable JS runtime. There are a lot, but duktape seems popular; for example, polkit switched from (newer) SpiderMonkey to duktape. The only change I've needed to make to JS code is that RegExps don't seem to be callable under duktape; they aren't under V8 either though, so this might have been a Mozilla-ism.
The massively smaller codebase of duktape is hopefully better security and maintainability wise, but also results in much smaller binaries. For example, pactester goes from 1.5M to 687K on my system.
Passes unit tests on macOS. Not tested on Linux/Windows yet. However, I'm not certain about i.e. string lifetimes with duktape. They didn't seem clear with SpiderMonkey either though; perhaps it'd be an opportunity to i.e. explicitly strdup them?