Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Security Freeze

Security covered Under active development 1 sites

This module provides a read-only mode for your Drupal site, allowing visitors to browse content while preventing all logins, database writes, and file changes. It can be activated via Drush commands or settings.php to secure your site during security incidents or patch deployments.

AI Development Declaration

This module was written by AI agents. The module maintainer reviews and takes full responsibility for all the work done by AI.

About the Module

A read-only "security maintenance mode" for Drupal. Its main purpose is to keep your Drupal site (partially) working while the database and file system are read-only — during a security incident, or while you assess and deploy a security patch. Visitors keep browsing the public-facing site while every write, login, and file change is refused.

What is it for?

When a critical vulnerability is disclosed or your site is under active threat, you need to lock things down fast — but taking your site totally offline should be the last option, not the only option.

The strongest lockdown is at the infrastructure layer: a read-only database server and a read-only file system. Drupal does not run well that way on its own; even an anonymous page view tries to write cache entries, state, locks, and logs, and a refused write becomes a 500 error. Security Freeze makes Drupal work in that state. Visitors can still browse pages, use search, and navigate menus, while nobody can log in (not even UID 1), no content can be written, and no files can be modified. Writes that the read-only database would refuse are dropped or turned into clean 403 (Access Denied) responses instead of 500 errors, so the site stays "online" from the perspective of uptime monitors and health checks.

Security Freeze is not a replacement for a read-only database and file system. Those infrastructure measures are what reliably stop writes, including from an exploit that bypasses Drupal entirely. The module's job is to keep the site usable while they are in place, and to add independent application-layer guards on top of them.

When the vulnerability is in PHP itself, no Drupal module can stop it: the bug fires before Drupal runs. For that case, the optional strict static mode builds a static HTML snapshot of the pages you choose, so your web server can serve the site without passing a single request to PHP.

There is no web UI — everything is operated over SSH using Drush commands (drush freeze:on / freeze:off / freeze:status / freeze:snapshot) or via settings.php. This is intentional: during a security incident, SSH may be the only safe access channel.

Features

  • Blocks all logins — cookie sessions, HTTP basic auth, bearer tokens, and all active sessions are terminated. UID 1 cannot log in.
  • Blocks all database writes — multiple independent layers (statement-level guard, service-level takeover, optional frozen database driver) refuse every INSERT, UPDATE, DELETE, and DDL statement through Drupal's database API.
  • Blocks file uploads and destructive file operations — uploads are stopped before the file reaches disk; move, rename, delete, and chmod on existing files are refused.
  • Blocks JSON:API and REST writes — unsafe HTTP methods against decoupled API endpoints return a clean 403.
  • Blocks cron — web-triggered, automated, and CLI drush cron are all stopped.
  • Keeps read-only pages live — page views, Views, search, facets, exposed filters, and menus continue working normally.
  • Enforces a strict Content-Security-Policy — a self-host-only CSP header is set on every response while frozen, with no dependency on any other module. The policy is customisable or can be skipped entirely.
  • Redirects logging to stderr — the database logger is suppressed; log entries go to stderr so your audit trail continues without database writes.
  • Handles multilingual sites — translation writes on render are silently dropped so translated pages still display correctly.
  • Handles state and key/value writes — Drupal's lazy state writes on read requests are dropped in-memory so pages don't crash on a read-only database.
  • Static homepage generation — optionally generates a static index.html for the homepage, so the web server can serve it directly and minimise server load during the incident.
  • Strict static mode (optional) — PHP receives no web traffic at all, while the site stays readable. The module builds a static HTML snapshot of the pages you list in settings.php, captured as an anonymous visitor with the freeze CSP embedded, so your priority pages are current at the moment of lockdown even if nobody has visited them. Paired with an nginx page mirror, which saves each anonymous public page as visitors browse, the web server serves the snapshot first, then the mirror, and gives every other URL a "temporarily unavailable" page with HTTP 503 that can use your site's theme. With no route to PHP, a vulnerability in PHP itself has nothing to reach. New snapshots can still add during a lockdown: add it with Drush over SSH and run drush freeze:snapshot:add to publish the new static pages, with no deployment and without lifting the freeze.
  • Defense-in-depth — every security control uses multiple independent layers, so bypassing one still meets the next.

What you must do at the infrastructure layer

These steps are the protection itself; the module keeps the site working on top of them. The read-only database and file system are the final guarantee, because an exploit that bypasses Drupal entirely still cannot write. You must:

  1. Move cache, lock, and flood off the database — use Redis, Memcached, or another external backend. If these services remain on the database, the first cache miss on a read-only database will crash the site. The freeze:on command runs a preflight check and warns you if any are still database-backed.
  2. Set the database server to read-only — after running drush freeze:on, set read_only = ON (and super_read_only = ON on MySQL/Aurora) on your database server. This is the un-bypassable backstop that stops even a direct PDO exploit.
  3. Make the file system read-only — the module guards file operations through Drupal's API and PHP stream wrappers, but only a read-only mount stops raw filesystem writes from an exploit. Mount the application codebase read-only at the container or volume level. Mount sites/default/files read-only too, after drush freeze:on has warmed the caches and built any static snapshot, and once derived assets (aggregated CSS/JS, image style derivatives, compiled Twig templates) exist, because Drupal can no longer generate them after that.
  4. (Strict static mode only) Switch your web server to the static folders — replace the normal Drupal server block with a lockdown configuration that serves the module’s snapshot first, then the nginx page mirror, and never passes a request to PHP. Prepare both configurations in advance so the switch is a reload (nginx -t nginx -s reload), not a deployment, and apply it in every nginx container. Keep a rule that blocks private files and both static folders above the asset rule, and confirm with nginx -T that no fastcgi_pass remains. The case study “Keeping a Drupal site online during a lockdown with an nginx page mirror and the static snapshot” includes a tested nginx configuration; any web server that can serve static files works. Switch back before running drush freeze:off.

Case Study

Worked examples of Security Freeze applied to real vulnerabilities:

More information

For full documentation — including the freeze/unfreeze procedure, configuration options, the cache trap, database driver setup, strict static mode, and how each security layer works — see the README included with the module.

Requirements: Drupal 11. No contrib dependencies.

Ask your assistant about Security Freeze

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Jun 2026
Latest release
4 weeks ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.0.0-beta1 Pre-release 11 Oct 23, 2026
1.0.x-dev Dev 11 Jun 23, 2026
1.0.0-alpha1 Pre-release 11 Jun 23, 2026