In my view what separates TiddlyWiki from other wikis (and makes it fun) is that everything is a tiddler, even widgets, macros and javascript tiddlers. There is no separation between content and code.
There’s been several threads on using TiddlyWiki in a multiuser context, but I haven’t seen a discussion of how we can keep TiddlyWiki extensible and powerful without becoming a security nightmare.
Potential for attacks
Naively allowing anyone to add tiddlers to a wiki could result in malicious code automatically doing the following without the victim’s consent:
- impersonating other users towards third parties (eg: using their auth cookies in requests)
- defacing the UI
- accessing private information
- deleting or updating users’ tiddlers (potentially with self-replicating code)
TiddlyWiki’s focus on “hackability” means it’s often enough to tag a tiddler with a $:/
-prefixed tag for the code within to be triggered by a UI button or run automatically on wiki load. This is a good thing as long as we can figure out a way to keep it secure.
Single- and multiuser scenarios
In a single-user scenario, a single individual is both the author and the viewer of tiddlers. The trust model is simple: the author must trust the code in the official tiddlywiki release + any plugins they may be using (we can call this vendor code). Any additional logic is his own (author code).
Multi-user can refer to several scenarios:
- multiple devices, single user. This is the same as the single device single user case from a trust perspective: vendor + author code.
- multiple users, each read only. Since users cannot persist their modifications to the wiki, other users are still running only vendor code without augmentation from wiki users.
- multiple isolated users. Each user can create new / shadow existing tiddler which are saved to a database, but other users don’t see these changes. To each user it’s like they have their own wiki, the union of vendor tiddlers coming from the wiki HTML and author tiddlers loaded from the database. There’s no way for users to collaborate, but also no attack surface (only vendor + author code).
- multiple users with shared tiddlers. This is what most people generally think of when they say “multi user TiddlyWiki”. In addition to vendor and author code, users will also be running other wiki users’ code (other user code), potentially less trustworthy than the first two, but enjoying the same privileges. Tiddlers containing other user code would live in a database just like author code.
Trust with shared tiddlers
A possible compromise between hackability and security could be running other user code with limited privileges, while vendor and author code could continue to run at full privileges (exactly as in single user scenarios). We could prevent each type of attack listed above by placing restrictions on tiddlers shared by several users:
- Impersonating other users towards third parties: by using sandboxed iframes to display tiddlers containing other user code the
Origin
would benull
, so CORS won’t allow cookies to be sent with outgoing requests. - defacing the UI: no
$:/
-prefixed tags and restrictions ontype
andmodule-type
fields for shared tiddlers. - accessing private information and deleting or updating users’ tiddlers: the “other user code sandbox” iframe has limited access to the wiki:
Other user code wiki permissions
Other user code should be able to:
- persist some state for the current user only (a good example is a “dark mode” toggle).
- persist some state for the entire wiki (a good example is a moving a card to a different lane in a kanban).
It should not be able to:
- read fields of tiddlers it was not authorized to access.
- alter/shadow/create new tiddlers which enjoy vendor or author trust status (this would allow it to escape the sandbox).
- alter tiddlers containing other user code (this would allow self replication for example).
Perhaps a too restrictive, but one possible answer could be allowing other user code to:
- read any tiddler (with the possible exception of tiddlers explicitly marked as private somehow).
-
write/delete only tiddlers
application/json
type tiddlers which are also shared.
As vendor code could still be run with full access to TiddlyWiki, tiddlers containing other user code which need greater privileges could be moved into the wiki HTML.
What would be your suggestions? What would be a sane policy to determine which tiddlers can be read / written by other user code? Since you participated in previous multi-user discussions, I would be particularly curious to hear your thoughts, @jeremyruston, @linonetwo, @Springer, @TW_Tones, @joshuafontany, @Charlie_Veniot, @TiddlyTweeter.
Identifying shared tiddlers
A new title prefix, such as €:/
could be used to denote the fact that a tiddler is shared among all wiki users (and thus requires restrictions in permitted tags and rendering mechanism).