Overview of App Security

Security is a core feature of the Google Cloud Platform, but there are still steps you should take to protect your App Engine app and identify vulnerabilities.

Use the following features to ensure that your App Engine app is secure. To learn more about the Google Security Model and the available steps that you can take to secure your GCP projects, see Google Cloud Platform Security.

HTTPS requests

Use HTTPS requests to access to your App Engine app securely. Depending on how your app is configured, you have the following options:

appspot.com domains
  • Simply use the https URL prefix to send HTTPS request to the default service of your GCP project, for example:
  • To target specific resources in your App Engine app, you use the -dot- syntax to separate each resource you want to target, for example:


  • Tip: You convert an HTTP URL to HTTPS by simply replacing the periods between each resource with -dot-, for example:


For more information about HTTPS URLs and targeting resources, see How Requests are Routed.

Custom domains

To send HTTPS requests with your custom domain, you can use the managed SSL certificates that are provisioned by App Engine. For more information, see Securing Custom Domains with SSL.

Access control

In each GCP project, set up access control to determine who can access the services within the project, including App Engine. You can assign different roles to different accounts to ensure each account has only the permissions it needs to support your app. For details see, Setting Up Access Control.

App Engine firewall

The App Engine firewall enables you to control access to your App Engine app through a set of rules that can either allow or deny requests from the specified ranges of IP addresses. You are not billed for traffic or bandwidth that is blocked by the firewall. Create a firewall to:

Allow only traffic from within a specific network
Ensure that only a certain range of IP addresses from specific networks can access your app. For example, create rules to allow only the range of IP addresses from within your company's private network during your app's testing phase. You can then create and modify your firewall rules to control the scope of access throughout your release process, allowing only certain organizations, either within your company or externally, to access your app as it makes its way to public availability.
Allow only traffic from a specific service
Ensure that all the traffic to your App Engine app is first proxied through a specific service. For example, if you use a third-party Web Application Firewall (WAF) to proxy requests directed at your app, you can create firewall rules to deny all requests except those that are forwarded from your WAF.
Block abusive IP addresses
While Google Cloud Platform has many mechanisms in place to prevent attacks, you can use the App Engine firewall to block traffic to your app from IP addresses that present malicious intent or shield your app from denial of service attacks and similar forms of abuse. You can blacklist IP addresses or subnetworks, so that requests routed from those addresses and subnetworks are denied before it reaches your App Engine app.

For details about creating rules and configuring your firewall, see Controlling App Access with Firewalls.

Security scanner

The Google Cloud Security Scanner discovers vulnerabilities by crawling your App Engine app, following all that links within the scope of your starting URLs, and attempting to exercise as many user inputs and event handlers as possible.

In order to use the security scanner, you must be an owner of the GCP project. For more information on assigning roles, see Granting Project Access.

You can run security scans from the Google Cloud Platform Console to identify security vulnerabilities in your App Engine app. For details about running the Security Scanner, see the Security Scanner Quickstart.

ASP.Net Core data protection provider

The ASP.NET Core data protection stack uses encryption to protect web application data such as cookies and anti-CSRF tokens.

The default IDataProtectionProvider stores encryption keys locally on the machine running the webserver, which is not compatible with App Engine and causes error messages to be displayed.

You can use Google.Cloud.AspNetCore.DataProtection.Storage and Google.Cloud.AspNetCore.DataProtection.Kms that solve this problem. You can use these libraries by doing the following:

  1. Create a Cloud Storage bucket.

  2. Create a Cloud Key Management Service keyring and key:

    gcloud kms keyrings create dataprotectionprovider --location global
    gcloud kms keys create key --location global --keyring `
        dataprotectionprovider --purpose=encryption
  3. Set your service account permission to use the keyring:

    gcloud kms keyrings add-iam-policy-binding dataprotectionprovider `
        --location 'global' `
        --member serviceAccount:my-project-id@appspot.gserviceaccount.com  `
        --role roles/cloudkms.cryptoKeyEncrypterDecrypter
  4. Add the libraries to your application's .csproj:

    dotnet add package Google.Cloud.AspNetCore.DataProtection.Kms
    dotnet add package Google.Cloud.AspNetCore.DataProtection.Storage
  5. Add the names of the bucket and object (filename) where keys will be stored and the name of your KMS key to your application's appsettings.json file:

      "Logging": {
        "LogLevel": {
          "Default": "Warning"
      "AllowedHosts": "*",
      "DataProtection": {
        "Bucket": "YOUR-BUCKET",
        "Object": "DataProtectionProviderKeys.xml",
        "KmsKeyName": "projects/YOUR-PROJECT-ID/locations/global/keyRings/dataprotectionprovider/cryptoKeys/key"
  6. You can configure ASP.NET Core's data protection stack to use Google libraries by adding the following to your Startup.cs file:

    using Google.Cloud.AspNetCore.DataProtection.Kms;
    using Google.Cloud.AspNetCore.DataProtection.Storage;
        public class Startup
            public void ConfigureServices(IServiceCollection services)
                // Antiforgery tokens require data protection.
                    // Store keys in Cloud Storage so that multiple instances
                    // of the web application see the same keys.
                    // Protect the keys with Google KMS for encryption and fine-
                    // grained access control.

You can download a runnable example with a set up script from the Google Cloud Platform GitHub repository.

Was this page helpful? Let us know how we did:

Send feedback about...

App Engine flexible environment for .NET docs