OK. Thid was not at all obvious in your previous posts, which talked about “library failures” and “third-party frameworks”.
So you’re talking about an AS library which is embedded in an (otherwise non-functional) app for distribution purposes, as per #8 here. The user downloads that app and installs it on their machine, and AS can now find and use all the libraries embedded within it.
And you’re saying 12.5 no longer allows AppleScripts to import libraries from this installed “library wrapper” app?
Good. I trust that’s an intentional, permanent change by Apple.
This was always a serious misfeature, and a genuine security hole too. It made it easy to smuggle a malicious AppleScript library onto AppleScript’s default search path by tucking it inside an otherwise innocuous app, e.g.:
/Applications/SomeApp.app/Contents/Library/Script Libraries/Text.scpt
would make a library named “Text” visible to all AppleScripts installed on that Mac.
Furthermore, since it’s a native AS library, it executes inside your script’s context (e.g. Script Debugger, FastScripts, ASOC app, or AS applet), thereby escaping the original app’s own sandbox. Yipe!
ISTR (vaguely) voicing my own concern to one of the Chrises at the time. I think originally it was higher in the search hierarchy so app-installed libraries could even mask libraries installed in /Library/Script Libraries
and so get loaded first. The final implementation puts app-embedded libraries last on AS search path, which ameliorates that risk—although that still leaves two exploitable holes:
-
If the user doesn’t already have the real “Text” library installed on their Mac, use script "Text"
would end up importing and using the malicious version; and
-
If two differently-named library-wrapper apps are installed on the same Mac, one containing the legitimate “Text” library and the other with a malicious “Text” library, which of those libraries get be loaded by use script "Text"
? It could be either, presumably depending on which app bundle AS searches first.
…
The only reason that this was never a practical attack vector with known exploits out in the wild is because the number of Mac users who run AppleScripts is tiny, and the number of those users who use third-party libraries miniscule. So any blackhat who’d waste their time making it would have to be extraordinarily bored.
Still, the idea that a globally-importable library could be inserted onto a user’s machine without the user knowingly, intentionally installing it is frightening. In hindsight I should’ve called it out as a Completely Bad Idea and pressed against it being implemented at all, e.g. by filing a Radar report to make Apple’s security team aware of the hole being opened. But I didn’t understand security so well a decade ago.
I’ve spent more time around NPM et al since then, so am more aware now. Still not an expert, but I know enough about the issues to know those big popular languages (Node.js, Python, etc) and their enormous library repositories are a fricking security horror, which 99% of those language users deal with by completely ignoring/being completely ignorant of/denying there is even a problem. (And internet commerce runs on those langs! Our PII and CC numbers, in their hands!)
…
Addendum: App-embedded AS libraries could have been acceptable, had AS required the library’s location to be explicitly declared in the tell
/use
statement, e.g.:
use script "Myriad Tables Lib" of application "Shane’s Script Library Pack.app"
Obviously with that there is still the issue of having two different apps of that name on the same Mac, but that’s no different to the issue AppleScripters already have when targeting scriptable apps by name/bundle ID, and there is multiple identically-named/IDd versions of the same app installed (Hello, Adobe Illustrator.app). But at least the code now makes explicit where that library is to be found, making unintentional imports from anywhere else impossible.
Anyway, it would not surprise me if your SLP is the only app on earth to distribute+install AS libraries this way. So it sounds like the right solution is for you to go back to distributing thoaw libraries as simple .scptd
files, which AppleScript users can install into their Script Libraries
folder the old-fashioned way. (And they can deal with the inevitable pains of codesigning, distributing, etc their own software from there; but that’s a separate problem.)
Or, if you really must have them as .app
bundles, you could go really old school and convert them into “Script Servers” (remember those?!): stay-open AS applets that expose their handlers for other scripts to call via Apple events, just like any other scriptable faceless background app.
…
Thank you for clarifying your original post. (And for the fun trip down the old memory path.
Now we just need Apple to clarify its policies, which studiously remain clear as mud. We live in hope.