Drupal security hardening

A Drupal security hardening project closes the gap between a working site and a site you can defend. This page covers the decisions, build sequence, effort drivers, verification and handover for teams doing it in-house or with a partner.

On this page

Drupal security hardening starts with knowing what you run

Hardening is a set of configuration, access and patch-process controls applied to Drupal core and every contributed module on the site. For a Drupal site that is in production or about to go live, security is now a review gate, and the first question a reviewer asks is usually not about firewalls but about inventory: which core version, which contributed projects, which PHP and database versions, and who can change what. You cannot harden what you have not listed, so the first deliverable is a current inventory of code, configuration, server, database and accounts.

The work is harder than it looks because the attack surface spans five layers at once: custom and contributed code, site configuration, the web server and PHP runtime, the database, and the people who hold editor and administrator roles. Patch timing is also set by someone else. Drupal core and contributed projects are licensed under GPL-2.0-or-later, and there is no paid edition, so there is no vendor license to buy and no vendor patch pipeline to subscribe to. The Drupal Security Team publishes advisories with CVE identifiers and risk scores and ships fixes in its Wednesday security release windows, so your team or partner must watch those advisories and act on them. Confirm which release windows and advisory channels your team will monitor, and who owns the decision to patch.

Ask the team or partner to show, before any changes are made, a written list of installed versions, the modules with open advisories, the accounts with administrative rights and the server paths that are publicly reachable. That list becomes the baseline for every later control. Confirm with the vendor, your hosting provider and your own security team which of these values they need in writing, and agree how the inventory will be kept current after the project ends.

Which Drupal components carry the attack surface

A Drupal site's exposure comes from its code, its configuration, its files, its accounts, its login paths and the runtime around it. Each card below names the control an engineer will touch and the failure that control prevents, so the hardening review can be checked component by component.

Core and contributed code

Drupal core, contributed modules and themes all run with the same privileges as your site. Track which versions are installed, subscribe to Security Team advisories, and apply fixes in the monthly bugfix and third Wednesday security release windows. Check every contributed project for an active maintainer and a supported release before adding it, because abandoned code receives no fixes. Unpatched contributed modules are the most common route into a Drupal site.

Security Team

settings.php and trusted hosts

The settings.php file holds database credentials, hash salts and the trusted_host_patterns setting. Confirm the file is read-only for the web server user after installation, keep secrets out of version control, and set trusted host patterns to the exact domains the site serves. Without that check, host header manipulation can produce poisoned password reset links and cache issues. Ask the team which environment variables or secret stores supply the values.

Public and private file systems

Uploaded files live in the public file system by default, so anyone with a URL can fetch them unless access rules apply. Put sensitive documents in the private file system, keep it outside the web root, and confirm the web server does not execute uploaded PHP. Review which file extensions editors can upload, and test direct URL access to both locations with an unauthenticated browser session.

Roles and permissions

Drupal grants access through roles, and a role with broad permissions can change configuration, install modules or run PHP through text formats. Review each role against the work it actually does, remove permissions that editors do not need, and restrict the full HTML and PHP-capable text formats to a small group. Keep the number of administrator accounts low, and confirm that stale accounts from former staff are blocked.

Authentication and two-factor

Core username and password login is the default path, and any SAML or OpenID Connect integration adds a second route into the same accounts. Decide whether local login stays enabled for administrators, enforce two-factor authentication on privileged roles, and confirm that identity provider role mapping cannot grant administrator rights by accident. Test the login, logout and password reset flows after each change, and record which contributed authentication modules are installed.

SAML module page

PHP runtime and web server

Drupal depends on the PHP version and the web server in front of it. Confirm that the PHP version is one the current Drupal release supports, because older runtimes stop receiving security fixes. Configure the web server to deny access to sensitive paths such as the sites configuration files and the private file directory, and use TLS for all traffic. Ask your hosting team how PHP and operating system patches are applied and who is responsible for them.

PHP requirements

How requests, files and admin access cross trust boundaries

The diagram starts with an anonymous visitor, an authenticated editor and an administrator, all reaching the web server and PHP runtime before Drupal core and contributed code. Requests then pass through trusted host checks and role checks before touching the database, the private file system and settings.php. The identity provider sits outside the boundary, and the Security Team advisory feed feeds patch work back in. Check that each hand-off has a control you can test.

Request, file and admin paths through the Drupal trust boundaries.

Which hardening decisions to make first and what each costs you

This table compares five hardening decisions for a Drupal site, with the option, when it fits and the operational cost of each. Read each row as a choice between two paths, then check the cost column against the staff hours and skills you actually have. The main takeaway is that patch cadence and administrator sign-in matter more than any single module.

DecisionWhen it fitsWhat it costs you operationally
Patch on the monthly bugfix windowSites with regular content and feature changes and a team that can test each releaseRecurring testing time every month, plus more frequent deployments and rollback planning
Patch on the security window onlyStable sites with limited change and a team that can apply security releases quicklyLower routine effort, but bugfixes and contributed module updates can drift, making later upgrades harder
In-house patchingOrganizations with Drupal and PHP skills in-house and staff available on Wednesday release windowsOngoing salary or contractor time, plus on-call coverage for out-of-hours security releases
Support retainerTeams without enough Drupal depth or out-of-hours coverage, or those wanting a fixed response modelRecurring fee and dependence on the provider's scope, so confirm response expectations in writing
Local administrator accountsBreak-glass access when the identity provider or SSO failsExtra credentials to store, rotate and review, and a risk if they are shared or unmonitored
SSO for all administratorsOrganizations with central identity management and existing access reviewsSetup and role mapping work, plus dependence on the identity provider being available for admin access
Two-factor authentication through a contributed moduleSites where the identity provider cannot enforce multi-factor authentication for Drupal loginsModule maintenance and compatibility checks at each Drupal upgrade, plus user enrollment and recovery support
Two-factor enforced by the identity providerOrganizations that already require multi-factor authentication centrallyPolicy and integration work with the identity team, and a need to confirm that admin paths cannot bypass it
Read-only code deploymentsProduction sites under change control, where audit trails and repeatable releases matterBuild pipeline and configuration sync discipline, and slower emergency fixes that need a new release
Editing code on the production serverRarely justified for production; sometimes used for quick fixes on small sitesUntracked changes, drift between environments, and difficulty proving what was running at a given time

Drupal security hardening sequence from inventory to monitoring

This sequence takes a Drupal site from an unknown starting state to one where versions are supported, privileges are limited, configuration is locked down and new vulnerabilities reach the team on a predictable schedule. Each step ends with a check the team can repeat later.

  1. Inventory core, modules, themes and PHP

    Record the Drupal core version, every contributed module and theme with its version, the PHP version, the web server, and the database engine. Compare each item against the versions Drupal.org currently supports. Drupal 10 requires PHP 8.1 or later, Drupal 11 requires PHP 8.3 or later, and no supported Drupal version runs on PHP 7. Drupal 7 security support ended on January 5, 2025, so any Drupal 7 site is already outside standard coverage. Done when the team has a signed-off list with each item marked supported, scheduled for upgrade, or unsupported, and an owner for each unsupported item.

  2. Subscribe to advisories and map Wednesday windows

    Subscribe the platform and security owners to Drupal Security Team advisories, and to alerts for every contributed project in the inventory. Security releases ship on the third Wednesday of the month, and bugfix releases on the first Wednesday, according to the Drupal core release schedule. Write a runbook that assigns who reviews each advisory, who approves a patch into a staging environment, and who deploys to production in the same window. Done when a test advisory or a past advisory has been walked through the runbook and the team can name the person responsible for each action.

  3. Review roles and permissions

    Export the role and permission configuration and review it role by role. Remove administrative permissions from content roles, confirm that the anonymous and authenticated roles have only what public visitors need, and limit the number of accounts with the administrator role. Check which contributed modules add permissions and whether those permissions are granted by default. Done when every role has a documented purpose, a named owner, and a short list of privileged accounts that the client's security team has approved.

  4. Lock down settings.php and file permissions

    Confirm that the settings file is not writable by the web server after installation, that the private file path sits outside the web root, and that uploaded files cannot run as scripts. Confirm that configuration sync storage is not publicly reachable and that the web server denies access to sensitive paths such as the Composer and Git metadata. Check that database credentials and salt values come from the environment or a secrets store rather than from files committed to source control. Done when a file permission audit from the server shows the expected owners and modes, and a request to a protected path returns a denial instead of the file.

  5. Set and test the trusted host patterns

    Define the exact hostnames the site should answer to, including production, staging and any load balancer health check names, and enter them as trusted host patterns in the settings file. Anchor each pattern so that unlisted hosts are rejected. Test with requests that use an unlisted Host header, including the bare IP address of the server. Done when unlisted hosts return a rejection, every intended hostname loads, and the test is saved so it can be repeated after each deployment.

  6. Enforce two-factor or SSO for privileged accounts

    Require a second factor or federated sign-in for every account that can administer the site or publish sensitive content. Evaluate two-factor authentication modules that fit the client's policy, and where the organization already runs an identity provider, route privileged sign-in through SAML or OpenID Connect. Decide how local break-glass administrator accounts are stored, monitored and tested. Confirm the module versions are supported for the installed Drupal core. Done when a test administrator cannot sign in with a password alone, and the break-glass account has been used once under controlled conditions and the event is logged.

  7. Wire dependency monitoring into the pipeline

    Add a dependency audit to the Composer-based build so that every merge request and scheduled run reports known vulnerable packages. Pair it with a scheduled inventory export that compares the deployed versions to the advisories received. Make the pipeline fail or raise a ticket when a supported-version check fails, such as a PHP version that falls out of support or a core release that is no longer maintained. Done when a deliberately outdated test package causes the pipeline to report it, and a report from the production environment lists the same versions as the inventory recorded in the first step.

How the hardening work changes by hosting environment

On traditional virtual machines running Apache or Nginx, the team typically owns most of the stack, so most hardening work sits with them. The platform team usually controls the operating system patch cadence, firewall rules, PHP-FPM pools and the web server configuration, while the application team controls the Drupal codebase, contributed modules and site configuration.

  • Web server config: Virtual host rules must block direct access to sensitive paths such as sites/default/files/private and any settings.php backups, and deny access to .git and vendor directories.
  • PHP runtime: PHP-FPM users, open_basedir style restrictions and the PHP version must match a version supported by the Drupal release in use.
  • Patching: Operating system and PHP security updates need a schedule that lines up with the Wednesday security release windows on the Drupal release schedule.
  • File permissions: The web user should own only what it needs to write, with the codebase read-only in production where the deployment model allows it.
  • Network controls: Database and cache ports stay on private interfaces, and admin access runs through a bastion or VPN.

Confirm with your own operations team who holds root access, who approves kernel and PHP upgrades, and where backups of settings.php and the private file directory are stored.

Access control and secrets handling for hardened Drupal

Access control and secrets handling are where most Drupal hardening work either holds or fails. The cards below cover who can change the site, where credentials live, how files and update routes are exposed, and how changes are recorded, so each control can be confirmed on the running site rather than assumed from the build.

Least-privilege roles and an admin register

Drupal ships with an administrator role that bypasses permission checks, so the number of accounts holding it should be small and named. Keep a written register of who holds administrator and any role with permission to install modules, change text formats or edit PHP-capable input. To confirm it, export the role-to-user mapping and compare it with the register. Treat any account on that list that is not tied to a current staff member as a finding.

Drupal Security Team

Database credentials and hash salt in settings.php

The settings.php file holds the database credentials and the hash_salt value that Drupal uses for one-time login links and form tokens. Anyone who reads them can connect to the database or forge sensitive links. Confirm that the file is read-only for the web server user after installation and that the salt was generated per site and is not copied from a template or another environment.

Private file system outside the web root

Uploaded documents that should not be public belong in a private file system path that the web server cannot serve directly. Confirm the configured path in settings.php sits outside the document root, then request a known private file URL from an unauthenticated browser and expect it to be denied. Public and private paths should be tested separately, since a misplaced directory is a common cause of exposed uploads.

Restricted update and admin routes

Routes such as /update.php, /user/login and the administration area should be limited by network path, IP allowlisting, or a reverse proxy rule where your environment allows it. Pair this with trusted host patterns so requests with unexpected host headers are rejected. Confirm by testing these routes from an outside network segment and checking that the expected responses are returned.

Secrets held in the environment, not in code

API keys for SSO providers, mail services and remote storage should be injected at runtime through environment variables or a secrets manager, not committed to Composer configuration, exported configuration or custom modules. Exported configuration is stored in version control, so a secret placed there persists in history. Confirm by searching the repository and the configuration sync directory for credential patterns and by checking that rotation does not require a code change.

Audit logging of role and permission changes

Changes to roles, permissions and user accounts should leave a record that shows who made the change and when. Drupal's core Database Logging module records some account events, but confirm what it captures in your version and whether logs are shipped off the server. Test the control by creating a temporary role, granting one permission, and checking that the change appears in the log and in the exported configuration diff.

How to test the hardening and confirm it fails safely

Testing the hardening means proving that each control rejects the request it is meant to reject, on the running site rather than in a configuration file. Start with the trusted host patterns set in settings.php: send requests with unexpected Host headers to the production hostname, to an IP address and to a made-up domain pointing at the server, and confirm Drupal refuses each one instead of rendering the site. Then test access control with real accounts. Log in as an anonymous user and as a content editor and attempt to reach the permissions page, the user administration pages, and the module and update screens. Each should return access denied. Do the same check for any custom role that holds only content tasks, because role drift is common after a few months of editorial changes.

Next, confirm that sensitive files are not served over HTTP. Request settings.php, the sites/default/files/private directory and any backup or database dump your team keeps in the webroot, and confirm the web server returns a refusal or a not-found response. Repeat the check through any CDN or load balancer in front of the site, since a cache can serve content that the origin would block. For privileged roles, confirm that two-factor authentication or the SSO provider is enforced at sign-in: a password-only attempt for an administrator account should fail, and the enforcement settings in the chosen module should be reviewed with the identity team, not assumed from a default. Finish with a scan or an authenticated review of the running site. Ask the testing team to state in writing whether the scan ran authenticated, which roles it covered, and which findings were confirmed by hand.

Testing failure behavior matters as much as testing success. Trigger a few controlled errors on a staging copy, such as a request to a missing route and a malformed query string, and confirm the response shows a generic error page with no stack trace, file paths or database details. Check that the error logs capture the detail for your team while the public response stays minimal. For updates, rehearse a security release on staging: apply it through the normal Composer workflow, run database updates, then make a deliberate failure, such as a broken dependency, and confirm you can restore the code and database from the backup taken before the change. Record the restore time and confirm the site returns to its last known state. Ask your partner or internal team to show this rehearsal in the handover, because a backup that has never been restored is an untested assumption.

What drives hardening effort and how to keep each driver down

This table compares the factors that expand or shrink a Drupal hardening engagement and the steps that keep each one manageable. Read each row as a lever you control before work starts, since most of the effort comes from decisions made during scoping. The main takeaway is that a smaller module footprint, fewer privileged accounts and a current core and PHP version usually reduce both the initial effort and the recurring cost.

DriverWhy it raises effortHow to keep it down
Contributed modules and custom codeEach contributed project and custom module needs its own advisory tracking, update testing and review of permissions and input handling.Keep only modules the site needs, prefer maintained contributed projects, and document which custom code must be reviewed on each release.
Roles and users with elevated accessAdministrators, editors with publishing rights and service accounts each widen the set of permissions to review and the impact of a compromised account.Remove unused roles, assign permissions by task, limit administrator accounts and review user lists on a fixed schedule.
Number of environments and hosting modelsDevelopment, staging and production each need the same patches, settings and file protections, and cloud, data center or air-gapped hosting changes how controls are built and evidenced.Standardize one deployment pipeline with configuration sync, keep environment-specific settings in version control and confirm the hosting model before scoping.
Identity provider integrationsSAML or OpenID Connect sign-in, role mapping and local fallback accounts each add configuration to test and a separate way in that must be secured.Define role mapping rules up front, restrict or disable local password login where policy allows, and confirm the identity provider's settings with its owner.
PHP version and Drupal core major version in useSites on end-of-life Drupal or unsupported PHP need upgrades before hardening is meaningful, and Drupal 7 sites require a migration rather than an in-place update.Confirm the current PHP and core versions against the core release schedule and PHP requirements, then plan the upgrade as part of the same project.
Compliance evidence requirementsAssessors often ask for proof of patch timing, access reviews, backup restores and change records, which means logs and reports must be produced and kept.Ask the compliance team which evidence they need, agree the format early and set up logging, access review records and change tracking as part of the build.

What to monitor, back up, patch and document after go-live

The running model starts with subscribing to Security Team advisories and putting the release calendar into your operations rhythm. According to the Drupal core release schedule, bugfix releases ship on the first Wednesday of each month and security releases on the third Wednesday. Treat the third Wednesday as a standing change window: someone owns reading each advisory, deciding whether the affected core or contributed project is in use, and scheduling the update within the window your risk policy allows. Advisories from the Drupal Security Team carry CVE identifiers and risk scores, so record the decision for each one, including the decisions to defer. Contributed projects need the same attention. Review the modules you run at least monthly for advisories, for projects marked unsupported, and for maintainers who have stopped responding. An orphaned module with an open advisory is a patch you may have to write, fork or replace yourself, so confirm early whether an alternative exists before you need it.

Keep a dated change record that an auditor or a new engineer can read without asking you. It should show every role and permission change, who approved it and why, each patch decision with its date, and the rollback plan that went with it. Back up code, configuration and the database together and in the same job. A database restored without the matching config/sync export and Composer lock file can leave the site in a state nobody tested. Confirm with your hosting provider and your own tooling that backups include the private file directory and the settings that live outside version control, and run a restore to a separate environment on a schedule you set. Restore tests are the only evidence that a backup works.

Document the hardening baseline as a single reference: the permission matrix for each role, the file system ownership and write permissions, the settings in settings.php and the trusted host patterns, the two-factor authentication configuration, the logging settings and the list of enabled modules with their versions. Store it with the change record so the live site can be compared against it at any point. Each periodic review should produce a short diff between the live configuration and the baseline, with every deviation either corrected or approved. This is also where you record the Drupal version support status and the planned upgrade date, because the baseline is out of date the moment core moves to a version no longer receiving security coverage.

Questions buyers ask before hiring help with Drupal security hardening

What does Drupal security hardening cost and what drives the price?

Cost depends on the size and state of the site, how many contributed modules and custom modules it runs, how many roles and integrations need review, and how much of the hosting environment is in scope. Drupal core and contributed modules are GPL-2.0-or-later with no license fee, so the spend is labor: someone reviews permissions, settings, file system protection, patching and monitoring, then documents the result. Ask for a quote built from a written scope that lists each system, the environments covered and the deliverables. One-time work (the baseline review and fixes) is separate from recurring work (monthly patching, dependency monitoring and retesting), so ask the vendor to price both.

How long does a Drupal hardening engagement take?

Duration follows scope: the number of sites, the amount of custom code, how many roles and integrations need review, and how quickly your team can approve changes and test them. A single standalone site with a short list of contributed modules is a much smaller job than a multisite estate with single sign-on and external hosting. Ask for a phased plan that separates the baseline review, remediation, verification and handover, and confirm which steps depend on your change windows. Drupal security releases arrive on the third Wednesday of the month, and bugfix releases on the first Wednesday, so your patch process needs a fixed slot in the plan.

What does our internal team need to provide?

Expect to provide access and decisions, not just time. The usual inputs are:

  • Read access to the codebase, Composer files and the hosting environment, including web server and database configuration
  • A list of user roles and who holds administrator rights
  • Staging or test copies of the site where changes can be tested before production
  • Named owners who can approve changes, schedule maintenance windows and accept risk
  • Details of the identity provider if single sign-on is involved

Without these, the review slows down and fixes may not match how the site is actually used.

Can our team harden Drupal without an outside partner?

Yes, if you have engineers who know Drupal, Composer, the web server and the database. The core tasks are well documented: review roles and permissions, protect the file system and settings.php, configure trusted host patterns, add two-factor authentication through a contributed module, subscribe to the Drupal Security Team advisories and track contributed project updates. The risk usually lies in consistency and follow-through: the team must act on advisories within the release windows, keep staging current and retest after each change. A partner adds the most value when your team lacks that capacity, when a separate review of the configuration is needed, or when evidence must be produced for an assessment.

What should we do if our Drupal 7 site is still in production?

Drupal 7 security support ended on January 5, 2025, so the site no longer receives core security fixes from the community. Hardening cannot close that gap. The short-term option is extended security support from a certified provider in the Drupal Association's Extended Security Support Provider Program, which currently lists HeroDevs and Tag1 Consulting. Treat that as a stopgap while you plan a migration to a supported version, since Drupal 6 and 7 sites cannot simply be updated and must be moved into a new site. Review the extended support partners list to compare current options and confirm terms directly with each provider.

Does DeployOpen issue a security certification after hardening?

No. DeployOpen does not issue audit reports, attestations or certifications. It can harden the Drupal configuration, document the controls, collect the evidence and prepare the system for a compliance assessment. Independent auditors and certification bodies perform the assessment and issue any report or certificate. Ask your auditor which evidence they expect, such as role reviews, change records, patch logs and monitoring outputs, and make sure those records are produced during the engagement.

How do we keep a hardened Drupal site secure after the engagement ends?

Hardening decays unless it is run as a process. Keep a named owner for the site, apply bugfix and security releases on the monthly schedule, and subscribe to the Drupal Security Team advisories, which publish CVE identifiers and risk scores. Review roles each time staff change and re-check trusted host patterns and file permissions after each deployment. Track contributed modules for maintenance status, because an unmaintained module can leave a gap even when core is current. Many organizations pair the handover with a support retainer that covers patching, dependency monitoring and periodic retesting.

How DeployOpen scopes, hardens, hands over and supports Drupal

DeployOpen works on Drupal security hardening as a written, fixed-scope engagement inside your own infrastructure. We agree the scope, test and harden the site, document each change and hand over the configuration, runbooks and evidence your security and compliance teams need to review it.

How we scope

  • Inventory Drupal core version, PHP version, contributed modules and themes, and whether any Drupal 7 code remains in use.
  • Review roles and permissions, administrative accounts, text formats and file upload paths against your access policy.
  • Agree in writing which environments, hosting layers and advisories are covered, and which items your own team keeps.

How we build

  • Apply hardening to settings.php, file system permissions, trusted host patterns and web server rules, then verify each change in staging.
  • Set up two-factor authentication and identity integration where agreed, and test login, recovery and admin lockout paths.
  • Establish dependency monitoring and a patch routine that follows the Security Team advisories and the first and third Wednesday release windows.

How we hand over

  • Deliver a hardening record listing each setting changed, its reason, and the test that confirmed it.
  • Provide runbooks for applying security releases, rotating credentials and responding to a flagged advisory.
  • Walk your operations and security staff through the monitoring setup and confirm who receives each alert.

How we support

  • Offer ongoing support, upgrades and continuous security testing as a retainer, scoped in writing separately from the initial engagement.
  • Retest affected settings after each core or contributed module update to confirm the hardening still holds.
  • Ask any provider to confirm in the quote which advisories, release windows and environments a retainer includes.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.