Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protect an unauthenticated Cloud Run endpoint

when I make an unauthenticated (public) Cloud Run endpoint to host an API, what are my options to protect this endpoint from malicious users making billions of HTTP requests?

For $10 you can launch a Layer 7 HTTP flood attack that can send 250k requests per second. Let's assume your Cloud Run endpoints scale up and all requests are handled. For invocations alone, you will pay $360,-/hour (at $0.40 per million requests).

Note that there is a concurrency limit and a max instance limit that you might hit if the attack is not distributed over multiple Cloud Run endpoints. What other controls do I have?

As I understand, the usual defenses with Cloud Armor and Cloud CDN are bound to the Global Load Balancer, which is unavailable for Cloud Run, but is available for Cloud Run on GKE.

like image 862
Wietse Venema Avatar asked Apr 16 '19 21:04

Wietse Venema


People also ask

How do I protect my cloud from running?

Create a dedicated service account with minimal permissions for service-to-service authentication and service access to the rest of Google Cloud. Write, build, and deploy two services to Cloud Run which interact. Make requests between a public and private Cloud Run service.

How do I authenticate service-to-service?

To set up service-to-service authentication, you'll have to do two things: Register an application in your Azure Active Directory tenant for authenticating API calls against Business Central. Grant access for that application in Business Central.


1 Answers

For unauthenticated invocations to a Cloud Run service with an IAM Cloud Run Invoker role set to the allUsers member type, I would expect the answer to be the same as those provided here - https://stackoverflow.com/a/49953862/7911479

specifically:

Cloud Functions sits behind the Google Front End which mitigates and absorbs many Layer 4 and below attacks, such as SYN floods, IP fragment floods, port exhaustion, etc.

It would certainly be great to get a clear Y/N answer on Cloud Armor support.

[Edit]: I have been thinking on this quite a lot and have come to the following conclusion:

if you expect you are likely to become a victim of an attack of this type then I would monitor your regular load/peak and set your account's ability to scale just above that load. Monitoring will allow you to increase this as your regular traffic grows over time. It appears to be the only good way. Yes, your service will be down once you reach your account limits, but that seems preferable in the scenario where you are the target.

An idea which I am yet to try is a protected route with Firebase Authentication and anonymous authentication.

like image 72
jthegedus Avatar answered Oct 21 '22 03:10

jthegedus