Automating OS patches on Cloud Run

I've always liked Cloud Run because it lets me mostly ignore managing container infrastructure. All I have to do is provide a container image, and Cloud Run makes sure it starts when needed. If I'm deploying a web service, it provides me with an HTTPS endpoint and load balancing, without requiring me to configure anything complicated or read documentation.

However, there's one chore I'm still responsible for: keeping the system packages and the language runtime in the container image up to date. For example, when someone discovers a vulnerability in Node.js or Python, I have to trigger a build, run my tests, and redeploy the service. What's worse, to even know there's a problem, I need to set up automated security scans, turning routine patching into a constant cycle.

Cloud Run's automatic base image updates take that maintenance off your plate. Normally, a container image bundles your application layers on top of a base image containing the operating system packages and language runtime, so patching a base image vulnerability means rebuilding and redeploying the entire image.

With runtime rebasing, Cloud Run keeps your application layers separate from the Google-managed base image and replaces that base image underneath your running service with zero downtime. Because Cloud Run rolls out the patched base image directly to container instances without waiting on your build pipeline, your services get security fixes much faster.

The diagram below compares a traditional deployment with runtime rebasing during an initial deploy and a subsequent security patch:

A comparison diagram showing Cloud Run deployments without and with base image updates. The top half shows a traditional deployment where application layers and the base image are bundled together, requiring manual developer rebuilds and redeploys that delay security patches. The bottom half shows runtime rebasing, where the container image omits the base image and Cloud Run replaces the vulnerable base image underneath the application layers automatically with zero downtime and without creating a new revision.

Read on to see how base image updates shrink your exposure window during a runtime vulnerability, how to deploy a Node.js service from source with base image updates enabled, why you can't revert a base image update, and which dependencies you still patch yourself.

Reducing the vulnerability gap

Whenever a vulnerability surfaces in an operating system package or language runtime, your services remain exposed between the moment a patch is published and the moment you rebuild and redeploy every container image. Take the January 2026 high-severity Node.js vulnerability (CVE-2025-59466), an uncatchable stack overflow when async_hooks is active that let attackers crash a server with a single deeply nested request. Because frameworks such as Next.js, NestJS, and Fastify rely on async_hooks for request context tracking, a wide range of production Node.js services were exposed, and updating npm packages alone couldn't fix a bug inside the Node.js runtime itself.

Enabling base image updates hands the responsibility of patching operating system and language runtime vulnerabilities over to Cloud Run. When Google publishes an emergency security patch or routine maintenance update, Cloud Run updates the base image and rolls it out across your running container instances automatically. Your services pick up the patched runtime as soon as Google releases the updated base image, shrinking that exposure window without waiting on manual builds or CI pipelines.

Configuring base image updates

The recommended way to use base image updates is to deploy directly from source without a Dockerfile, letting Google Cloud's buildpacks assemble a rebaseable container image for you. To test this end to end, set up a small Express service, deploy it from source with base image updates enabled, and inspect the active base image version in Cloud Logging.

Step 1: Set up an Express service

Create a new directory for the service and switch into it:

mkdir example-app && cd example-app

Inside this directory, define your project dependencies in package.json:

package.json
{
  "name": "example-app",
  "main": "index.js",
  "dependencies": {
    "express": "^5.2.1"
  }
}

With package.json in place, add index.js to serve a basic HTTP response:

index.js
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello, automatic updates!');
});

const port = process.env.PORT || 8080;
app.listen(port, () => console.log(`Listening on port ${port}`));

Leave out the Dockerfile from this directory. When you deploy a directory without a Dockerfile from source, Cloud Run uses Google Cloud's buildpacks to detect your Node.js dependencies and build a rebaseable image automatically. If a standard Dockerfile is present, Cloud Build builds from that file instead, bundling the OS and runtime layers into your image so Cloud Run can't rebase it.

Step 2: Enable the required APIs

Before deploying, make sure you install the gcloud CLI and create a Google Cloud project with billing enabled. Then set your project ID in your shell:

export PROJECT_ID="YOUR_PROJECT_ID"

A source deployment requires the Cloud Run Admin API, the Cloud Build API, and the Artifact Registry API to build and store your container image. Enable all three services before deploying:

gcloud services enable \
  run.googleapis.com \
  cloudbuild.googleapis.com \
  artifactregistry.googleapis.com \
  --project "$PROJECT_ID"
Operation "operations/acf.p2-123456789012-396be3b7-4aee-40ad-8fc6-ef05544f67bf" finished successfully.

Step 3: Deploy from source

With the APIs enabled, deploy the service example-app from source using the gcloud CLI. If this is your first source deployment in europe-west1, press Y when prompted to create the cloud-run-source-deploy Artifact Registry repository:

gcloud run deploy example-app \
  --source . \
  --base-image nodejs24 \
  --automatic-updates \
  --region europe-west1 \
  --allow-unauthenticated \
  --project "$PROJECT_ID"
Building using Buildpacks and deploying container to Cloud Run service [example-app] in project
[YOUR_PROJECT_ID] region [europe-west1]
✓ Building and deploying new service... Done.
  ✓ Validating configuration...
  ✓ Creating Container Repository...
  ✓ Uploading sources...
  ✓ Building Container...
  ✓ Setting IAM Policy...
  ✓ Creating Revision...
  ✓ Routing traffic...
Done.
Service [example-app] revision [example-app-00001-pc9] has been deployed and is serving 100 percent of traffic.
Service URL: https://example-app-123456789012.europe-west1.run.app

The following flags control how Cloud Run packages and serves your code:

  • --source . uploads the current directory to Cloud Build and packages it into a container image.
  • --base-image nodejs24 selects the Node.js 24 base image.
  • --automatic-updates enables base image updates for this source deployment.
  • --region europe-west1 deploys the service to the Belgium region.
  • --allow-unauthenticated makes the service publicly accessible without requiring IAM authentication.

Once the deployment finishes, retrieve the service URL and send a request with curl to confirm the service is running:

SERVICE_URL=$(gcloud run services describe example-app \
  --region europe-west1 \
  --project "$PROJECT_ID" \
  --format="value(status.url)")

curl "$SERVICE_URL"
Hello, automatic updates!

Beyond nodejs24, Google provides base images for Python, Go, Java, Ruby, PHP, and .NET, plus an OS-only Ubuntu image (osonly24) for standalone compiled binaries. Each identifier pins the major runtime or Ubuntu release while letting Cloud Run apply security and maintenance patches underneath your service. For all supported versions and stacks, review the official list of base images.

Unlike standard Cloud Run services such as example-app, where you opt in explicitly with --base-image and --automatic-updates, Cloud Run functions enable base image updates by default. Functions run on Google's Functions Framework, which structures your handler code cleanly on top of the base image without extra configuration. Whether you deploy with gcloud functions deploy or gcloud run deploy --function --base-image, Cloud Run turns base image updates on unless you pass --no-automatic-updates.

Step 4: Verify the base image version

Cloud Run attaches the exact base image version to every stdout and stderr log entry emitted by a container instance under the run.googleapis.com/base_image_versions label. Query your service's stdout logs with the gcloud CLI and extract that label using --format:

gcloud logging read 'resource.type="cloud_run_revision" '\
'AND resource.labels.service_name="example-app" '\
'AND logName="projects/'$PROJECT_ID'/logs/run.googleapis.com%2Fstdout"' \
  --project "$PROJECT_ID" \
  --limit 1 \
  --format="value(labels.['run.googleapis.com/base_image_versions'])"
us-docker.pkg.dev/serverless-runtimes/google-24/runtimes/nodejs24:nodejs24_20261022_24_22_1_RC01

The tag encodes both the image build date (20261022) and the exact Node.js version (24.22.1) inside the google-24 Ubuntu stack. Whenever Cloud Run rolls out an operating system or language runtime patch, newly started container instances log the updated tag in this field. You can filter Cloud Logging on this label during a security audit to confirm that your running instances have picked up a patched release.

Why you can't revert base image updates

A base image rollout does not create a new Cloud Run revision: Cloud Run replaces the underlying base image in place and leaves your active revision unchanged. Normally, each deployment creates an immutable revision of your container image and configuration so you can route traffic back to a known-good state. Because an in-place update leaves no previous revision to fall back to, you can't revert a base image update. If your workload requires rollback controls for every operating system and runtime change, build a standard Dockerfile-based container image and roll out updates through your own deployment pipeline.

What base image updates don't patch

Base image updates only patch the operating system packages and language runtime inside the base image. Packages installed in your application layers, such as express in package.json, remain untouched when Cloud Run replaces the base image. Compiled Go applications also bake the Go runtime and standard library directly into the binary at build time, so base image updates only patch the OS packages underneath. You still need to track advisories for your application dependencies and rebuild and redeploy your service to pick up library or compiler fixes.

To dig into how runtime rebasing works at container startup or how to build rebaseable images yourself without buildpacks, read How runtime rebasing works on Cloud Run and Building rebaseable container images with Docker from scratch.