Drupal Security Best Practices: How to Harden, Audit, and Test Your Site
Modern digital experiences require a content management system (CMS) that can lift brands above competitors, which is why global brands such as Mars, Stanley Black & Decker, and NASA trust the open source Drupal platform to fuel their brand-differentiating experiences.
But there is one arena organizations do not want to be known for: cyberattacks.
The threat picture has worsened steadily. As MIT professor Stuart Madnick reported, data breaches hit an all-time high in 2023, and supply chain exploits grew more targeted and pervasive; ransomware attacks in the first nine months of that year alone outnumbered all of 2022. Nothing since has reversed that trend.
Drupal itself holds up well, having long been among the most secure content management systems available and recording roughly 33% fewer vulnerabilities than WordPress in 2023. But a secure platform is not the same as a secure site.
Drupal Security Is a Shared Responsibility
This is the point enterprise teams most often miss. Security splits across three layers, and no vendor covers all of them.
- Drupal core and the Drupal Security Team handle vulnerabilities in core and in supported contributed modules. They publish security advisories and release fixes.
- Your hosting provider secures the infrastructure: network, operating system, and platform-level controls such as a web application firewall.
- Your team owns everything else. That means applying patches, reviewing custom code, configuring user permissions, managing secrets, and deciding who has administrator access. Most Drupal breaches trace back to this layer, not to a flaw in Drupal.
To answer the question directly: Drupal is a strong, secure foundation for enterprise websites, and it is still only as secure as the way you operate it.
We convened a panel of in-house experts to discuss how to operate it well: Robert Former, Chief Information Security Officer; Justin Cherry, Senior Principal Compliance Auditor, Director GRC; and Claudia Mueller Thomson, Director, Product Management, Cloud Platform.
Common Security Threats Facing Drupal Sites
The biggest and most visible threat facing all websites, not just Drupal ones, is distributed denial of service (DDoS). DDoS attacks are cheap, easy to launch, and hard to attribute.
Tools and practices do mitigate them, but they remain one of the most frequent events Acquia addresses, said Cherry. Customers of Acquia Edge Security get frontline protection from a web application firewall (WAF) that filters bad traffic before it reaches the web server or load balancer, which lowers DDoS risk considerably.
The second major threat is self-inflicted: failing to patch or review code. "If you don't patch and if you don't look over your code, you're opening yourself up to bad actors," says Former. "The threats that arise from inaction are as serious as the threats that arise from action. Patch, test, scan. Don't make it easy for attackers."
Custom or out-of-date modules are another attack vector. Cherry recommends using supported modules and monitoring your site through application security scanning.
Beyond those, the application-level vulnerability classes that matter most for Drupal are:
- Cross-site scripting (XSS) – injecting scripts that run in another user's browser. Drupal's Twig templating escapes output by default, which helps, but custom code can bypass it.
- SQL injection – manipulating database queries. Drupal's database abstraction layer prevents this when you use it correctly; raw queries in custom code reintroduce the risk.
- Cross-site request forgery (CSRF) – tricking an authenticated user into submitting an unintended action. Use Drupal's form API, which adds CSRF tokens automatically.
- Remote code execution (RCE) – the most severe class, usually arriving through an unpatched core or module vulnerability.
- Privilege escalation – a lower-privileged account gaining administrator rights, often through misconfigured permissions.
- Insecure API exposure – JSON:API and GraphQL endpoints that expose more data than intended, or that lack proper authentication.
Strong input validation and output escaping in custom code prevent most of the first three.
Drupal Security Best Practices
Drupal core updates and patch management
"Patch promptly" is advice everyone agrees with and few operationalize. A repeatable workflow is what actually closes the gap.
- Monitor advisories. Subscribe to Drupal.org security advisories, which publish on a predictable schedule, and to CVE distribution lists for your wider stack. Drupal's Update Manager flags available updates inside the admin interface.
- Triage by severity. Assign an owner and a remediation deadline based on risk. Many teams target 24 to 48 hours for critical advisories, one week for moderate, and the next release cycle for low.
- Patch everything, not just core. Drupal core, contributed modules, custom themes, and Composer and PHP dependencies all need coverage. Theme updates are the most commonly forgotten.
- Pin versions. Use Composer to lock dependency versions so deployments stay reproducible and nothing updates unexpectedly.
- Test in staging. Apply the patch in a staging environment that mirrors production, and run your automated test suite.
- Back up first. Take a database and file backup immediately before a production deployment.
- Validate afterward. Confirm the fix landed, the site works, and nothing regressed. Record what you did.
Tracking end-of-life components belongs in this workflow too. Former raised patching twice to stress it: "We've seen a startling uptick in the number of vulnerabilities published." Build the new version of a component into your code early, because that effort is a fraction of what it costs to scramble in production.
This is especially urgent right now. Drupal 10 reaches end of life on December 9, 2026. After that date it receives no security advisories or fixes. If you are still on Drupal 10, upgrading to Drupal 11 is a security requirement, not a nice-to-have.
Security modules
A handful of contributed modules meaningfully raise your baseline:
- Security Kit (SecKit) adds protective HTTP headers that reduce XSS and clickjacking risk.
- Password Policy enforces complexity and rotation rules.
- Two-factor Authentication (TFA) adds a second factor for logins.
- Login Security limits failed login attempts and blocks suspicious addresses.
- Paranoia removes the ability to execute arbitrary PHP through the interface.
Vet every module you add on active maintenance, a supporting organization, and participation in Drupal's security advisory policy.
User roles and permissions
Access control is where many Drupal sites are quietly weakest.
- Apply least privilege. Give each role the minimum permissions needed. Audit the permissions page rather than assuming defaults are safe.
- Lock down user 1. Drupal's first account bypasses permission checks entirely. Treat it as a break-glass credential: strong unique password, stored in a password manager, not used for daily work.
- Separate administrative accounts. Editors should not browse the web logged in as administrators. Give privileged users a second, distinct account.
- Require multifactor authentication. Enforce MFA, ideally through single sign-on (SSO), for every account with elevated access.
- Watch the dangerous permissions. "Administer permissions," "administer users," "administer modules," "use PHP for settings," and anything allowing full HTML carry escalation risk.
- Review access quarterly. People change roles and leave. Stale accounts are an easy way in.
- Log privileged actions. Keep an audit trail of who changed permissions, installed modules, or edited configuration.
- Offboard deliberately. Disable accounts the day someone departs rather than at the next review.
Server Security Hardening
Application security does not help if the surrounding server configuration leaks. These are the controls to verify.
- File permissions. The web server should not be able to write to code directories. Settings files should be read-only in production. Grant write access only where Drupal genuinely needs it, such as the public files directory.
- Secrets management. Keep database credentials, API keys, and salts out of version control and out of the web root. Use environment variables or a dedicated secrets manager, and rotate credentials on a schedule.
- Private files. Store any file that should not be publicly reachable in a private file system directory outside the web root, served through Drupal's access checks.
- Trusted host settings. Configure
trusted_host_patternsin settings.php to block HTTP host header attacks. - HTTPS everywhere. Force HTTPS site-wide, enable HTTP Strict Transport Security, and set secure cookie flags.
- Error reporting. Set error display to "none" in production. Verbose errors reveal file paths and database structure to attackers.
- Database security. Give the Drupal database user only the privileges it needs. Do not expose the database to the public network.
- Configuration management. Keep configuration in code with Drupal's configuration management system, so changes are reviewed and auditable rather than clicked into production.
- Environment separation. Development, staging, and production should be genuinely separate, with distinct credentials and no production data in lower environments unless it has been sanitized.
Protecting High-Traffic Drupal Sites
High-traffic sites need resilience controls beyond a hardened application.
- Web application firewall. A WAF at the edge filters malicious requests before they reach your origin.
- DDoS protection. Edge-level absorption keeps volumetric attacks away from your infrastructure.
- Rate limiting. Cap requests per address for login forms, search, and API endpoints to blunt brute-force and scraping attempts.
- Bot management. Distinguish good bots from credential stuffers and scrapers. This matters more each year as automated traffic grows.
- CDN caching. Serving cached pages from the edge both improves performance and reduces the attack surface reaching your application.
- Origin shielding. Hide origin server addresses so attackers cannot bypass your edge protection.
- Traffic alerting. Alert on anomalies, not just outages. A traffic spike is sometimes an attack in progress.
- Tested escalation procedures. Know who to call, and rehearse it. An untested runbook fails when you need it.
One option worth knowing: Drupal Steward, offered by the Drupal Association, provides WAF protection specifically against known Drupal vulnerabilities. It is useful when you cannot patch immediately, though it is a stopgap rather than a substitute for patching.
Drupal Security Audit
Regular security audits
A Drupal security audit should test specific, verifiable areas. Use this as a checklist:
- Versions. Is Drupal core current and supported? Are all contributed modules, themes, and Composer dependencies up to date?
- Risky modules. Are any unsupported, abandoned, or known-vulnerable modules installed? Any unused modules still enabled?
- Permissions. Does any role hold permissions it does not need? Are dangerous permissions limited to trusted roles?
- Authentication. Is MFA enforced for privileged accounts? Are password policies active? Any shared or stale accounts?
- Configuration. Error reporting off, trusted host patterns set, HTTPS enforced, security headers present?
- Exposed files and endpoints. Are settings files, backups, logs, or
.gitdirectories reachable from the web? Are JSON:API and GraphQL endpoints properly authenticated? - Custom code. Does it use Drupal's APIs for database queries, form handling, and output escaping?
- Logging and monitoring. Are security events logged, retained, and actually monitored?
- Server posture. File permissions, database access, environment separation.
- Remediation evidence. Were findings from the last audit fixed and verified, with a record?
Cherry, a compliance specialist, is a strong proponent of a secure development framework. Payment card industry (PCI) cardholder data requires a secure development methodology, but even sites that handle no card data benefit from a framework such as OWASP. For application testing he recommends both dynamic and static code scanning to surface vulnerabilities in the code and the running application.
Findings only matter if they close. Risk-rank every finding, assign an owner, set a deadline, retest after the fix, and record the outcome.
Drupal Penetration Testing
Cherry recommends penetration testing at least annually, more often if a regulation requires it or your organization tests on major releases. He also suggests manually poking at your own site and trying to break it.
Former agrees. "The best way to know how to fix it is to be the one who breaks it," he says. That is why he favors internal red teams.
"Internal pen testers have that internal knowledge that puts them a step above external attackers and gets you another level deeper," he continued. "So, pen test your own stuff and then test it with an external third party. By the time your third party comes in, you should already know what they're going to find and be ready to address any surprises that you haven't found yourself."
Scoping a test safely
Penetration testing touches live systems, so scope it carefully.
- Get written authorization. Document who approved the test, what is in scope, and when. Testing without authorization creates legal exposure.
- Define scope precisely. List the domains, environments, and endpoints included, and what is explicitly excluded.
- Set rules of engagement. Agree in advance whether DDoS simulation, social engineering, or data modification are permitted. Usually they are not.
- Prefer a production-like staging environment for destructive tests. Where you must test production, agree safeguards first.
- Provide test accounts at each privilege level, so testers can probe for privilege escalation without touching real user data.
- Agree a testing window and notify your hosting provider, so defensive systems do not misread the test as a real attack.
- Establish an emergency contact who can halt the test immediately.
- Remediate and retest. A report with no retest is an unfinished engagement.
The OWASP Testing Guide is a useful reference for structuring scope and methodology.
A threat management team complements this work by looking outward as well as inward. At Acquia, someone tracks developments in Russia, Ukraine, the Middle East, and Central America, Former explained, so the team watches for what is coming rather than being surprised.
Monitoring, Backups, and Incident Response
Prevention eventually fails. What follows determines the damage.
Monitoring. Log authentication events, permission changes, and configuration edits. Alert on failed login spikes, unexpected administrator logins, and traffic anomalies. Assign a named owner to every alert, because an alert nobody owns is noise.
Backup strategy. Back up code, database, and files on a schedule matched to how often your content changes. Store backups separately from production so one compromise does not take both. Then test restoration. An untested backup is a hope, not a plan.
Incident response. Write a playbook before you need it, covering how to contain an incident, who decides to take the site offline, who notifies customers and regulators, and how evidence is preserved. Then run a post-incident review and fix the underlying cause.
Tooling helps carry this load, says Mueller Thomson. It is expensive but worth every penny: "Platforms are very complex. There are many assets that need to be monitored; too many opportunities for human error. So, tooling made all the difference for us in terms of our ability to stay on top of security and compliance needs."
Her broader point applies to all of the above. "Security and compliance should be planned, designed, prioritized, budgeted, hired for, and implemented as part of every new product or service an engineering team puts in place." Treating either as an end-stage checkbox is itself a common and costly mistake.
How to Improve an Existing Drupal Site's Security
If you have inherited a site of unknown security posture, work in this order.
First, inventory. List your Drupal core version, every contributed module and theme with its version and support status, all custom code, and every account with elevated access. You cannot secure what you have not catalogued.
Second, close the critical gaps. Apply outstanding security advisories. Confirm you are on a supported Drupal version. Disable unused modules. Turn off error display. Remove or replace unsupported modules.
Third, fix access control. Audit permissions against least privilege, secure user 1, enforce MFA on privileged accounts, and remove stale accounts.
Fourth, harden configuration using the server hardening list above, then establish the routine: patch monitoring with owners and deadlines, scheduled scans, backups with tested restores, and a quarterly access review.
Finally, verify independently. Once the basics hold, commission an audit or penetration test to find what you missed. Test every fix in staging, and confirm each one landed in production.
Choosing Drupal Security Hardening Experts
At enterprise scale, some of this work goes to specialists. Three options exist, and they are not mutually exclusive.
Internal team. Best for ongoing operations: patching, access reviews, monitoring. Requires sustained Drupal and security headcount.
Managed hosting provider. Best for infrastructure, WAF, DDoS protection, and platform patching. You still own application-layer decisions.
Third-party security specialists. Best for independent audits and penetration tests. Independence is the point, so your auditor should not be the team that built the site.
When evaluating an external provider, look for:
- Demonstrable Drupal expertise. Contributions to Drupal core or security advisories are credible proof, not marketing claims.
- High-scale experience. Ask for work on sites comparable to yours in traffic and complexity.
- A stated methodology. OWASP-aligned or similar, not an ad hoc process.
- Independent testing capability. In-house pen testers rather than a resold scan.
- Incident response availability. What happens at 2 a.m. on a holiday, and what does the SLA actually guarantee?
- Reporting quality. Ask for a sample report. Findings should be risk-ranked and reproducible, not a raw scanner dump.
- Remediation support. Will they help fix what they find, and retest afterward?
- References. From organizations in your sector, at your scale.
Start With What Is Overdue
If this list is daunting, start here: confirm you are on a supported Drupal version, apply every outstanding security advisory, and check who holds administrator access. Those three steps close the gaps behind most Drupal compromises.
Then build the routine. Security is not a project that finishes; it is an operating practice that holds.