snacでのSPAM対策

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac でのSPAM 対策について.

SPAM が来ないに越したことはありませんがActivityPub でも偶に見かけます.もしSPAM が来るときのことを考えて対策を確認しておきます.
snac では2つの対策があるようです.

SPAM Mitigation
    There have been some SPAM attacks on the Fediverse and, as too many instances and server implementations out there still allow automatic account creation, it will only get worse.  snac includes some (not very strong) tools for try‐
    ing to survive the SPAM flood that will eventually happen.
The  min_account_age field in the main configuration file allows setting a minimum age (in seconds) to consider too recently created accounts suspicious of being a potential source of SPAM. This is a naïve assumption, because spam‐
mers can create accounts, let them dormant for a while and then start to use them. Also, some ActivityPub implementations don't even bother to return a creation date for their accounts, so this is not very useful.
From version 2.50, post content can be filtered out by regular expressions.  These weapons of mass destruction can be written into the filter_reject.txt file in the server base directory, one per line;  if  this  file  exists,  all
posts'  content  will  be  matched (after being stripped of HTML tags) against these regexes, one by one, and any match will make the post to be rejected. Use lower case, the regex will be case insensitive by default.  If you don't
know about regular expressions, don't use this option (or learn about them inw some tutorial, there are gazillions of them out there), as you and your users may start missing posts. Also, given that every regular expression  imple‐
mentation supports a different set of features, consider reading the documentation about the one implemented in your system.
— snac(8) より

アカウント作成から日の浅いアカウントを拒否

1つ目はメイン設定ファイルの server.json で設定できる min_account_age で,投稿を受け付けるアカウントが作成されてからの時間が設定できます.
ただし,SPAM アカウントを作成して寝かせてから運用したり,アカウントの作成日を返さない実装もあるらしいのであまり役に立たないようです.
既定値は 0 になっています.

$ jq .min_account_age server.json
0

投稿内容を正規表現でフィルタリング

2つめは投稿内容を正規表現でフィルタリングできるようです.snac データディレクトリに filter_reject.txt を用意してこのファイル中に1行ずつ記述できるようです.これにより全ての投稿をHTML タグを取り除いた後正規表現と1つずつ照合され一致する投稿は拒否されます.
正規表現なのでテストを十分して設定したほうが良さそうです.

Reverse proxy やFirewall などsnac の外で対策も考えられます.その他以下のようなものもあるようです.e-mail もこんな感じで多段にしたりしますね.そうなるとReceived のようなものが見たいなと思ったりも.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です