Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable rate limiting on -dev #8540

Closed
AlexandraMoga opened this issue Oct 15, 2021 · 15 comments · Fixed by mozilla/addons-server#18463 or mozilla/addons-server#19508
Closed

Enable rate limiting on -dev #8540

AlexandraMoga opened this issue Oct 15, 2021 · 15 comments · Fixed by mozilla/addons-server#18463 or mozilla/addons-server#19508

Comments

@AlexandraMoga
Copy link

Describe the problem and steps to reproduce it:

Currently add-ons submission and API throttling is enabled only on stage. When an issue that affects this functionality is closed, we usually have to wait until the code lands in stage to be able to verify it. By enabling rate limiting on -dev, we can have such issues tested earlier.

As far as I'm aware, we currently have the following throttles:

I've already raised this issue to @diox on slack and, if everyone else agrees, we can re-enable throttling on -dev.

@diox
Copy link
Member

diox commented Dec 7, 2021

We tried to do that but the new API doesn't have the same bypasses yet so it's a bit annoying. Instead, we want to add a bypass mechanism directly in the throttle classes so that it applies to everything automatically. (And we can probably keep the existing code to bypass throttling on ratings/old signing API for now)

@diox
Copy link
Member

diox commented Jul 28, 2022

I gave the new API:BypassThrottling permission to the 2 groups mentioned, and started using that permission instead of the previously existing ones to bypass rate limiting everywhere on the site. And re-activated rate limiting on dev.

@AlexandraMoga
Copy link
Author

I've verified the new permission to successfully bypass the following throttles:

  • add-on submissions through Devhub
  • addon submission through the new submissions API
  • addon submission with the old signing API
  • posting multiple ratings
  • posting abuse reports

Without the permission, throttling still applies as before.

@ioanarusiczki
Copy link

@diox

I tested the abuse reports throttles on -stage a month ago when I was writing a test case. I remembered something and checked it again with -dev:

I can send with Postman using the APIs 20 mixed requests (to report a user or an addon , authenticated with Session ID or anonymous ) then I hit the 429, Too Many requests.

Then if I try it using a browser (same PC) I can send 20 more reports for addons/users.

Should I receive a 429 per IP address after the first 20 attempts ?

@diox
Copy link
Member

diox commented Aug 17, 2022

Yeah it should be 20 reports per IP per day regardless of how they were posted. If you are sure this is using the same IP (no proxy/VPN/etc) then please file an issue.

@AlexandraMoga
Copy link
Author

@diox Just for the record, I've tried the following method to test the API throttling for abuse reports (no proxy/VPN on):

  1. I've sent 20 authenticated requests using a python requests script until I've hit a user_abuse rate limit (recorded in this activity log)
  2. I've switched to the browser, logged in with a different account and tried to submit an addon abuse report: the addons manager abuse report window opened, I've filled in the required fields and submitted the abuse; there was no confirmation message received and when looking in the browser console I could see the following error message: Reporting add-on for abuse via firefox failed: Error: Error submitting abuse report which indicates that the abuse report was not posted; I've checked the admin abuse reports and there was indeed no entry created for this attempt; I've checked the activity logs and I found an ip_abuse entry for the user
  3. I've repeated step two with another user and had the same results, and I've seen an ip_abuse entry as well
  4. I've sent anonymous requests both from the browser and using the python requests script and the abuse report was not submitted either (there are no activity logs for anonymous requests apparently so I don't have the exact examples)
  5. The throttling also applies to user abuse reports

There is something I've noticed though: user_abuse throttles are set for 24 hours while IP throttles seem to last only for ~ 3 hours (I don't have the exact time because I started counting a bit later after the requests were sent and than I was already at a 2.3 hours waiting time).

Hope this helps and if @ioanarusiczki arrives to different results we can compare our findings.

@diox
Copy link
Member

diox commented Aug 19, 2022

Both throttles should last 24 hours. However, something to keep in mind when testing on dev: cache will be reset at each deploy! So depending on what was happening on dev when you were testing that may have had an impact.

@AlexandraMoga
Copy link
Author

Both throttles should last 24 hours. However, something to keep in mind when testing on dev: cache will be reset at each deploy! So depending on what was happening on dev when you were testing that may have had an impact.

I was testing on stage

@ioanarusiczki
Copy link

@diox @AlexandraMoga

I repeated my testing on AMO stage. I sent using Postman 20 consecutive requests for an addon using a Session id -> after 20 requests with https://addons.allizom.org/api/v5/abuse/report/addon/ I hit the throttle:
"detail": "Request was throttled. Expected available in 83747 seconds."

Then authenticated with the same user I tried to send a user abuse report from FF -> I cannot because I get the "Request was throttled, Expected available in 83657 seconds."
Then I tried to send addon abuse reports. In this case, I can still send them .

I'm wondering if I'm doing something wrong when I set up the abuse reports for -stage env. ? Yet, if I check the admin the addon reports were sent from the browser.

@diox
Copy link
Member

diox commented Aug 29, 2022

Then authenticated with the same user I tried to send a user abuse report from FF -> I cannot because I get the "Request was throttled, Expected available in 83657 seconds."

When sending an abuse report from FF, that shouldn't use the authentication AFAIK. So if you get throttled at this point, this must be because of the IP - meaning everything is working as expected.

Then I tried to send addon abuse reports. In this case, I can still send them .

What do you mean by that exactly ? After waiting ?

@ioanarusiczki
Copy link

@diox

What do you mean by that exactly ? After waiting ?

Maybe the gif would help, I'm into the same browser and I hit the 429 with Postman , then I tried from an AMO page.

sending reports

@diox
Copy link
Member

diox commented Aug 29, 2022

What's the value for extensions.abuseReport.url in your about:config ?

@ioanarusiczki
Copy link

@diox https://services.addons.allizom.org/api/v4/abuse/report/addon/
extensions.abuseReport.amoDetailsURL is https://services.addons.allizom.org/api/v4/addons/addon/
extensions.webapi.testing is true (I turned it false by mistake right before making the gif)

I also checked with Browser Toolbox , after I tried again, I see the api responding

201 createdapi

@diox
Copy link
Member

diox commented Aug 29, 2022

Ok. Would be interesting to test entirely with postman with services.addons.mozilla.org - trying various things until we can get simpler steps to reproduce that don't involve using the browser.

@ioanarusiczki
Copy link

@KevinMind KevinMind transferred this issue from mozilla/addons-server May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment