-
I recently went insane and made #4341. A PR that dumps a Lua interpreter into Chatterino. As of today (2023-02-01) Plugins can request access to the following parts of the standard library:
Note that for this to be available they must declare it in their info.json (here is how one looks). The UI does indicate what's used, even if the plugin isn't executing any code The whole dangerous library used is a little bit of a placeholder for a more proper system. In the Lua global namespace there is also a table with Chatterino specific functions available, Plugins don't need any specific permission to use it. Before #4341 is anywhere near getting merged, we must decide what kind of threat model are we going to use for Plugins. Mainly:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
If you can tell me how to test it, I can look into that for macOS. |
Beta Was this translation helpful? Give feedback.
-
Yes, we should limit functionality. I think a model similar to how Deno does it for Javascript or how it's done in web-extensions is good. There's info on built-in Lua functions related to sandboxing on lua-users.org and more info on sandboxing considerations for Roblox in Luau. Permissions could be similar to how they're currently done. I would rename the permissions and give it an entry (one plugin should only have one entry): {
"$schema": "https://raw.githubusercontent.com/Chatterino/chatterino2/master/docs/plugin.schema.json",
"entry": "plugin.lua", // or start...
"name": "My Plugin",
"description": "I exhaust all permissions",
"authors": "me",
"homepage": "https://chatterino.com",
"source": "https://github.com/Chatterino/plugins",
"tags": [],
"permissions": [
{
"name": "read", // without "data" it only allows reading in the plugin directory
"data": [
"res/**", // globs
"data.json",
"*" // this would allow everything
]
},
"write", // same model as "read" - here: only in the plugin directory
"run", // allows the plugin to run applications - same model as "read"
{
"name": "ffi",
"data": {
"windows-x64": {
"files": [
// maybe these should be downloaded to not waste storage
{ "path": "mylib.dll", "sha256": "3aa4c90b7a3263c64fee6222a4344692ce41501eb2b012b924e7414d168b8de0" }
]
},
"linux-aarch64": {
// ...
}
}
},
{
"name": "http", // only https should be allowed
"data": [
// See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns
"https://*.mozilla.org/*"
]
}
],
"version": "0.1.0-alpha.0", // requires semver
"license": "GPL-2.0"
} There should also be a limit on how many resources a plugin can use (similar to how it's done in Luau).
Non-technical users. Basically the scenario where a user sees something cool on Discord and mindlessly downloads the plugin. Chatterino should at least tell them, that the plugin has permission to, for example, run any file on his PC - maybe even with a tooltip why that could be dangerous. This should be done before the first run (otherwise there's no point in a permission model). I think permissions should be added in followup-prs. The initial implementation should only include the bare-minimum functions (e.g. math). This makes it easier to reason about a specific implementation of permissions. |
Beta Was this translation helpful? Give feedback.
-
Accepted as issue #4620. |
Beta Was this translation helpful? Give feedback.
Yes, we should limit functionality. I think a model similar to how Deno does it for Javascript or how it's done in web-extensions is good. There's info on built-in Lua functions related to sandboxing on lua-users.org and more info on sandboxing considerations for Roblox in Luau.
Permissions could be similar to how they're currently done. I would rename the permissions and give it an entry (one…