Description
Google Cloud Functions allow you to host serverless code that is executed when an event is triggered, without the requiring the management a host operating system. These functions can also store environment variables to be used by the code that may contain authentication or other information that needs to remain confidential.
Rationaleβ
It is recommended to use the Secret Manager, because environment variables are stored unencrypted, and accessible for all users who have access to the code.
Impactβ
There should be no impact on the Cloud Function. There are minor costs after 10,000 requests a month to the Secret Manager API as well for a high use of other functions. Modifying the Cloud Function to use the Secret Manager may prevent it running to completion.
Auditβ
Determine if Confidential Information is Stored in your Functions in Cleartextβ
From Google Cloud Consoleβ
- Within the project you wish to audit, select the Navigation hamburger menu in the top left. Scroll down to under the heading
Serverless
, then selectCloud Functions
- Click on a function name from the list
- Open the
Variables
tab and you will see bothbuildEnvironmentVariables
andenvironmentVariables
- Review the variables whether they are secrets
- Repeat step 3-5 until all functions are reviewed
From Google Cloud CLIβ
-
To view a list of your cloud functions run
gcloud functions list
-
For each cloud function in the list run the following command.
gcloud functions describe <function_name>
-
Review the settings of the buildEnvironmentVariables and environmentVariables. Determine if this is data that should not be publicly accessible.
Determine if Secret Manager API is 'Enabled' for your Projectβ
From Google Cloud Consoleβ
- Within the project you wish to audit, select the Navigation hamburger menu in the top left. Hover over
APIs & Services
to under the headingServerless
, then selectEnabled APIs & Services
in the menu that opens up. - Click the button
+ Enable APIS and Services
- In the
Search
bar, search forSecret Manager API
and select it. - If it is enabled, the blue box that normally says
Enable
will instead sayManage
.
From Google Cloud CLIβ
-
Within the project you wish to audit, run the following command.
gcloud services list
-
If
Secret Manager API
is in the list, it is enabled.
Default Valueβ
By default Secret Manager is not enabled.
Referencesβ
- https://cloud.google.com/functions/docs/configuring/env-var#managing_secrets
- https://cloud.google.com/secret-manager/docs/overview
Additional Informationβ
There are slight additional costs to using the Secret Manager API. Review the documentation to determine your organizations' needs.