-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Restrict access of public CORS Anywhere demo #45
Comments
- Add checkRateLimit option to the API. - Extend the default server.js with environment variables CORSANYWHERE_WHITELIST (re-using originWhitelist) and CORSANYWHERE_RATELIMIT (using the new checkRateLimit option) to make it easy to enforce usage limits. - Document that Heroku doesn't want open proxies.
I have now imposed some rate limits. With some exceptions (e.g. localhost because it's used for development and blocking localhost altogether doesn't make sense), you can only make 600 requests per origin per hour. I came to this number by capturing Origin headers for a whole hour, 5 times (in the weekend and weekday, at different times on a given day) (resulting in 1741K requests from 2.9k unique origins, excluding previously blacklisted origins). The data shows that:
600 requests per hour is a royal limit. If you need more, host your own instance of CORS Anywhere (see https://github.com/Rob--W/cors-anywhere#demo-server for instructions). If this limit turns out to be too permissive, the limit may be tightened even more. Here are some statistics based on the data.
I captured another 1 hour of requests after setting the limit to 600 per hour, and got the following actual results (excluding blacklisted sites):
These actual findings are within the expectations from the original investigation, so I'll stick to these limits for now. And here are some more healthy statistics from the past hour (similar to the analysis from https://github.com/Rob--W/cors-anywhere/issues/42#issuecomment-198744800): Error codes:
Status codes (including requests that were immediately blacklisted and not visible in the above stats):
|
- Add ability to rate-limit/block requests by origin (#45). - Avoid crashing on invalid HTTP status codes (#95). - Support and test coverage for latest Node.js versions (up to 9). - Support `Access-Control-Max-Age` via `corsMaxAge` option. - Listen on `0.0.0.0:8080` by default instead of `127.0.0.1:8080`. (use `HOST` and `PORT` environment variables to override this). - Update gTLD list.
Are |
@tstibbs Excepted, at my discretion. |
While developing on localhost, I accidentally wrote an infinitely-looping script that sent out multiple requests through your heroku demo... I noticed immediately in the console log, so I closed the browser tab that the site was running in and changed the lines that was causing this to happen. Thought this took care of it, but a few minutes later my app stopped working altogether. May I know if reaching the rate limit results in a permanent ban or a temporary one that expires after a set amount of time? Honest mistake. |
@erikksuzuki The ban is automatic and automatically expires. I do occasionally add extra restrictions when I spot persistent abuse patterns, but in your case, you probably have access again by now. Note: When developing on localhost, I suggest that you don't use CORS Anywhere as a proxy, but self-host CORS Anywhere (see README) or use other methods (e.g. configuring CORS correctly or using browser extensions that automatically add CORS headers). That will result in faster response times, and also prevent you from being blocked by mistake. |
@Rob--W I made the same mistake as erikksuzuki did. How much time must go by before the ban expires? Thank you. |
The current rate limiting rules are documented in #164. Note that you can easily self-host CORS Anywhere to not have the restrictions. To learn how to set it up, see https://github.com/Rob--W/cors-anywhere#demo-server |
I totally understand your reasons for imposing the limits, but could this be conveyed in a bit friendlier manner? |
Not true. If you're getting hit by the rate limit, the error is 404 either means:
|
The CORS Anywhere demo is hosted at Heroku. I've been informed that the app is causing performance issues on the platform and that hosting an open proxy is against the Acceptable Use Policy:
I'll be monitoring the traffic in the coming period, and blacklist all origins/destinations that have excessive usage demands, and/or automatically block sites that have more than X requests per Y seconds, unless explicitly whitelisted.
These measures are needed to 1) resolve the performance issues on Heroku platform 2) prevent abuse of the open CORS Anywhere proxy 3) Ensure that the CORS Anywhere demo can continue to operate for (small) sites who want to try out CORS Anywhere before hosting it themselves.
The text was updated successfully, but these errors were encountered: