Top Banner
Drupal and Security Advice for Site Builders and Coders Arunkumar Kuppuswamy Software Engineer Innoppl Technologies [email protected] Phone: +91 80986 41508
39

Drupal and security - Advice for Site Builders and Coders

Apr 07, 2017

Download

Internet

Arun Kumar K
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Drupal and security - Advice for Site Builders and Coders

Drupal and Security Advice for Site Builders and Coders

Arunkumar Kuppuswamy Software Engineer Innoppl [email protected]: +91 80986 41508

Page 2: Drupal and security - Advice for Site Builders and Coders

● Security Vulnerabilities● General Tips● Server Environment● Site Configurations● Personal Practices● Drupal Configuration● Writing Custom Codes

Agenda

Page 3: Drupal and security - Advice for Site Builders and Coders

● Drupal is an open-source CMS and or framework● 2.2% of websites in Internet are running using

Drupal● 3rd Popular CMS in world.● Reliability● Scalability● A huge dedicated community

Why Drupal ?

Page 4: Drupal and security - Advice for Site Builders and Coders

https://w3techs.com/technologies/overview/content_management/all

Do you think Drupal is the Right choice ?

Page 7: Drupal and security - Advice for Site Builders and Coders

- System flaw or weakness in an application● Cross Site Scripting (XSS)● Broken Authentication● Gain Information / Privileges● SQL Injection● Bypass something● CSRF

Security vulnerabilities

Page 8: Drupal and security - Advice for Site Builders and Coders

● Cross Site Scripting● Code in the browser● Making requests● Parsing responses● Javascript, Flash, Java, etc.

What is XSS?

Page 9: Drupal and security - Advice for Site Builders and Coders

● Filter text● On output to browser● As late as reasonable● Some API filters where reasonable● t() and \Drupal::translation()->formatPlural()

with @text and %text placeholders

Fixing XSS?

Page 10: Drupal and security - Advice for Site Builders and Coders
Page 11: Drupal and security - Advice for Site Builders and Coders

- User to access the system without going through the security clearance● User can see or do something● That permissions/access should prevent

What is Access Bypass?

Page 12: Drupal and security - Advice for Site Builders and Coders

● Creating PermissionsMODULE_NAME.permissions.yml

Fixing Access Bypass

Page 13: Drupal and security - Advice for Site Builders and Coders

● Menu CallbacksMODULE_NAME.routing.yml

Fixing Access Bypass

Page 14: Drupal and security - Advice for Site Builders and Coders

● Node access○ hook_node_access()

● User access○ hook_user_access()

● Entity access○ hook_entity_access()

● Field access○ hook_field_access()

Fixing Access Bypass

Page 15: Drupal and security - Advice for Site Builders and Coders

Fixing Access Bypass?

Page 16: Drupal and security - Advice for Site Builders and Coders

● User has permission to Access

● Use behat

Fixing Access Bypass?

Page 17: Drupal and security - Advice for Site Builders and Coders

- Executing malicious SQL statements.● Incorrectly filtered escape characters● Incorrect type handling● Blind Conditional SQL injection

SQL Injection

Page 18: Drupal and security - Advice for Site Builders and Coders

Drupal SQL Injection Sample Code

Page 19: Drupal and security - Advice for Site Builders and Coders

Drupal SQL Injection Sample Code

Page 20: Drupal and security - Advice for Site Builders and Coders

● Database abstraction layer

● Adding tags to your queries

Fixing SQL Injection

Page 21: Drupal and security - Advice for Site Builders and Coders

Unauthorized commands are transmitted from a user that the website trusts.● Path that does not confirm intent● <img src="http://example.com/node/1/quickdelete" >● Mostly in Form submissions

What is CSRF?

Page 22: Drupal and security - Advice for Site Builders and Coders

● Use Form API: confirmation forms

● Send and validate tokens : Drupal::csrfToken()● Using a secret cookie● Multi-Step Transactions● HTTPS

Fixing CSRF?

Page 23: Drupal and security - Advice for Site Builders and Coders

● YAML route definition for a protected link● Protected Ajax request

Fixing CSRF?

Page 24: Drupal and security - Advice for Site Builders and Coders

● Protected Ajax request

Fixing CSRF?

Page 25: Drupal and security - Advice for Site Builders and Coders

● Roles and permissions● Keep your site settings secure

○ Text formats○ PHP module○ PHP in other modules

Secure site configuration

Page 26: Drupal and security - Advice for Site Builders and Coders

● File permissions: web server user forbidden to change code

● PHP execution: restrict in .htaccess or Nginx config

● Drupal handbook for securing your site

Secure site configuration

Page 28: Drupal and security - Advice for Site Builders and Coders

● Stronger password hashing / salt● Login flood control

○ prevents brute-force credential guessing● Protected cron

○ prevents Denial of Service attacks

Drupal 8

Page 29: Drupal and security - Advice for Site Builders and Coders

Update Settings

Page 30: Drupal and security - Advice for Site Builders and Coders

● Automatically sanitizes strings on output● No PHP in templates● You can't run SQL queries● Twig auto-escaping : htmlspecialchars()

Drupal 8: Twig

Page 31: Drupal and security - Advice for Site Builders and Coders
Page 32: Drupal and security - Advice for Site Builders and Coders

● Filtered HTML format● Limiting users to using only images local

Content Entry & Filtering Improved

Page 33: Drupal and security - Advice for Site Builders and Coders

Choosing Contrib Modules

Page 34: Drupal and security - Advice for Site Builders and Coders

● Use HTTPS, SSH, SFTP● Strong password policy● Server – LAMP stack● Require SSH keys● Take & verify your backups

○ Sanitize backups before sharing

General Tips

Page 35: Drupal and security - Advice for Site Builders and Coders

● Drupal Security Team○ Keep Drupal code secure in core and contrib○ Educate the community on security best

practices1. Developers2. Site builders3. Site administrators and users4. Decision makers

○ Security Advisory for every security release○ @drupalsecurity and Security Group

Security Process

Page 36: Drupal and security - Advice for Site Builders and Coders

Security Issue

Code Maintainer

Team Security

New Release

Page 38: Drupal and security - Advice for Site Builders and Coders

Any Queries ?

Page 39: Drupal and security - Advice for Site Builders and Coders

Thank you!