Secure coding in PHP

3 nap
210 000 Ft + ÁFA
tanfolyamkezdési időpontok:

A tanfolyam célja

The course provides essential skills for PHP developers necessary to make their applications resistant to contemporary attacks through the Internet. Web vulnerabilities are discussed through PHP-based examples going beyond the OWASP top ten, tackling various injection attacks, script injections, attacks against session handling of PHP, insecure direct object references, issues with file upload, and many others. PHP-related vulnerabilities are introduced grouped into the standard vulnerability types of missing or improper input validation, incorrect error and exception handling, improper use of security features and time- and state-related problems. For this latter we discuss attacks like the open_basedir circumvention, denial-of-service through magic float or the hash table collision attack. In all cases participants will get familiar with the most important techniques and functions to be used to mitigate the enlisted risks.

A special focus is given to client-side security tackling security issues of JavaScript, Ajax and HTML5. A number of security-related extensions to PHP are introduced like hash, mcrypt and OpenSSL for cryptography, or Ctype, ext/filter and HTML Purifier for input validation. Hardening best practices are given in connection with PHP configuration (setting php.ini), Apache and the server in general. Finally, an overview is given to various security testing tools and techniques which developers and testers can use, including security scanners, penetration testing and exploit packs, sniffers, proxy servers, fuzzing tools and static source code analyzers.

Both the introduction of vulnerabilities and the configuration practices are supported by a number of hands-on exercises demonstrating the consequences of successful attacks, showing how to apply mitigation techniques and introducing the use of various extensions and tools.

  •     Understand basic concepts of security, IT security and secure coding
  •     Learn Web vulnerabilities beyond OWASP Top Ten and know how to avoid them
  •     Learn about XML security
  •     Learn client-side vulnerabilities and secure coding practices
  •     Learn to use various security features of PHP
  •     Have a practical understanding of cryptography
  •     Learn how to set up and operate the deployment environment securely
  •     Learn about denial of service attacks and protections
  •     Learn about typical coding mistakes and how to avoid them
  •     Be informed about recent vulnerabilities of the PHP framework
  •     Get sources and further readings on secure coding practices


  •     IT security and secure coding
  •     Web application security
  •     Client-side security
  •     Practical cryptography
  •     Deployment environment
  •     Denial of service
  •     Common coding errors and vulnerabilities
  •     XML security
  •     Principles of security and secure coding
  •     Knowledge sources

1. IT security and secure coding

  •         Nature of security
  •         What is risk?
  •         IT security vs. secure coding
  •         From vulnerabilities to botnets and cybercrime
    •             Nature of security flaws
    •             Reasons of difficulty
    •             From an infected computer to targeted attacks
    •             The Seven Pernicious Kingdoms
    •             OWASP Top Ten 2017

    Web application security

  •         Injection
    •             Injection principles
    •             SQL injection
      •                 Exercise – SQL Injection
      •                 Exercise – SQL injection
      •                 Typical SQL Injection attack methods
      •                 Blind and time-based SQL injection
      •                 SQL injection protection methods
      •                 SQL injection protection in PHP
    •             Other injection flaws
      •                 Command injection
      •                 Command injection exercise – starting Netcat
      •                 Case study – ImageMagick
      •                 Cookie injection / HTTP parameter pollution
  •         Broken authentication
    •             Session handling threats
    •             Session data handling in PHP
    •             Exercise – Exploiting week session data handling
    •             Session handling best practices
    •             Setting cookie attributes – best practices
  •         Sensitive data exposure
    •             Sensitive data exposure
    •             Transport layer security
  •         XML external entity (XXE)
    •             XML Entity introduction
    •             XML bomb
    •             XML external entity attack (XXE) – resource inclusion
    •             XML external entity attack – URL invocation
    •             XML external entity attack – parameter entities
    •             Case study – XXE in Google Toolbar
  •         Broken access control
    •             Typical access control weaknesses
    •             Insecure direct object reference (IDOR)
    •             Exercise – Insecure direct object reference
    •             Protection against IDOR
    •             Case study – Facebook Notes
  •         Security misconfiguration
    •             Security misconfiguration
    •             Configuring the PHP environment
    •             Setting manipulation in PHP
    •             Insecure file uploads
    •             Exercise – Uploading executable files
    •             Filtering file uploads – validation and configuration
  •         Cross-Site Scripting (XSS)
    •             Persistent XSS
    •             Reflected XSS
    •             DOM-based XSS
    •             Exercise – Cross Site Scripting
    •             Exploitation: CSS injection
    •             Exploitation: injecting the tag
    •             Exercise – HTML injection with base tag
    •             XSS prevention
  •         Insecure deserialization
    •             Deserialization basics
    •             Security challenges of deserialization
    •             From deserialization to code execution
    •             Issues with deserialization – JSON

2. Client-side security

  •         JavaScript security
  •         Same Origin Policy
  •         Cross Origin Resource Sharing (CORS)
  •         Exercise – Client-side authentication
  •         Client-side authentication and password management
  •         Protecting JavaScript code
  •         Exercise – JavaScript obfuscation
  •         Clickjacking
    •             Clickjacking
    •             Exercise – Do you Like me?
    •             Protection against Clickjacking
    •             Anti frame-busting – dismissing protection scripts
    •             Protection against busting frame busting
  •         AJAX security
    •             XSS in AJAX
    •             Script injection attack in AJAX
    •             Exercise – XSS in AJAX
    •             XSS protection in Ajax
    •             Exercise CSRF in AJAX – JavaScript hijacking
    •             CSRF protection in AJAX
  •         HTML5 security
    •             New XSS possibilities in HTML5
    •             HTML5 clickjacking attack – text field injection
    •             HTML5 clickjacking – content extraction
    •             Form tampering
    •             Exercise – Form tampering
    •             Cross-origin requests
    •             HTML proxy with cross-origin request
    •             Exercise – Client side include

    Practical cryptography

  •         Cryptosystems
    •             Elements of a cryptosystem
  •         Symmetric-key cryptography
    •             Providing confidentiality with symmetric cryptography
    •             Symmetric encryption algorithms
    •             Block ciphers – modes of operation
  •         Other cryptographic algorithms
    •             Hash or message digest
    •             Hash algorithms
    •             SHAttered
    •             Message Authentication Code (MAC)
    •             Providing integrity and authenticity with a symmetric key
    •             Random numbers and cryptography
    •             Cryptographically-strong PRNGs
    •             Hardware-based TRNGs
  •         Asymmetric (public-key) cryptography
    •             Providing confidentiality with public-key encryption
    •             Rule of thumb – possession of private key
    •             The RSA algorithm
    •                 Introduction to RSA algorithm
    •                 Encrypting with RSA
    •                 Combining symmetric and asymmetric algorithms
    •                 Digital signing with RSA
  •         Public Key Infrastructure (PKI)
    •             Man-in-the-Middle (MitM) attack
    •             Digital certificates against MitM attack
    •             Certificate Authorities in Public Key Infrastructure
    •             X.509 digital certificate
  •         Cryptography in PHP
    •             hash
    •             mcrypt
    •             openssl

    Deployment environment

  •         Configuration management
  •         Hardening
  •         Server virtualization
  •         PHP Suhosin
  •         Patch management
  •         PHP configuration
    •             php.ini settings – Information disclosure
    •             php.ini settings – Resource limits
    •             php.ini settings – Session handling
    •             php.ini settings – Other security related
    •             Apache settings

    Denial of service

  •         DoS introduction
  •         Asymmetric DoS
  •         SSL/TLS renegotiation DoS
  •         Case Study – ReDos in Stack Exchange
  •         Hashtable collision attack
    •             Using hashtables to store inputs
    •             Hashtable collision
    •             Hashtable collision in PHP
    •             Fix for the hashtable collision attack

 3. Common coding errors and vulnerabilities

  •             Input validation
    •                 Input validation concepts
    •                 Path traversal vulnerability
      •                     Path traversal
      •                     Path traversal mitigation
      •                     Case study – Insufficient URL validation in LastPass
    •                 Unvalidated redirects and forwards
    •                 Log forging
      •                     Some other typical problems with log files
  •             Input validation and escaping APIs in PHP
    •                 Basic input validation functions
    •                 Escaping in PHP
    •                 PHP input validation extensions
      •                     PHP input validation extensions
      •                     CType
      •                     ext/filter
    •                 Arbitrary code execution
      •                     Arbitrary code execution
      •                     Dangerous functions regarding remote code execution
      •                     Exercise CodeExec –Remote PHP code execution
      •                     Exercise: exploiting preg_replace
    •                 MySQL validation errors – beyond SQL Injection
      •                     Issues with max_packet_size
      •                     MySQL column truncation
      •                     MySQL validation best practices

        XML security

  •             Introduction
  •             XML parsing
  •             XML injection
    •                 (Ab)using CDATA to store XSS payload in XML
  •             XML Signature
    •                 XML Signature introduction
    •                 XML Signature structure
    •                 Hash collision with XML Digital Signature
    •                 XML canonicalization
    •                 Signing XML documents – spot the bug!
    •                 XML Signature Wrapping (XSW) attack
    •                 XML Signature Wrapping – countermeasures

        Common coding errors and vulnerabilities

  •             Improper use of security features
    •                 Typical problems related to the use of security features
    •                 Insecure randomness
      •                     Weak PRNGs in PHP
      •                     Stronger PRNGs in PHP
      •                     Exercise RandomTest
      •                     Using random numbers in PHP – spot the bug!
    •                 Password management
      •                     Exercise – Weakness of hashed passwords
      •                     Password management and storage
      •                     Special purpose hash algorithms for password storage
      •                     Storing credentials for external systems in PHP
      •                     Case study – the Ashley Madison data breach
  •             Improper error and exception handling
    •                 Typical problems with error and exception handling
    •                 Empty catch block
    •                 Overly broad catch
    •                 Information leakage through error reporting
    •                 Exercise – Information leakage through error reporting
    •                 Error handling best practices
  •             Time and state problems
    •                 Concurrency and threading
    •                 Concurrency in PHP
    •                 Spot the bug – Race condition with files
    •                 Exercise – Race condition with files
    •                 Preventing file race condition
    •                 Double submit problem
    •                 PHP session handling
    •                 A PHP design flaw – open_basedir race condition
    •                 Database race condition
    •                 Optimistic vs. pessimistic locking
  •             Code quality
    •                 PHP variable initialization problems
    •                 PHP type comparison rules
    •                 Magic float
      •                     Magic float

        Principles of security and secure coding

  •             Matt Bishop’s principles of robust programming
  •             The security principles of Saltzer and Schroeder

        Knowledge sources

  •             Secure coding sources – a starter kit
  •             Vulnerability databases
  •             PHP secure coding guidelines and sources – a compilation
  •             Cheat sheets
  •             Recommended books – PHP


Kinek ajánljuk


Advanced Web application development

Kapcsolódó tanfolyamok

Ajánlja másoknak is!