It doesn't seem right that the big players like Facebook and Twitter enjoy much better security. Is there really no open source offering that just gets this stuff right? A Twitter-in-a-box, like WordPress is a blog-in-a-box, but secure this time?
Apparently Gab used Mastodon. Is Mastodon intrinsically hard to secure?
No, we can't conclude that yet. Gab modified their instance heavily from Mastodon code over several years. People are also pointing to an addition made by Gab, where an SQL query is used without input sanitization, as a possible culprit for the breach.
SQL injection that was used for the breach was introduced after the fork. We know that for sure because the source code was public, as is required by AGPL Mastodon uses.