Securing Apache and PHP

Slides:



Advertisements
Similar presentations
MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Advertisements

Enabling Secure Internet Access with ISA Server
WEB AND WIRELESS AUTOMATION connecting people and processes InduSoft Web Solution Welcome.
IUT– Network Security Course 1 Network Security Firewalls.
1 Web Servers / Deployment Alastair Dawes Original by Bhupinder Reehal.
Working with Proxy Servers and Application-Level Firewalls Chapter 5.
Building Your Own Firewall Chapter 10. Learning Objectives List and define the two categories of firewalls Explain why desktop firewalls are used Explain.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
System and Network Security Practices COEN 351 E-Commerce Security.
Server-Side vs. Client-Side Scripting Languages
K. Salah 1 Chapter 31 Security in the Internet. K. Salah 2 Figure 31.5 Position of TLS Transport Layer Security (TLS) was designed to provide security.
Chapter Apache Installation in Linux- Mandrake. Acknowledgment The following information has been obtained directly from
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 8: Implementing and Managing Printers.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
Apache : Installation, Configuration, Basic Security Presented by, Sandeep K Thopucherela, ECE Department.
PHP Scripting Language. Introduction “PHP” is an acronym for “PHP: Hypertext Preprocessor.” It is an interpreted, server-side scripting language. Originally.
Firewalls and VPNS Team 9 Keith Elliot David Snyder Matthew While.
Chapter 7: Working with Proxy Servers & Application-Level Firewalls
E-Commerce The technical side. LAMP Linux Linux Apache Apache MySQL MySQL PHP PHP All Open Source and free packages. Can be installed and run on most.
Network Topology. Cisco 2921 Integrated Services Router Security Embedded hardware-accelerated VPN encryption Secure collaborative communications with.
Securing LAMP: Linux, Apache, MySQL and PHP Track 2 Workshop PacNOG 7 July 1, 2010 Pago Pago, American Samoa.
Introducing LAMP: Linux, Apache, MySQL and PHP Track 2 Workshop PacNOG 7 July 1, 2010 Pago Pago, American Samoa.
FIREWALL TECHNOLOGIES Tahani al jehani. Firewall benefits  A firewall functions as a choke point – all traffic in and out must pass through this single.
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
PHP Web Development, PHP Programming
Linux Operations and Administration
By Jeerarat Boonyanit. As you can see I have chosen Cpanel for my server management tool. cPanel is a Linux based web hosting control panel that provides.
TOPIC 1 – SERVER SIDE APPLICATIONS IFS 234 – SERVER SIDE APPLICATION DEVELOPMENT.
Hands-On Microsoft Windows Server 2008 Chapter 1 Introduction to Windows Server 2008.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Penetration Testing Security Analysis and Advanced Tools: Snort.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Web Servers1-1 Web Servers Xingquan (Hill) Zhu
Brad Baker CS526 May 7 th, /7/ Project goals 2. Test Environment 3. The Problem 4. Some Solutions 5. ModSecurity Overview 6. ModSecurity.
Principles of Computer Security: CompTIA Security + ® and Beyond, Third Edition © 2012 Principles of Computer Security: CompTIA Security+ ® and Beyond,
Hands-On Microsoft Windows Server 2008 Chapter 1 Introduction to Windows Server 2008.
CIS 451: Servers, CGI and Log Files Dr. Ralph D. Westfall January, 2009.
Agenda Review route summarization Cisco acquire Sourcefire Review Final Exam.
Putting What We Learned Into Context – WSGI and Web Frameworks A290/A590, Fall /16/2014.
OS Hardening Justin Whitehead Francisco Robles. ECE Internetwork Security OS Hardening Installing kernel/software patches and configuring a system.
1 Apache. 2 Module - Apache ♦ Overview This module focuses on configuring and customizing Apache web server. Apache is a commonly used Hypertext Transfer.
SQL Queries Relational database and SQL MySQL LAMP SQL queries A MySQL Tutorial and applications Database Building.
Computer Emergency Notification System (CENS)
1 Welcome to CSC 301 Web Programming Charles Frank.
1 Topic 2: Lesson 3 Intro to Firewalls Summary. 2 Basic questions What is a firewall? What is a firewall? What can a firewall do? What can a firewall.
Fundamentals of Proxying. Proxy Server Fundamentals  Proxy simply means acting on someone other’s behalf  A Proxy acts on behalf of the client or user.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
CIS 450 – Network Security Chapter 14 – Specific Exploits for UNIX.
Module 14: Securing Windows Server Overview Introduction to Securing Servers Implementing Core Server Security Hardening Servers Microsoft Baseline.
Module 7: Advanced Application and Web Filtering.
Vulnerability Scanning Vulnerability scanners are automated tools that scan hosts and networks for known vulnerabilities and weaknesses Credentialed vs.
Security Issues with PHP  PHP installation  PHP programming Willa Zhu & Eugene Burger.
Module 10: Windows Firewall and Caching Fundamentals.
Apache Web Server Architecture Chaitanya Kulkarni MSCS rd April /23/20081Apache Web Server Architecture.
TOPIC 7.0 LINUX SERVICES AND CONFIGURATION. ROOT USER Root user is called “super user” because it has power far beyond those of mortal user. As root,
Web Security. Introduction Webserver hacking refers to attackers taking advantage of vulnerabilities inherent to the web server software itself These.
(ITI310) By Eng. BASSEM ALSAID SESSIONS 10: Internet Information Services (IIS)
Web Server Security: Protecting Your Pages NOAA OAR WebShop 2001 August 2 nd, 2001 Jeremy Warren.
Aaron Corso COSC Spring What is LAMP?  A ‘solution stack’, or package of an OS and software consisting of:  Linux  Apache  MySQL  PHP.
TMG Client Protection 6NPS – Session 7.
Relational database and SQL MySQL LAMP SQL queries
Configuration for Network Security
* Essential Network Security Book Slides.
IS3440 Linux Security Unit 9 Linux System Logging and Monitoring
Lecture 1: Multi-tier Architecture Overview
Lecture 3: Secure Network Architecture
Firewall Installation
Web Servers (IIS and Apache)
Web Application Development Using PHP
Presentation transcript:

Securing Apache and PHP Justin Mayhue and Christopher Pau

Motivation Via LAMP (Linux, Apache, MySQL, and PHP) web hosts have a popular, free OS/software solution According to Netcraft, over 47% of webservers use the Apache as of October 2007 Popularity makes for an easy target, as oftentimes configurations are not well thought-out

Who should be concerned? Webmasters – installation of scripts (permissions errors: chmod 777? 755?) Web Developers – creating software for various configurations (what is enabled? Disabled?) Web Hosts – security of their server and possible abuse Average Users – where is their data saved? Who can access it? How is it secured?

Background: Apache Free, open-source, Unix-based webserver software available for Linux, Mac OSX, Windows, and other platforms Design features revolve around modules used to control, interpret, and deliver web content to clients Supports virtual hosting – multiple users can host independent sites on the same server platform

Background: PHP PHP (PHP: Hypertext Processor) is a scripting language aimed at creating dynamic content Like Apache, it is free, open-source software available for a variety of operating systems Works with Apache to filter user input and provide content for Apache to serve back to the users

Theory: CGI Binaries CGI (Common Gateway Interface) is a protocol for exchanging information between a server and an external application Under this protocol, the external application is run upon each request (i.e., a new process is created), and this application closes after delivering output to the server PHP was originally designed to run as a set of CGI binaries #!/usr/local/bin/php

Theory: Apache Modules Rather than creating an instance of a process for every request, Apache provides functionality for persistent modules to run These modules can handle certain types of requests indefinitely without terminating PHP has been adapted to run as an Apache module, as well, and was used this way in the Web Security lab

Apache Module vs. CGI Binaries Which is optimal for running PHP? PHP as an Apache module yields speed Only one instance of PHP, the module itself, needs to be running at one time Resources such as dedicated connections to a MySQL database can be preserved across sessions Also, this allows PHP to be configured via .htaccess directives – an Apache-specific function

Apache Module vs. CGI Binaries Worker - PHP Worker - CGI PHP Worker - PHP Worker - CGI PHP Worker - PHP Worker - CGI PHP PHP Worker - PHP Worker - CGI Database and other resources Database and other resources

Apache Module vs. CGI Binaries However, Apache runs as a separate user, inheriting permissions of “nobody” -- thus all resources PHP uses must be accessible to “nobody” as well PHP as a CGI binary favors security CGI binaries can interface with an Apache module (such as suEXEC or suPHP) to run as a separate user This allows separate permissions for multiple users and multiple resource needs in a shared hosting environment

Apache Module vs. CGI Binaries User: apache (nobody) With suEXEC or suPHP Apache Apache User: file owner Worker - PHP Worker - CGI PHP Worker - PHP Worker - CGI PHP Worker - PHP Worker - CGI PHP PHP Worker - PHP Worker - CGI Database and other resources Database and other resources

Apache Module vs. CGI Binaries With suEXEC or suPHP Apache Apache User secureddata.com chroot /path/to/SecuredData.com /path/to/SecuredData.com User hackworld.com chroot /path/to/HackWorld.com /path/to/HackWorld.com /etc/passwd /etc/passwd World Readable r - x Locked per user directory Edit anything writeable r w x

PHP Safe Mode As an alternative to running PHP as a CGI binary for increased permissions security, PHP provides the Safe Mode configuration Provides user permissions security Places limitations on the file structure PHP can access (PHP fopen) Can disable the use of certain potentially vulnerable functions

PHP Safe Mode However, such restrictions are considered “architecturally incorrect” -- PHP itself is blocking and manipulating its own normal operation Can easily be bypassed if functions are allowed to execute on command line exec(“cat stuff >> /etc/passwd”) Will not be included in future versions PHP 6 and beyond Still, frequently used by many hosts

Alternative Solutions: ModSecurity ModSecurity is an Apache module designed as a web application firewall Operates at application layer Protocol-level firewalls used in routers and gateway-level machines usually filter traffic based on source and destination ModSecurity is generally used to filter traffic based upon the contents – including both the headers and payload data Rules-based, applied before sending traffic to handling application or module

Alternative Solutions: ModSecurity Default rules block Protocol violations Protocol anomalies Request Limits Http Policy Bad Robots Generic Attacks Trojans Outbound Connections

Alternative Solution: Suhosin and PHP-Hardening Patch Provides a third-party alternative to manual configuration solutions previously discussed Protects against known vulnerabilities such as buffer overflows, as well as PHP core vulnerabilities that could potentially be exploited Similar in concept to libsafe and other patch-based protection schemes

In the Lab Part I: Analyze PHP as an Apache module and Safe Mode as a security option Part II: Analyze PHP as a CGI binary and suPHP as a flexibility extension Part III: Explore mod_security as an application-layer firewall solution to security exploits

Part I: Apache Module PHP is already installed in lab as an Apache module from Web Security lab grabfile.php and newfile.php: test PHP's permissions for reading, writing, and modifying files

Part I: Apache Module Permission issue example: separate user, ftpuser, attempting to modify an example file written by PHP/Apache

Part I: Safe Mode Safe Mode is then enabled via php.ini, and the tests repeated, as well as including remote scripts in PHP files

Part II: PHP as a CGI Binary Apache is then installed as a CGI binary, and http.conf is modified accordingly The tests are then repeated – still runs as “nobody” user

Part II: suPHP suPHP is then installed, and tests run again In this case, scripts are set to run as their owner, thus ftpuser can modify file created by its own scripts

Part III: ModSecurity mod_security is then installed, and a few example rules are given A number of previous exploits are then attempted, and the results examined

Conclusions PHP run as an Apache module and as a CGI binary both have benefits and drawbacks Specific implementation depends upon the needs of the host, and of the webmasters using the host

Conclusions Companies and individuals should be familiar with the global platform and configuration of their chosen hosts Especially in shared hosting environments, users may not have the option of changing their configuration at will

Conclusions Hosts should be aware of the pros and cons of the hosting configuration(s) they offer, and be prepared to deal with updates For instance, PHP as an Apache module running in safe mode is very prevalent, but will soon be phased out – hosts must deal with this change

Questions?