Harry Potter and The Jabber Spam
################################
:date: 2017-01-13T16:21:16
:category: computer
:tags: xmpp
After many many years of happy using :abbr:`XMPP (Jabber)` we
were finally awarded with the respect of spammers and suddenly
some of us (especially those who have their :abbr:`JID (Jabber
ID)` in their email signature) are getting a lot of :abbr:`spim
(IM Spam)`.
Fortunately, the world of Jabber is not so defenceless, thanks to
`XEP-0016`_ (Privacy Lists). Not only it is possible to set up
list of known spammers (not only by their complete JIDs, but also
by whole domains), but it is also possible to build a more
complicated constructs.
Usually these constructs are not very well supported by GUI so
most of the work must be done by sending plain XML stanzas to the
XMPP stream. For example with pidgin_ one can open XMPP Console
by going to Tools/XMPP Console and selecting appropriate account
for which the privacy lists are supposed to be edited.
Whole system of ACLs consists from multiple lists. To get a list
of all those privacy lists for the particular server, we need to
send this XMPP stanza:
.. code-block:: xml
If the stanza is sent correctly and your server supports
XEP-0016, then the server replies with the list of all privacy
lists:
.. code-block:: xml
To get a content of one particular list we need to send this
stanza:
.. code-block:: xml
And again the server replies with this list:
.. code-block:: xml
Server goes through every item in the list and decides based on
the value of ``action`` attribute. If the actual considered
stanza does not match any item in the list, the whole system
defaults to ``allow``.
I was building a blocking list like this for some time (I have
even authored `a simple Python script`_ for adding new JID to the
list), but it seems to be road to nowhere. Spammers are just
generating new and new domains. The only workable solution seems
to me to be white-list. Some domains are allowed, but everything
else is blocked.
See this list stanza sent to the server (answer should be simple
one line empty XML element):
.. code-block:: xml
Server goes in order through all items on the list, and if it
doesn’t match on any item, it hits the last item in the list,
which denies the access.
It is also useful to make sure the list which have actually
created be default:
.. code-block:: xml
So, now I am in the state of testing, how it works (using as
server jabberd2 version 2.4.0 from the RHEL-6/EPEL package).
.. _`XEP-0016`:
http://xmpp.org/extensions/xep-0016.html
.. _pidgin:
http://pidgin.im/
.. _`a simple Python script`:
https://github.com/horazont/aioxmpp/blob/devel/examples/block_jid.py