Transcript
Page 1: Drupal and Security: What You Need to Know

Drupal and SecurityWhat you need to know

Stephane Corlosquet29th September 2015

Page 2: Drupal and Security: What You Need to Know

Stéphane"scor"Corlosquet

9+ years with Drupal

Drupal Security Team member

RDF in core + contrib

Definitive Guide to Drupal 7

We're hiring

Page 3: Drupal and Security: What You Need to Know

Lotsofthingstocover

Server environment

Server config

Personal practices

Drupal Configuration

Code

Page 5: Drupal and Security: What You Need to Know

Generaltips

Use HTTPS, SSH, SFTP

Strong password policy

Server – LAMP stack

Require SSH keys

Take & verify your backups

for sharingSanitize backups

Page 6: Drupal and Security: What You Need to Know

Securesiteconfiguration

Keep your site settings secure

Text formats

PHP module

PHP in other modules

Roles and permissions

Page 7: Drupal and Security: What You Need to Know

Securesiteconfiguration

File permissions: web server user forbidden to change

code

PHP execution: restrict in .htaccess or Nginx config

Drupal handbook for securing your site

Page 8: Drupal and Security: What You Need to Know

Drupalspecifichosting

Can your hosting provider help you improve your

security process?

&

Tuned for Drupal security (and performance)

Code, DB, uploaded files, config

Managed security updates

Acquia Cloud Insight

Acquia Remote administration

Page 10: Drupal and Security: What You Need to Know

PCI,HIPAA,SOC1,SOC2,SCADA

Be aware of the regulations in your environment

Anyone work in HIPAA environment?

FedRAMP/FISMA Certification & Accreditation (C&A)?

Anyone work with Drupal in SCADA environment?

Drupal PCI Compliance Report

Page 11: Drupal and Security: What You Need to Know

Securityprocess

Ongoing maintenance

Budget for security

Managed hosting

Drupal.org packaging infrastructure

Page 12: Drupal and Security: What You Need to Know

Securityprocess

Keep Drupal code secure in core and contrib

Educate the community on security best practices

Developers

Site builders

Site administrators and users

Decision makers

for every security release

Drupal Security Team

Security Advisory

Page 13: Drupal and Security: What You Need to Know

Securityprocess

https://www.acquia.com/blog/keeping-drupal-secure

Page 17: Drupal and Security: What You Need to Know

Whatarethemostcommon

issues?

Page 18: Drupal and Security: What You Need to Know

Whatarethemostcommon

issues?

Page 19: Drupal and Security: What You Need to Know

WhatisXSS?

Cross Site Scripting

Code in the browser

Making requests

Parsing responses

Javascript, Flash, Java, etc.

Page 20: Drupal and Security: What You Need to Know

TestingforXSS

<script>alert('title');</script>

<img src="a" onerror="alert('title');">

Catches 90%

Page 21: Drupal and Security: What You Need to Know

FixingXSS?

Filter text

On output to browser

As late as reasonable

Some API filters where reasonable

t() and @text and %text placeholders

Page 23: Drupal and Security: What You Need to Know

WhatisAccessBypass?

User can see or do something

That permissions/access should prevent

Page 24: Drupal and Security: What You Need to Know

Wheredoweenforceit?

Menu 'access callback'

if(user_access('see something'));Node access system

Entity access

Field access

Services & Ajax apis?

In templates

Page 25: Drupal and Security: What You Need to Know

TestingforAccessBypass

Visit node/nid etc.

Visit anything/%node

Use behat

Page 26: Drupal and Security: What You Need to Know

FixingAccessBypass?

user_access for permissions

node_accessentity_access$query->addTag('node_access');menu definitions

write automated tests

Page 27: Drupal and Security: What You Need to Know

WhatisCSRF?

path that does not confirm intent

<img src=" " >http://example.com/node/1/quickdelete

Page 28: Drupal and Security: What You Need to Know

TestingforCSRF

$_GET, $_POST, no use of drupal_get_token()

"verb" menu callbacks without token

Page 29: Drupal and Security: What You Need to Know

FixingCSRF?

Use Form API: confirmation forms

Send and validate tokens

Protect Against CSRF webinar with greggles

Page 30: Drupal and Security: What You Need to Know

Drupalgeddon-coreSQL

injection2014

SQL injection lead to arbitrary code execution

Plan your security updates!

Exploited soon after the release

Mitigated on Acquia Cloud

Handbook for how to recover from a breach

Page 31: Drupal and Security: What You Need to Know

Drupal7

Securityimprovements

Page 32: Drupal and Security: What You Need to Know

Drupal7

Stronger password hashing / salt

Login flood control

prevents brute-force credential guessing

Protected cron

prevents Denial of Service attacks

Update manager

Update module from the web UI

Page 33: Drupal and Security: What You Need to Know

Drupal7UpdateManager

Page 34: Drupal and Security: What You Need to Know

Drupal7UpdateManager

Notifications

Page 35: Drupal and Security: What You Need to Know

Drupal8

Securityimprovements

Page 36: Drupal and Security: What You Need to Know

Drupal8:Twig

Automatically sanitizes strings on output

# Drupal 7 if (isset($variables['link_path'])) { $output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables } else { $output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables } return $output;

# Drupal 8 {% if link_path -%} <a{{ attributes }}>{{ name }}{{ extra }}</a> {%- else -%} <span{{ attributes }}>{{ name }}{{ extra }}</span> {%- endif -%}

Page 37: Drupal and Security: What You Need to Know

Drupal8:Twig

No PHP in templates

{% if link_path -%} <a{{ attributes }}>{{ name }}{{ extra }}</a>{%- else -%} <span{{ attributes }}>{{ name }}{{ extra }}</span>{%- endif -%}

Page 38: Drupal and Security: What You Need to Know

Drupal8:WYSIWYGincore

Streamlined filter mechanism (server and client side)

No more full HTML as last resort

Page 39: Drupal and Security: What You Need to Know

Drupal8:PHP

Removed PHP module

Page 40: Drupal and Security: What You Need to Know

Drupal8:Built-inCSRFtokens

CSRF tokens built in the routing system

# views_ui.routing.ymlviews_ui.enable: path: '/admin/structure/views/view/{view}/enable' defaults: _controller: '\Drupal\views_ui\Controller\ViewsUIController::ajaxOperation' op: enable requirements: _entity_access: view.enable _csrf_token: 'TRUE'

Page 41: Drupal and Security: What You Need to Know

Drupal8:lotsmorehardening

PDO MySQL limited to executing single statements

PHP execution in subfolders forbidden in .htaccess

Clickjacking protection per default with X-Frame-

Options

Hashed user session IDs in the DB

Trusted hosts pattern to restrict URL domains

Blog post: 10 Ways Drupal 8 Will Be More Secure

Page 42: Drupal and Security: What You Need to Know

BookonSecurityinDrupal

Page 43: Drupal and Security: What You Need to Know

References

Drupal Security Advisories

Drupal Security Team

Drupal Security report

Drupal Security Best Practices guide

DGD7 chapter 6

https://groups.drupal.org/security

Security on docs.acquia.com

Page 44: Drupal and Security: What You Need to Know

Thanks!

Got questions?

Contact

@scorlosquet

[email protected]


Recommended