top 32 comments

sorted by: hot top controversial new old
[–] 22 points 1 year ago* (1 child)

I found the same IPs doing the same thing for my server, but one thing I noticed in the access log was that nginx was returning a 499 status code. That code means that the client closed the connection before the server answered the request. So this seems to be a deliberate attack instead of the rash of bots many have been dealing with recently. They just firehose out requests to DoS the server since pagination on services with dynamic data is expensive.

I ended up creating a fail2ban rule to add any IP to my firewall blocklist that makes a bunch of 499 entries.

Edit: I also set a rate limit in nginx for any url that has a "page" query included

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 15 points 1 year ago*

    Get a blocklist and set it up.

    Literally all of the IPs are known bots for up to 3 years:

    Oh and maybe also a rate-limiter...

  • source
  • [–] 29 points 1 year ago

    That "jackass" sounds like an AI training set scraper. They're known for being incredibly brutal to the sites they scrape, ignoring robots.txt and other honor-based systems for preventing the site from getting overloaded.

  • source
  • [–] 9 points 1 year ago* (2 children)

    FYI these are all on ASN 49453

    The other (lazier) option is to block/challenge the ASN

  • source
  • hideshow 2 child comments
  • load more comments (1 reply)
    [–] 9 points 1 year ago

    Thanks for sharing

  • source
  • [–] 9 points 1 year ago (2 children)

    Sounds like such unscoped requests should not be allowed in the first place? Maybe worth reporting in a Lemmy issue?

  • source
  • hideshow 2 child comments
  • [+] [S] 3 points 1 year ago (1 child)
  • [–] 5 points 1 year ago*

    It's only useful with the ModeratorView type. I haven't heard more than just a few using it for anything other than for moderation purposes. It is useful for some type of bots, for example. But I think they should opt in for a solution with the upcoming plugin system (for example a webhook) or with mentions. Polling this endpoint is not very efficient and it is very possible to even miss some comments.

    So I think this endpoint should be just for the modview type and authorization should therefore be required.

    Or the rate limit should be more fine tunable. There are like only 4 configurable rate limits that encompass all endpoints.

  • source
  • parent
  • [–] 9 points 1 year ago* (2 children)

    For Cloudflare users:
    Security Rules:

    (http.request.uri.path eq "/api/v3/comment/list" and not http.request.uri.query contains "post_id")
    

    For Caddy users:

      # >>> Specific handler for /api/v3/comment/list with post_id check
      handle_path /api/v3/comment/list {
        # Check if the 'post_id' query parameter is present
        @hasPostId {
          query post_id=*
        }
        # Abort the connection if the parameter is missing
        handle @hasPostId {
          reverse_proxy http://localhost:8536/
        }
        # This handles all requests that did not match @hasPostId
        abort
      }
    
  • source
  • hideshow 2 child comments
  • [–] 6 points 1 year ago

    I found that the Caddy handler above blocked many third party clients and even Tesseract.

    So instead I'm using this CEL expression to return a 444 error on match of the unscoped old-sorted 50 per-page comments past page 99:

    @block_comment_spam expression <<CEL
        {http.request.uri.path} == "/api/v3/comment/list" &&
        {http.request.uri.query.limit} == "50" &&
        {http.request.uri.query.sort} == "Old" &&
        int({http.request.uri.query.page}) > 99 &&
        {http.request.uri.query.post_id} == ""
    CEL
    
    handle @block_comment_spam {
        respond 444
    }
    
  • source
  • parent
  • load more comments (1 reply)
    [–] 6 points 1 year ago (8 children)

    This is for Lemmy I presume (or also for Piefed or Mbin)? You've modified yours heavily though, I thought, which could complicate matters. I wonder if you are having those bot scraping issues that semi-recently (a month or so ago?) started increasing in frequency. So many instances now have a human detector before letting you in whereas before it was not necessary.

  • source
  • hideshow 8 child comments
  • [–] 4 points 1 year ago (5 children)

    PieFed has a similar API endpoint. It used to be scoped, but was changed at the request of app developers. It's how people browse sites by 'New Comments', and - for a GET request - it's not really possible to document and validate that an endpoint needs to have at least one of something (i.e. that none of 'post_id' or 'user_id' or 'community_id' or 'user_id' are individually required, but there needs to be one of them).

    It's unlikely that these crawlers will discover PieFed's API, but I guess it's no surprise that they've moved on from basic HTML crawling to probing APIs. In the meantime, I've added some basic protection to the back-end for anonymous, unscoped requests to PieFed's endpoint.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 1 year ago (3 children)

    Could you elaborate on this:

    it's not really possible to document and validate that an endpoint needs to have at least one of something

    In what sense it is not possible, as I can easily see it done in the code?

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 year ago (2 children)

    It's straight-forward enough to do in back-end code, to just reject a query if parameters are missing, but I don't think there's a way to define a schema that then gets used to auto-generate the documentation and validate the requests. If the request isn't validated, then the back-end never sees it.

    For something like https://freamon.github.io/piefed-api/#/Misc/get_api_alpha_search, the docs show that 'q' and 'type_' are required, and everything else is optional. The schema definition looks like:

    /api/alpha/search:
        get:
          parameters:
            - in: query
              name: q
              schema:
                type: string
              required: true
            - in: query
              name: type_
              schema:
                type: string
                enum:
                  - Communities
                  - Posts
                  - Users
                  - Url
              required: true
            - in: query
              name: limit
              schema:
                type: integer
              required: false
    

    required is a simple boolean for each individual field - you can say every field is required, or no fields are required, but I haven't come across a way to say that at least one field is required.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 6 points 1 year ago

    We had this issue on and off for a few weeks at least, causing massive postgres CPU spikes. I ended up blocking large page params with an nginx regex.

  • source
  • [–] 6 points 1 year ago

    Maybe we should introduce a gated API and charge $12 for 50k requests...

  • source
  • [–] 5 points 1 year ago (1 child)

    Isn't the same endpoint used to list all of a user's comments in their profile?

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [+] [S] 16 points 1 year ago* (last edited 1 year ago) (1 child)
  • [–] 3 points 1 year ago (2 children)

    Things have been slow for me off and on in recent weeks. And today it’s quite slow.

  • source
  • hideshow 2 child comments
  • [–] 3 points 1 year ago

    Not sure if there's a legit use for just fetching only comments outside of a post

    The ability to see all comments is right there at the Lemmy UI.

  • source
  • [–] 2 points 1 year ago

    To everyone in this thread, if you notice a problem in Lemmy please open an issue. We are only two developers and dont have time to browse the Fediverse all day to come across such things. Only if we know about a problem can we actually fix it and make a new release.

    For reference here are the issue and proposed fix:

  • source
  • [–] 1 point 1 year ago

    I think this could end up blocking https://lemmy-meter.info/ They make requests without post id

  • source
  • [–] 1 point 3 months ago

    Lulz, imagine being so butthurt over people being upset that you were manipulating their online experience without informing them first.

  • source