yukimochi / Activity-Relay

Yet another powerful customizable ActivityPub relay server written in Go.
https://relay.toot.yukimochi.jp/
GNU Affero General Public License v3.0
281 stars 39 forks source link

Increase in HTTP 400s #65

Closed mhamzahkhan closed 1 year ago

mhamzahkhan commented 1 year ago

Hello,

I've noticed there has been an increase in HTTP 400 responses lately from my relay. It appears to be when a user gets deleted on a subscribed instance. Is there any way to perhaps suppress this?

Eg this message from mastodon.social:

POST /inbox HTTP/1.1
Host: relay.intahnet.co.uk
User-Agent: http.rb/5.1.0 (Mastodon/4.0.2; +https://mastodon.social/)
Content-Length: 783
Accept-Encoding: gzip
Content-Type: application/activity+json
Date: Tue, 06 Dec 2022 02:19:11 GMT
Digest: SHA-256=6pIuvMfHG2tkx1M2YyuXFMxs1B29dCsSqRYfwHwUV0Q=
Signature: keyId="https://mastodon.social/users/epochjute52#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="w5rKlc9E3xaHaMr98+sZi2cFp8jdJc/NMcjHNcKQNF5CkcBNW5/exm08mOTDlIXrEWIrltTUl+tLVTJYJ9mgmdjeJiUJETL4ooGsyyp+wmzaQ3AqV7DxMcweyEdvF6oA907Bboo5df0oN706nmWJeQymakPOty3k+ziIOduJzIxDWq7bC8lK5Z2GpwEz48Rz2vPHGTnkeUd/cKNzw23PVnoeN4tW05gevzranxzuVf0UR5ttYSWndEj3lNqciYIos3jCwUWmg8wnS7r3eUtejP9pbqFrc7KTs/IKhfyF0cmR1Hk/yA6f/pLBZyagMU/mw0/OEuOihTsaZvxOOijLGg=="

{"@context":"https://www.w3.org/ns/activitystreams","id":"https://mastodon.social/users/epochjute52#delete","type":"Delete","actor":"https://mastodon.social/users/epochjute52","to":["https://www.w3.org/ns/activitystreams#Public"],"object":"https://mastodon.social/users/epochjute52","signature":{"type":"RsaSignature2017","creator":"https://mastodon.social/users/epochjute52#main-key","created":"2022-12-06T02:16:43Z","signatureValue":"N7vTgtsxBEBsy7e54OknzubroyYFKxbrAT7gTFuXMeePvPmbEplIOl7cvGlnKl3GeqS/ApNI8CmEMlAHqHaelQugVCY4kPhE5gHmgyVRR0BviXrBkUN22JUiTkwuQkSkXNpkOjyGS7MPHcbG89GOmJofsgHpzAd3zJuL/ie1mHNqN/QkD+AF8vCTb3rUb47HZCwiUQxbhUEf6qLamk3M4Z8/VCt4tbZwJtj0t1Sx0yvjRzAPHqJBj8C7weM5WIwMBx11BBbBGqOz13TE3u61QE4HrDnd2fv2Gw93ENxdl0ihkuysPnN8086XTaFtlzuqSNlQlvw3oykwRlLZTIlt1A=="}}

and the response:

HTTP/1.1 400 Bad Request
Server: nginx/1.21.6
Date: Tue, 06 Dec 2022 02:19:11 GMT
Content-Length: 0
Connection: keep-alive
yukimochi commented 1 year ago

Conclusion: Treat same as spam request, prefer to block request with reverse-proxy or skip logging about that with your logging solution. ( by User-Agent, IP Address, and so on...)

Principle: Point 1: Using Activity-Relay ( send activity to /index ) are limited for subscriber only. Point 2: Activity-Relay acts returning 400 for unallowed requests. ( 401 might be better? But that's not the point. ) Point 3: By unclear reason mastodon.social sent delete request for your relay without subscription. ( Maybe when account deletion it will send delete to all peers...? But I don't know details... )