SlideShare une entreprise Scribd logo
1  sur  23
Akash Mahajan
That Web Application Security Guy
Reduce Attack Surface



  F 117
Nighthawk




            http://en.wikipedia.org/wiki/File:F-117_Nighthawk_Front.jpg


                  #rootconf | @makash | akashm.com                        2
What is the Attack Surface


all the TCP and UDP ports listening
      on the external interfaces


 # netstat -nltup
            #rootconf | @makash | akashm.com   3
Reducing the attack surface

by stopping services from
running
      # /etc/init.d/<servicename> stop
listen on external IP
      bind-address=127.0.0.1

starting at boot time
      # update-rc.d <servicename> remove




                  #rootconf | @makash | akashm.com   4
After Reduction




  #rootconf | @makash | akashm.com   5
Mini Distro


start with a 12 MB mini iso

 install OpenSSH server
 install required LAMP packages using tasksel
 there are no compilers, extra libraries


                  #rootconf | @makash | akashm.com   6
Patching and Updates

  choose Long Term Support
release (10.04 LTS, 12.04 LTS)

one command to patch & update

 # apt-get update && apt-get upgrade

            #rootconf | @makash | akashm.com   7
Protecting Your Access




      #rootconf | @makash | akashm.com   8
Reason #1 for Hacked Linux Servers




 SSH Server Password Brute Forcing
           #rootconf | @makash | akashm.com   9
Secure Shell aka SSH

Conventional wisdom says
 don’t allow root to login

 don’t use passwords ; use keys

 only use SSH version 2.0

           #rootconf | @makash | akashm.com   10
Attack Surface in SSH
password bruteforcing requires valid users
        who are allowed to login

lot of people use keys without passphrases

make one change in /etc/sshd_config

      AllowUsers <user@Host>
              #rootconf | @makash | akashm.com   11
Files and Permissions

          Read (r)          Write (w)               Execute (x)


 User        4                        2                 1

Group        4                        -                 1

Others       4                        -                 -



  -rwxr-xr-- | 0754
                 #rootconf | @makash | akashm.com                 12
Apache Web Server

/etc/apache2/conf.d/security

line number 27 ServerTokens Prod
line number 39 ServerSignature Off




            #rootconf | @makash | akashm.com   13
MySQL Database Server

if database and web server are on
the same host, then mysql server
 should only listen on localhost
       /etc/mysql/my.cnf

    bind-address=127.0.0.1
           #rootconf | @makash | akashm.com   14
MySQL Database Server

run # mysql_secure_installation

create new user for each new database

only give
SELECT, UPDATE, INSERT, DELETE, ALT
ER, CREATE privileges to new user
new user should be for localhost and don’t give %
                 #rootconf | @makash | akashm.com   15
Uncomplicated Firewall

• ufw enabled

• ufw allow 22 // SSH Access

• ufw allow 80 // Website Access

• ufw allow 443 // Secure Website Access

• ufw default deny // Kitchen Sink

                #rootconf | @makash | akashm.com   16
Uncomplicated Firewall



ufw allow from <external DB IP> to
   <current host IP> port 3306




          #rootconf | @makash | akashm.com   17
Reference Web App Architecture



Document Root should only contain files
 that are meant to be served to the user

everything should be in a folder outside it



              #rootconf | @makash | akashm.com   18
Reference Web App Architecture


/var/www/site/public for files to serve

/var/www/site/private for config files

   keep files user as person who uploads

       Keep the group as www-data


              #rootconf | @makash | akashm.com   19
My name is list, Check List

Start from a mini iso

Remove unwanted services

Whitelist user for SSH login

MySQL users need to be protected

Default Deny and Allow Specific

               #rootconf | @makash | akashm.com   20
Wait, there is more you can do

• Logs of SSH, web servers

• Monitoring of these services

• Add whitelisted to /etc/host.allow or
 blacklisted /etc/host.deny



               #rootconf | @makash | akashm.com   21
Questions and Answers

         Akash Mahajan
That Web Application Security Guy

      http://akashm.com | @makash

  akashmahajan@gmail.com | 9980527182
References
•   Information about F1117 Nighthawk from http://en.wikipedia.org/wiki/Lockheed_F-117_Nighthawk
•   Unable to find out where I got the stair case image from. If you know please do let me know.
•   Rest of the images are from istockphoto.com




                                 #rootconf | @makash | akashm.com                             23

Contenu connexe

Plus de Akash Mahajan

Hackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web ProgrammingHackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web Programming
Akash Mahajan
 
Web application security
Web application securityWeb application security
Web application security
Akash Mahajan
 
Web application security
Web application securityWeb application security
Web application security
Akash Mahajan
 
Web application security
Web application securityWeb application security
Web application security
Akash Mahajan
 

Plus de Akash Mahajan (18)

On Writing Well - A talk given at WinjaBlogs Session
On Writing Well - A talk given at WinjaBlogs SessionOn Writing Well - A talk given at WinjaBlogs Session
On Writing Well - A talk given at WinjaBlogs Session
 
App sec in the time of docker containers
App sec in the time of docker containersApp sec in the time of docker containers
App sec in the time of docker containers
 
Venom vulnerability Overview and a basic demo
Venom vulnerability Overview and a basic demoVenom vulnerability Overview and a basic demo
Venom vulnerability Overview and a basic demo
 
Security in the cloud Workshop HSTC 2014
Security in the cloud Workshop HSTC 2014Security in the cloud Workshop HSTC 2014
Security in the cloud Workshop HSTC 2014
 
INCOMPLETE - OUTLINE for RootConf 2014 - The little-servcie-which-wasn't-there
INCOMPLETE - OUTLINE for RootConf 2014 - The little-servcie-which-wasn't-thereINCOMPLETE - OUTLINE for RootConf 2014 - The little-servcie-which-wasn't-there
INCOMPLETE - OUTLINE for RootConf 2014 - The little-servcie-which-wasn't-there
 
The real incident of stealing a droid app+data
The real incident of stealing a droid app+dataThe real incident of stealing a droid app+data
The real incident of stealing a droid app+data
 
Believe It Or Not SSL Attacks
Believe It Or Not SSL AttacksBelieve It Or Not SSL Attacks
Believe It Or Not SSL Attacks
 
I haz your mouse clicks and key strokes
I haz your mouse clicks and key strokesI haz your mouse clicks and key strokes
I haz your mouse clicks and key strokes
 
Hackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web ProgrammingHackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web Programming
 
Secure HTTP Headers c0c0n 2011 Akash Mahajan
Secure HTTP Headers c0c0n 2011 Akash MahajanSecure HTTP Headers c0c0n 2011 Akash Mahajan
Secure HTTP Headers c0c0n 2011 Akash Mahajan
 
Php security
Php securityPhp security
Php security
 
Secure passwords-theory-and-practice
Secure passwords-theory-and-practiceSecure passwords-theory-and-practice
Secure passwords-theory-and-practice
 
Top 10 web application security risks akash mahajan
Top 10 web application security risks   akash mahajanTop 10 web application security risks   akash mahajan
Top 10 web application security risks akash mahajan
 
Web application security
Web application securityWeb application security
Web application security
 
Web application security
Web application securityWeb application security
Web application security
 
Web application security
Web application securityWeb application security
Web application security
 
Secure Programming In Php
Secure Programming In PhpSecure Programming In Php
Secure Programming In Php
 
Startups Security
Startups SecurityStartups Security
Startups Security
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
+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...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
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
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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 ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
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
 

Securing A Linux Web Server In 10 steps or Less

  • 1. Akash Mahajan That Web Application Security Guy
  • 2. Reduce Attack Surface F 117 Nighthawk http://en.wikipedia.org/wiki/File:F-117_Nighthawk_Front.jpg #rootconf | @makash | akashm.com 2
  • 3. What is the Attack Surface all the TCP and UDP ports listening on the external interfaces # netstat -nltup #rootconf | @makash | akashm.com 3
  • 4. Reducing the attack surface by stopping services from running # /etc/init.d/<servicename> stop listen on external IP bind-address=127.0.0.1 starting at boot time # update-rc.d <servicename> remove #rootconf | @makash | akashm.com 4
  • 5. After Reduction #rootconf | @makash | akashm.com 5
  • 6. Mini Distro start with a 12 MB mini iso install OpenSSH server install required LAMP packages using tasksel there are no compilers, extra libraries #rootconf | @makash | akashm.com 6
  • 7. Patching and Updates choose Long Term Support release (10.04 LTS, 12.04 LTS) one command to patch & update # apt-get update && apt-get upgrade #rootconf | @makash | akashm.com 7
  • 8. Protecting Your Access #rootconf | @makash | akashm.com 8
  • 9. Reason #1 for Hacked Linux Servers SSH Server Password Brute Forcing #rootconf | @makash | akashm.com 9
  • 10. Secure Shell aka SSH Conventional wisdom says don’t allow root to login don’t use passwords ; use keys only use SSH version 2.0 #rootconf | @makash | akashm.com 10
  • 11. Attack Surface in SSH password bruteforcing requires valid users who are allowed to login lot of people use keys without passphrases make one change in /etc/sshd_config AllowUsers <user@Host> #rootconf | @makash | akashm.com 11
  • 12. Files and Permissions Read (r) Write (w) Execute (x) User 4 2 1 Group 4 - 1 Others 4 - - -rwxr-xr-- | 0754 #rootconf | @makash | akashm.com 12
  • 13. Apache Web Server /etc/apache2/conf.d/security line number 27 ServerTokens Prod line number 39 ServerSignature Off #rootconf | @makash | akashm.com 13
  • 14. MySQL Database Server if database and web server are on the same host, then mysql server should only listen on localhost /etc/mysql/my.cnf bind-address=127.0.0.1 #rootconf | @makash | akashm.com 14
  • 15. MySQL Database Server run # mysql_secure_installation create new user for each new database only give SELECT, UPDATE, INSERT, DELETE, ALT ER, CREATE privileges to new user new user should be for localhost and don’t give % #rootconf | @makash | akashm.com 15
  • 16. Uncomplicated Firewall • ufw enabled • ufw allow 22 // SSH Access • ufw allow 80 // Website Access • ufw allow 443 // Secure Website Access • ufw default deny // Kitchen Sink #rootconf | @makash | akashm.com 16
  • 17. Uncomplicated Firewall ufw allow from <external DB IP> to <current host IP> port 3306 #rootconf | @makash | akashm.com 17
  • 18. Reference Web App Architecture Document Root should only contain files that are meant to be served to the user everything should be in a folder outside it #rootconf | @makash | akashm.com 18
  • 19. Reference Web App Architecture /var/www/site/public for files to serve /var/www/site/private for config files keep files user as person who uploads Keep the group as www-data #rootconf | @makash | akashm.com 19
  • 20. My name is list, Check List Start from a mini iso Remove unwanted services Whitelist user for SSH login MySQL users need to be protected Default Deny and Allow Specific #rootconf | @makash | akashm.com 20
  • 21. Wait, there is more you can do • Logs of SSH, web servers • Monitoring of these services • Add whitelisted to /etc/host.allow or blacklisted /etc/host.deny #rootconf | @makash | akashm.com 21
  • 22. Questions and Answers Akash Mahajan That Web Application Security Guy http://akashm.com | @makash akashmahajan@gmail.com | 9980527182
  • 23. References • Information about F1117 Nighthawk from http://en.wikipedia.org/wiki/Lockheed_F-117_Nighthawk • Unable to find out where I got the stair case image from. If you know please do let me know. • Rest of the images are from istockphoto.com #rootconf | @makash | akashm.com 23

Notes de l'éditeur

  1. starting at boot time#update-rc.d &lt;servicename&gt; removelistening on external IPbind-address=127.0.0.1