SlideShare a Scribd company logo
1 of 18
Being !BlackHat with
Drupal
- Anand Toshniwal
@toshniwal_anand
AGENDA
❏ Importance of secure coding
❏ Database security
❏ Session hijacking
❏ Text security
❏ Cross-site scripting
❏ Safely impersonating another user
Why secure coding is important?
❏ Security isn’t an option
❏ Link in the chain on design security
❏ Security by obscurity is myth
❏ Proactive prevention is more effective than reactive detection
❏ Hackers, crackers and attackers
Database Access
db_query(‘SELECT n.title FROM {node} n WHERE n.nid = ‘ . $_GET[‘nid’] );
Good practice
[D7] db_query(‘SELECT n.title FROM {node} n WHERE n.nid = :nid’, array(‘:nid’ => $_GET[‘nid’]));
[D8] Database::getConnection()->query(‘SELECT n.title FROM {node} n
WHERE n.nid = :nid’, [‘:nid’ =>
$_GET[‘nid’]]);
Bad practice
Dynamic queries
❏ If the query parts vary
❏ Select queries may be either static or dynamic
❏ To support multiple database servers easily
❏ Provides structural interface
❏ To enforce security checks
SESSION HIJACKING
Session ID
user
user’s
browser
Access
page
Drupal
Drupal receives
session ID
Handle Text in Secure Fashion
a. <?php print l(check_plain($title), 'node/'. $nid); ?>
b. <?php print l($title, 'node/'. $nid); ?>
2.
a. <?php print '<a href="/' . $url . '">'; ?>
b. <?php print '<a href="/'. check_plain($url) .'">'; ?>
c. <?php print '<a href="/'. check_url($url) .'">'; ?>
Choose the correct option
3.
a. $form['text1'] = array(
'#type' => 'textfield',
'#default_value' => check_plain($u_supplied),
);
b. $form[select1] = array(
'#type' => 'select',
'#default_value' => 0,
'#options' => node_get_types('names'),
);
Choose the correct option
Sanitization for backend use
Text Replacement
❏ @variable
$this->placeholderFormat('This will force HTML-escaping of the replacement
value: @text', ['@text' => (string)$safe_string_interface_object));
❏ %variable
$string = "%output_text";
$arguments = ['%output_text' => 'text output here.'];
$this->placeholderFormat($string, $arguments);
❏ :variable
$this->placeholderFormat('<a href=":url">@variable</a>', [':url' => $url,
'@variable' => $variable]);
Cross-site scripting (xss) attack
Cross-site scripting (xss) attack
Safely Impersonating Another User
Drupal 7
global $user;
$original_user = $user;
$old_state = drupal_save_session();
drupal_save_session(FALSE);
$user = user_load(1);
// Take your action here
$user = $original_user;
drupal_save_session($old_state);
Drupal 8
$accountSwitcher = Drupal::service('account_switcher');
$account = DrupaluserEntityUser::load(2);
$accountSwitcher->switchTo($account);
// Take your action here. If your code fails, then you should catch an
exception
// and switch back (see below).
// Restore user account.
$accountSwitcher->switchBack();
Being! Black Hat with Drupal - Anand Toshniwal

More Related Content

What's hot

Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Cliff Seal
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Fabien Potencier
 
MUC - Moodle Universal Cache
MUC - Moodle Universal CacheMUC - Moodle Universal Cache
MUC - Moodle Universal CacheTim Hunt
 
Pm 4.0 permission_storage
Pm 4.0 permission_storagePm 4.0 permission_storage
Pm 4.0 permission_storageOleg K
 
Indexing documents
Indexing documentsIndexing documents
Indexing documentsMongoDB
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHPmarkstory
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
What's New in Drupal 8: Entity Field API
What's New in Drupal 8: Entity Field APIWhat's New in Drupal 8: Entity Field API
What's New in Drupal 8: Entity Field APIDrupalize.Me
 
Dependency Injection in Laravel
Dependency Injection in LaravelDependency Injection in Laravel
Dependency Injection in LaravelHAO-WEN ZHANG
 
Zf Zend Db by aida
Zf Zend Db by aidaZf Zend Db by aida
Zf Zend Db by aidawaraiotoko
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery PresentationSony Jain
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPVineet Kumar Saini
 
Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Evgeny Nikitin
 
Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201Fabien Potencier
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 

What's hot (20)

Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
 
php plus mysql
php plus mysqlphp plus mysql
php plus mysql
 
MUC - Moodle Universal Cache
MUC - Moodle Universal CacheMUC - Moodle Universal Cache
MUC - Moodle Universal Cache
 
Drupal 8 database api
Drupal 8 database apiDrupal 8 database api
Drupal 8 database api
 
Pm 4.0 permission_storage
Pm 4.0 permission_storagePm 4.0 permission_storage
Pm 4.0 permission_storage
 
Indexing documents
Indexing documentsIndexing documents
Indexing documents
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
What's New in Drupal 8: Entity Field API
What's New in Drupal 8: Entity Field APIWhat's New in Drupal 8: Entity Field API
What's New in Drupal 8: Entity Field API
 
Dependency Injection in Laravel
Dependency Injection in LaravelDependency Injection in Laravel
Dependency Injection in Laravel
 
Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Zf Zend Db by aida
Zf Zend Db by aidaZf Zend Db by aida
Zf Zend Db by aida
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
Perl object ?
Perl object ?Perl object ?
Perl object ?
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
 
Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014
 
Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 

Similar to Being! Black Hat with Drupal - Anand Toshniwal

Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyBalázs Tatár
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Editionddiers
 
Drupal II: The SQL
Drupal II: The SQLDrupal II: The SQL
Drupal II: The SQLddiers
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Balázs Tatár
 
Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019Balázs Tatár
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesDesarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesLuis Curo Salvatierra
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Craig Francis
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::ManagerJay Shirley
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class ReferenceJamshid Hashimi
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And AnishOSSCube
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilorRazvan Raducanu, PhD
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7chuvainc
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QAarchwisp
 

Similar to Being! Black Hat with Drupal - Anand Toshniwal (20)

Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Edition
 
Drupal II: The SQL
Drupal II: The SQLDrupal II: The SQL
Drupal II: The SQL
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesDesarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móviles
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()
 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your boss
 
21. CodeIgniter search
21. CodeIgniter search21. CodeIgniter search
21. CodeIgniter search
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class Reference
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor15. CodeIgniter editarea inregistrarilor
15. CodeIgniter editarea inregistrarilor
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
 

More from DrupalMumbai

20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...
20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...
20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...DrupalMumbai
 
Drupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj KDrupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj KDrupalMumbai
 
How To Write Dynamic Migrations - Mohit Aghera
How To Write Dynamic Migrations - Mohit AgheraHow To Write Dynamic Migrations - Mohit Aghera
How To Write Dynamic Migrations - Mohit AgheraDrupalMumbai
 
Event Schedule DCM2018 Event Schedule DCM2018 100% 10 Too Many Project Meth...
 Event Schedule DCM2018 Event Schedule DCM2018 100% 10  Too Many Project Meth... Event Schedule DCM2018 Event Schedule DCM2018 100% 10  Too Many Project Meth...
Event Schedule DCM2018 Event Schedule DCM2018 100% 10 Too Many Project Meth...DrupalMumbai
 
AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...
AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...
AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...DrupalMumbai
 
Virtual Reality in WEB ! - Vidit Anjaria, Swastik Pareek
Virtual Reality in WEB ! - Vidit Anjaria,  Swastik PareekVirtual Reality in WEB ! - Vidit Anjaria,  Swastik Pareek
Virtual Reality in WEB ! - Vidit Anjaria, Swastik PareekDrupalMumbai
 
Building and Maintaining a Healthy Community - Jayesh Katta Ramalingaiah
Building and Maintaining a Healthy Community - Jayesh Katta RamalingaiahBuilding and Maintaining a Healthy Community - Jayesh Katta Ramalingaiah
Building and Maintaining a Healthy Community - Jayesh Katta RamalingaiahDrupalMumbai
 
How to use CSS Grids today in the real world - Manjit Singh
How to use CSS Grids today in the real world - Manjit SinghHow to use CSS Grids today in the real world - Manjit Singh
How to use CSS Grids today in the real world - Manjit SinghDrupalMumbai
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overviewDrupalMumbai
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Administration
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal AdministrationDrupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Administration
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal AdministrationDrupalMumbai
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Terminologies
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal TerminologiesDrupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Terminologies
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal TerminologiesDrupalMumbai
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal
Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal
Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal DrupalMumbai
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Intro
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal IntroDrupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Intro
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal IntroDrupalMumbai
 
Drupal Mumbai Introduction
Drupal Mumbai IntroductionDrupal Mumbai Introduction
Drupal Mumbai IntroductionDrupalMumbai
 

More from DrupalMumbai (15)

20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...
20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...
20 cool features that is in PHP 7, we missed in PHP 5. Let walkthrough with t...
 
Drupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj KDrupal 8 Plugin API - Manoj K
Drupal 8 Plugin API - Manoj K
 
How To Write Dynamic Migrations - Mohit Aghera
How To Write Dynamic Migrations - Mohit AgheraHow To Write Dynamic Migrations - Mohit Aghera
How To Write Dynamic Migrations - Mohit Aghera
 
Event Schedule DCM2018 Event Schedule DCM2018 100% 10 Too Many Project Meth...
 Event Schedule DCM2018 Event Schedule DCM2018 100% 10  Too Many Project Meth... Event Schedule DCM2018 Event Schedule DCM2018 100% 10  Too Many Project Meth...
Event Schedule DCM2018 Event Schedule DCM2018 100% 10 Too Many Project Meth...
 
AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...
AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...
AMPifying your Drupal 8 Site : higher performance and higher engagement - Par...
 
Virtual Reality in WEB ! - Vidit Anjaria, Swastik Pareek
Virtual Reality in WEB ! - Vidit Anjaria,  Swastik PareekVirtual Reality in WEB ! - Vidit Anjaria,  Swastik Pareek
Virtual Reality in WEB ! - Vidit Anjaria, Swastik Pareek
 
Building and Maintaining a Healthy Community - Jayesh Katta Ramalingaiah
Building and Maintaining a Healthy Community - Jayesh Katta RamalingaiahBuilding and Maintaining a Healthy Community - Jayesh Katta Ramalingaiah
Building and Maintaining a Healthy Community - Jayesh Katta Ramalingaiah
 
How to use CSS Grids today in the real world - Manjit Singh
How to use CSS Grids today in the real world - Manjit SinghHow to use CSS Grids today in the real world - Manjit Singh
How to use CSS Grids today in the real world - Manjit Singh
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Administration
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal AdministrationDrupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Administration
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Administration
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Terminologies
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal TerminologiesDrupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Terminologies
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Terminologies
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal
Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal
Drupal Global Training Day by Drupal Mumbai 6th Sep - Extending Drupal
 
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Intro
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal IntroDrupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Intro
Drupal Global Training Day by Drupal Mumbai 6th Sep - Drupal Intro
 
Drupal Mumbai Introduction
Drupal Mumbai IntroductionDrupal Mumbai Introduction
Drupal Mumbai Introduction
 

Recently uploaded

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Recently uploaded (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Being! Black Hat with Drupal - Anand Toshniwal

  • 1. Being !BlackHat with Drupal - Anand Toshniwal @toshniwal_anand
  • 2. AGENDA ❏ Importance of secure coding ❏ Database security ❏ Session hijacking ❏ Text security ❏ Cross-site scripting ❏ Safely impersonating another user
  • 3. Why secure coding is important? ❏ Security isn’t an option ❏ Link in the chain on design security ❏ Security by obscurity is myth ❏ Proactive prevention is more effective than reactive detection ❏ Hackers, crackers and attackers
  • 4. Database Access db_query(‘SELECT n.title FROM {node} n WHERE n.nid = ‘ . $_GET[‘nid’] ); Good practice [D7] db_query(‘SELECT n.title FROM {node} n WHERE n.nid = :nid’, array(‘:nid’ => $_GET[‘nid’])); [D8] Database::getConnection()->query(‘SELECT n.title FROM {node} n WHERE n.nid = :nid’, [‘:nid’ => $_GET[‘nid’]]); Bad practice
  • 5. Dynamic queries ❏ If the query parts vary ❏ Select queries may be either static or dynamic ❏ To support multiple database servers easily ❏ Provides structural interface ❏ To enforce security checks
  • 8. Handle Text in Secure Fashion
  • 9. a. <?php print l(check_plain($title), 'node/'. $nid); ?> b. <?php print l($title, 'node/'. $nid); ?> 2. a. <?php print '<a href="/' . $url . '">'; ?> b. <?php print '<a href="/'. check_plain($url) .'">'; ?> c. <?php print '<a href="/'. check_url($url) .'">'; ?> Choose the correct option
  • 10. 3. a. $form['text1'] = array( '#type' => 'textfield', '#default_value' => check_plain($u_supplied), ); b. $form[select1] = array( '#type' => 'select', '#default_value' => 0, '#options' => node_get_types('names'), ); Choose the correct option
  • 11. Sanitization for backend use Text Replacement ❏ @variable $this->placeholderFormat('This will force HTML-escaping of the replacement value: @text', ['@text' => (string)$safe_string_interface_object)); ❏ %variable $string = "%output_text"; $arguments = ['%output_text' => 'text output here.']; $this->placeholderFormat($string, $arguments);
  • 12. ❏ :variable $this->placeholderFormat('<a href=":url">@variable</a>', [':url' => $url, '@variable' => $variable]);
  • 16. Drupal 7 global $user; $original_user = $user; $old_state = drupal_save_session(); drupal_save_session(FALSE); $user = user_load(1); // Take your action here $user = $original_user; drupal_save_session($old_state);
  • 17. Drupal 8 $accountSwitcher = Drupal::service('account_switcher'); $account = DrupaluserEntityUser::load(2); $accountSwitcher->switchTo($account); // Take your action here. If your code fails, then you should catch an exception // and switch back (see below). // Restore user account. $accountSwitcher->switchBack();