SlideShare a Scribd company logo
1 of 31
Download to read offline
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Webinar series: PHP security best practices
Part 1: Web security best practices for PHP
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
PHPsecuritybestpracticesPHPsecuritybestpractices
by Daryl Wood
Senior Technical Trainer
Webinar, March 25, 2019
Rogue Wave Software, Inc.
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
PHPapplicationsecurityPHPapplicationsecurity
BestpracticefundamentalsBestpracticefundamentals
Security attack types
Log monitoring
Attack injection
Attack severities and impacts
PHP version end of life
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
AttackseveritiesandimpactsAttackseveritiesandimpacts
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
AttackseveritiesAttackseverities
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
AttackimpactsAttackimpacts
Impacts of injection success include:
Data loss, corruption, access denial, or complete host takeover
Lack of accountability
Bad public relations
Litigation expense
Web site front-facing impacts
Account(s) compromise
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Injectionandattacktypes(limited)Injectionandattacktypes(limited)
Some of the most common attacks or vulnerabilities include:
Cross-site scripting (XSS)
SQL injection
Broken session management
Brute force
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
InjectionInjection
Injection is an attempt to insert something nefarious into an
application. It can:
Allow malicious code pass through
Include system calls
Include whole scripts
Cause an interpreter to execute unauthorized code
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Cross-sitescripting(XSS)Cross-sitescripting(XSS)
An injection of script code, typically JavaScript, into an application from
an outside client.
This vulnerability occurs when input data is used without proper
ltering, validation, and escaping.
Two types of XSS (can occur on a server or client):
Stored
Re ected
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Cross-sitescripting(XSS)Cross-sitescripting(XSS)
AstoredvulnerableexampleAstoredvulnerableexample
$_POST['username'] = 'pablo';
$_POST['comment'] = '<script>alert("document.cookie")</script>';
if($_POST) {
$result = null;
try {
$pdo = new PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=blog',
'vagrant', 'vagrant');
$stmt = $pdo->query("INSERT INTO blog (username, comment) VALUES ({$_POST['username']},
{$_POST['comment']})");
if($stmt) $stmt->execute();
// Then subsequently
$result = $pdo->exec("SELECT * FROM blog WHERE username='{$_POST['username']}'");
} catch (Throwable $e){
// Handle ...
}
if($result){
echo $result['comment'];
}
}
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
SQLinjectionSQLinjection
SQL injection de nes an attempt to inject some amount of SQL, or any
database interface language, in input data from a client.
It attempts to execute unauthorized database actions on a database
server.
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
SQLinjectionSQLinjection
AvulnerabledodeexampleAvulnerabledodeexample
But, what if the Id parameter looks like this:
if ($_GET && isset($_GET['Submit'])) {
1.
//Employ ACL to determine access
try {
$pdo = new PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=blog',
'vagrant', 'vagrant');
$stmt = $pdo->query("SELECT first_name, last_name FROM blog
WHERE user_id = '{$_GET['id']}'");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Handle ...
}
}
;update blog set username = attacker where user_id = 1;
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
BrokensessionmanagementBrokensessionmanagement
Broken session management can allow unauthorized attackers access
to privileged account data. When this happens:
Account(s) are compromised
Can allow further exploitation
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
BrokensessionmanagementBrokensessionmanagement
AvulnerablecodeexampleAvulnerablecodeexample
class LoginController {
// ...
public function logoutAction() {
$this->view->setTemplate('login');
$this->view->render();
}
// ...
}
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
BruteforceBruteforce
A brute force attack is an attempt to break authentication.
The brute force attacker tries every character/special
character/symbol/number mutation possible until successful.
Robotic
Attempts to identify authentication mechanism
Good at covering tracks
Success is a not a matter of if, but when?
Extremely dangerous on success
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
BruteforceBruteforce
AvulnerablecodeexampleAvulnerablecodeexample
if($_POST && isset( $_POST['Login'] ) ) {
$username = $_POST['username'];
$password = md5($_POST['password']);
try{
$stmt = $this->getPdo()->query("SELECT * FROM users
WHERE username='$username' AND password='$password'");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
}catch(PDOException $e){
// Handle ...
}
if( $result && count($result) ) {
// Login Successful
echo "<p>Welcome to the password protected area " . $user . "</p>";
} else {
//Login failed
echo "<pre><br>Username and/or password incorrect.</pre>";
}
}
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
LogmonitoringLogmonitoring
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
LogmonitoringLogmonitoring
Log monitoring is all about keeping an eye on what's being attacked,
from where, and sometimes by whom.
This section includes:
Log location
Enabling
Monitoring tools
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
LoglocationLoglocation
Where are the logs? This is dependant on your server's OS. Here are
locations for a Debian-based Linux server using the Apache web server:
Syslog: /var/log/syslog
Apache access: /var/log/apache2/access.log
Apache error: /var/log/apache2/error.log
PHP error When enabled, and by default, is the syslog.
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
LogmonitoringLogmonitoring
LogEntryExamplesLogEntryExamples
A cut from a Debian-based Linux syslog:
A cut from an Apache access log:
A cut from an Apache error log:
Mar 15 09:58:40 linux systemd[1]: Timed out waiting for device
dev-disk-byx2did-usbx2dWDC_WD10_02FAEXx2d00Z3A0_152D00539000x2d0:0x2dpart1.device.
127.0.0.1 - - [14/Mar/2019:08:10:14 -0700] "GET / HTTP/1.1" 200 1330 "-"
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0"
[Fri Mar 15 08:11:41.867281 2019] [mpm_prefork:notice] [pid 1473]
AH00169: caught SIGTERM, shutting down
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
EnablingPHPerrorloggingEnablingPHPerrorlogging
PHP application error logging is not enabled by default. Enabeling in a
Debian-based Linux PHP installation for apache looks like this:
The le location: /etc/php/<version>/<parser type>/php.ini.
...
; Besides displaying errors, PHP can also log errors to locations such as a
; server-specific log, STDERR, or a location specified by the error_log
; directive found below. While errors should not be displayed on productions
; servers they should still be monitored and logging is a great way to do that.
; Default Value: Off
; Development Value: On
; Production Value: On
; http://php.net/log-errors
log_errors = On
...
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
MonitoringtoolsMonitoringtools
Include:
Framework tools
Third party library (https://packagist.org)
Third party service
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
PHPversionend-of-lifePHPversionend-of-life
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
PHPversionend-of-lifePHPversionend-of-life
PHP servers must be kept up to date, and a formal process established
to a ect that update.
Version end of life means that support for:
Bug xes will cease
Security xes will cease
System optimizations will cease
System monitoring might be impacted and fail to function correctly, if
at all.
Being proactive with version updates will help prevent problems!
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
RecapRecap
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
RecapRecap
Let's recap:
Attack severities and their technical and business impacts.
A limited set of injection and attack types.
Logging importance and some monitoring information.
The risks of PHP version end of life.
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Whatelse?Whatelse?
Oh, and, we never mentioned:
Cross site request forgery
Remote code injection
Command injection
Man-in-the-middle attacks
How to target log for severities
And more...
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
What'snext?What'snext?
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
StaytunedStaytuned
Additional resources:
PHP Security, support and migration: zend.com/phpsecurity
Training, PHP security and more: zend.com/en/services/training
Don't forget to join this webinar where weโ€™ll dive a little deeper into the
PHP security best practices with code xes!
April25th:PHPsecuritybestpracticescontinuesApril25th:PHPsecuritybestpracticescontinues
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Q&AQ&A
ยฉ 2019 Rogue Wave Software, Inc. All rights reserved
Thankyou!Thankyou!
Contact Ryan: ryan.krszjzaniek@roguewave.com
Contact Daryl: daryl.wood@roguewave.com
Follow me on Twitter: @datashuttle

More Related Content

More from Zend by Rogue Wave Software

Ongoing management of your PHP 7 application
Ongoing management of your PHP 7 applicationOngoing management of your PHP 7 application
Ongoing management of your PHP 7 applicationZend by Rogue Wave Software
ย 
Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7Zend by Rogue Wave Software
ย 
The Docker development template for PHP
The Docker development template for PHPThe Docker development template for PHP
The Docker development template for PHPZend by Rogue Wave Software
ย 
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i  Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i Zend by Rogue Wave Software
ย 
Standard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend ServerStandard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend ServerZend by Rogue Wave Software
ย 
Dev & Prod - PHP Applications in the Cloud
Dev & Prod - PHP Applications in the CloudDev & Prod - PHP Applications in the Cloud
Dev & Prod - PHP Applications in the CloudZend by Rogue Wave Software
ย 
The Truth about Lambdas and Closures in PHP
The Truth about Lambdas and Closures in PHPThe Truth about Lambdas and Closures in PHP
The Truth about Lambdas and Closures in PHPZend by Rogue Wave Software
ย 

More from Zend by Rogue Wave Software (20)

Middleware web APIs in PHP 7.x
Middleware web APIs in PHP 7.xMiddleware web APIs in PHP 7.x
Middleware web APIs in PHP 7.x
ย 
Ongoing management of your PHP 7 application
Ongoing management of your PHP 7 applicationOngoing management of your PHP 7 application
Ongoing management of your PHP 7 application
ย 
Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7
ย 
The Docker development template for PHP
The Docker development template for PHPThe Docker development template for PHP
The Docker development template for PHP
ย 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
ย 
Unit testing for project managers
Unit testing for project managersUnit testing for project managers
Unit testing for project managers
ย 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
ย 
Deploying PHP apps on the cloud
Deploying PHP apps on the cloudDeploying PHP apps on the cloud
Deploying PHP apps on the cloud
ย 
Data is dead. Long live data!
Data is dead. Long live data! Data is dead. Long live data!
Data is dead. Long live data!
ย 
Optimizing performance
Optimizing performanceOptimizing performance
Optimizing performance
ย 
Resolving problems & high availability
Resolving problems & high availabilityResolving problems & high availability
Resolving problems & high availability
ย 
Developing apps faster
Developing apps fasterDeveloping apps faster
Developing apps faster
ย 
Keeping up with PHP
Keeping up with PHPKeeping up with PHP
Keeping up with PHP
ย 
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i  Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i
ย 
Getting started with PHP on IBM i
Getting started with PHP on IBM iGetting started with PHP on IBM i
Getting started with PHP on IBM i
ย 
Continuous Delivery e-book
Continuous Delivery e-bookContinuous Delivery e-book
Continuous Delivery e-book
ย 
Standard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend ServerStandard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend Server
ย 
Dev & Prod - PHP Applications in the Cloud
Dev & Prod - PHP Applications in the CloudDev & Prod - PHP Applications in the Cloud
Dev & Prod - PHP Applications in the Cloud
ย 
The Truth about Lambdas and Closures in PHP
The Truth about Lambdas and Closures in PHPThe Truth about Lambdas and Closures in PHP
The Truth about Lambdas and Closures in PHP
ย 
Application Deployment on IBM i
Application Deployment on IBM iApplication Deployment on IBM i
Application Deployment on IBM i
ย 

Recently uploaded

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
ย 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
ย 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
ย 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
ย 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
ย 
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...Steffen Staab
ย 
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธcall girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธDelhi Call girls
ย 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
ย 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
ย 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
ย 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
ย 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
ย 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
ย 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
ย 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
ย 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
ย 

Recently uploaded (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
ย 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
ย 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
ย 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
ย 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
ย 
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
ย 
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธcall girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
ย 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
ย 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
ย 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
ย 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
ย 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
ย 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
ย 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
ย 
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS LiveVip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
ย 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
ย 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
ย 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
ย 

Web security best practices for PHP

  • 1. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Webinar series: PHP security best practices Part 1: Web security best practices for PHP
  • 2. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved PHPsecuritybestpracticesPHPsecuritybestpractices by Daryl Wood Senior Technical Trainer Webinar, March 25, 2019 Rogue Wave Software, Inc.
  • 3. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved PHPapplicationsecurityPHPapplicationsecurity BestpracticefundamentalsBestpracticefundamentals Security attack types Log monitoring Attack injection Attack severities and impacts PHP version end of life
  • 4. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved AttackseveritiesandimpactsAttackseveritiesandimpacts
  • 5. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved AttackseveritiesAttackseverities
  • 6. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved AttackimpactsAttackimpacts Impacts of injection success include: Data loss, corruption, access denial, or complete host takeover Lack of accountability Bad public relations Litigation expense Web site front-facing impacts Account(s) compromise
  • 7. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Injectionandattacktypes(limited)Injectionandattacktypes(limited) Some of the most common attacks or vulnerabilities include: Cross-site scripting (XSS) SQL injection Broken session management Brute force
  • 8. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved InjectionInjection Injection is an attempt to insert something nefarious into an application. It can: Allow malicious code pass through Include system calls Include whole scripts Cause an interpreter to execute unauthorized code
  • 9. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Cross-sitescripting(XSS)Cross-sitescripting(XSS) An injection of script code, typically JavaScript, into an application from an outside client. This vulnerability occurs when input data is used without proper ltering, validation, and escaping. Two types of XSS (can occur on a server or client): Stored Re ected
  • 10. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Cross-sitescripting(XSS)Cross-sitescripting(XSS) AstoredvulnerableexampleAstoredvulnerableexample $_POST['username'] = 'pablo'; $_POST['comment'] = '<script>alert("document.cookie")</script>'; if($_POST) { $result = null; try { $pdo = new PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=blog', 'vagrant', 'vagrant'); $stmt = $pdo->query("INSERT INTO blog (username, comment) VALUES ({$_POST['username']}, {$_POST['comment']})"); if($stmt) $stmt->execute(); // Then subsequently $result = $pdo->exec("SELECT * FROM blog WHERE username='{$_POST['username']}'"); } catch (Throwable $e){ // Handle ... } if($result){ echo $result['comment']; } }
  • 11. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved SQLinjectionSQLinjection SQL injection de nes an attempt to inject some amount of SQL, or any database interface language, in input data from a client. It attempts to execute unauthorized database actions on a database server.
  • 12. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved SQLinjectionSQLinjection AvulnerabledodeexampleAvulnerabledodeexample But, what if the Id parameter looks like this: if ($_GET && isset($_GET['Submit'])) { 1. //Employ ACL to determine access try { $pdo = new PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=blog', 'vagrant', 'vagrant'); $stmt = $pdo->query("SELECT first_name, last_name FROM blog WHERE user_id = '{$_GET['id']}'"); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { // Handle ... } } ;update blog set username = attacker where user_id = 1;
  • 13. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved BrokensessionmanagementBrokensessionmanagement Broken session management can allow unauthorized attackers access to privileged account data. When this happens: Account(s) are compromised Can allow further exploitation
  • 14. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved BrokensessionmanagementBrokensessionmanagement AvulnerablecodeexampleAvulnerablecodeexample class LoginController { // ... public function logoutAction() { $this->view->setTemplate('login'); $this->view->render(); } // ... }
  • 15. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved BruteforceBruteforce A brute force attack is an attempt to break authentication. The brute force attacker tries every character/special character/symbol/number mutation possible until successful. Robotic Attempts to identify authentication mechanism Good at covering tracks Success is a not a matter of if, but when? Extremely dangerous on success
  • 16. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved BruteforceBruteforce AvulnerablecodeexampleAvulnerablecodeexample if($_POST && isset( $_POST['Login'] ) ) { $username = $_POST['username']; $password = md5($_POST['password']); try{ $stmt = $this->getPdo()->query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); }catch(PDOException $e){ // Handle ... } if( $result && count($result) ) { // Login Successful echo "<p>Welcome to the password protected area " . $user . "</p>"; } else { //Login failed echo "<pre><br>Username and/or password incorrect.</pre>"; } }
  • 17. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved LogmonitoringLogmonitoring
  • 18. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved LogmonitoringLogmonitoring Log monitoring is all about keeping an eye on what's being attacked, from where, and sometimes by whom. This section includes: Log location Enabling Monitoring tools
  • 19. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved LoglocationLoglocation Where are the logs? This is dependant on your server's OS. Here are locations for a Debian-based Linux server using the Apache web server: Syslog: /var/log/syslog Apache access: /var/log/apache2/access.log Apache error: /var/log/apache2/error.log PHP error When enabled, and by default, is the syslog.
  • 20. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved LogmonitoringLogmonitoring LogEntryExamplesLogEntryExamples A cut from a Debian-based Linux syslog: A cut from an Apache access log: A cut from an Apache error log: Mar 15 09:58:40 linux systemd[1]: Timed out waiting for device dev-disk-byx2did-usbx2dWDC_WD10_02FAEXx2d00Z3A0_152D00539000x2d0:0x2dpart1.device. 127.0.0.1 - - [14/Mar/2019:08:10:14 -0700] "GET / HTTP/1.1" 200 1330 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0" [Fri Mar 15 08:11:41.867281 2019] [mpm_prefork:notice] [pid 1473] AH00169: caught SIGTERM, shutting down
  • 21. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved EnablingPHPerrorloggingEnablingPHPerrorlogging PHP application error logging is not enabled by default. Enabeling in a Debian-based Linux PHP installation for apache looks like this: The le location: /etc/php/<version>/<parser type>/php.ini. ... ; Besides displaying errors, PHP can also log errors to locations such as a ; server-specific log, STDERR, or a location specified by the error_log ; directive found below. While errors should not be displayed on productions ; servers they should still be monitored and logging is a great way to do that. ; Default Value: Off ; Development Value: On ; Production Value: On ; http://php.net/log-errors log_errors = On ...
  • 22. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved MonitoringtoolsMonitoringtools Include: Framework tools Third party library (https://packagist.org) Third party service
  • 23. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved PHPversionend-of-lifePHPversionend-of-life
  • 24. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved PHPversionend-of-lifePHPversionend-of-life PHP servers must be kept up to date, and a formal process established to a ect that update. Version end of life means that support for: Bug xes will cease Security xes will cease System optimizations will cease System monitoring might be impacted and fail to function correctly, if at all. Being proactive with version updates will help prevent problems!
  • 25. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved RecapRecap
  • 26. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved RecapRecap Let's recap: Attack severities and their technical and business impacts. A limited set of injection and attack types. Logging importance and some monitoring information. The risks of PHP version end of life.
  • 27. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Whatelse?Whatelse? Oh, and, we never mentioned: Cross site request forgery Remote code injection Command injection Man-in-the-middle attacks How to target log for severities And more...
  • 28. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved What'snext?What'snext?
  • 29. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved StaytunedStaytuned Additional resources: PHP Security, support and migration: zend.com/phpsecurity Training, PHP security and more: zend.com/en/services/training Don't forget to join this webinar where weโ€™ll dive a little deeper into the PHP security best practices with code xes! April25th:PHPsecuritybestpracticescontinuesApril25th:PHPsecuritybestpracticescontinues
  • 30. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Q&AQ&A
  • 31. ยฉ 2019 Rogue Wave Software, Inc. All rights reserved Thankyou!Thankyou! Contact Ryan: ryan.krszjzaniek@roguewave.com Contact Daryl: daryl.wood@roguewave.com Follow me on Twitter: @datashuttle