Backup File Artifacts The Underrated Web Danger TESTING AND EXPLOITING BFA WITH BFAC By: Mazin mazin AT mazinahmed DOT net.

Slides:



Advertisements
Similar presentations
WordPress Installation for Beginners Sheila Bergman
Advertisements

Implementing Tableau Server in an Enterprise Environment
3.02H Publishing a Website 3.02 Develop webpages..
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Tutorial 6 Creating a Web Form
Server-Side vs. Client-Side Scripting Languages
INSTALLATION OF WORDPRESS. WORDPRESS WordPress is an open source CMS, often used as a blog publishing application powered by PHP and MySQL. It has many.
Website Development with PHP and MySQL Introduction.
The OWASP Foundation Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under.
G51FSE Version Control Naisan Benatar. Lecture 5 - Version Control 2 On today’s menu... The problems with lots of code and lots of people Version control.
Presenter Deddie Tjahjono.  Introduction  Website Application Layer  Why Web Application Security  Web Apps Security Scanner  About  Feature  How.
Sharepoint Portal Server Basics. Introduction Sharepoint server belongs to Microsoft family of servers Integrated suite of server capabilities Hosted.
SEEM4570: XAMPP, Eclipse, Summary of Html Kangfei Zhao Room 711,ERB
Nikto LUCA ALEXANDRA ADELA. Nikto  Web server assessment tool  Written by Chris Solo and David Lodge  Released on December 27, 2001  Stable release:
W3af LUCA ALEXANDRA ADELA – MISS 1. w3af  Web Application Attack and Audit Framework  Secures web applications by finding and exploiting web application.
9.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
Creating a Web Presence Introduction to WordPress Week 1.
Linux Operations and Administration
1 Infrastructure Hardening. 2 Objectives Why hardening infrastructure is important? Hardening Operating Systems, Network and Applications.
Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Exploring Microsoft Office Word 2007 Chapter 7 The Advanced User Robert Grauer, Keith Mulbery,
Raven Services Update December 2003 David Wallis Senior Systems Consultant Raven Computers Ltd.
Instant Messaging for the Workplace A pure collaborative communication tool that does not distract users from their normal activities.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
Section 11: Implementing Software Restriction Policies and AppLocker What Is a Software Restriction Policy? Creating a Software Restriction Policy Using.
Web Applications Testing By Jamie Rougvie Supported by.
Samba – Good Just Keeps Getting Better The new and not so new features available in Samba, and how they benefit your organization. Copyright 2002 © Dustin.
Prepared by: Steve Teo Contributors: Tong Huu Khiem.
Module 8 : Configuration II Jong S. Bok
Web Security Group 5 Adam Swett Brian Marco. Why Web Security? Web sites and web applications constantly growing Complex business applications are now.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
+ Publishing Your First Post USING WORDPRESS. + A CMS (content management system) is an application that allows you to publish, edit, modify, organize,
Windows Vista Configuration MCTS : Internet Explorer 7.0.
How to Use an Android Tablet Well Come To You few Steps For How to Use an Android Tablet?
Web Content And Customer Relationship Management Solution. Transforming web sites into a customer-focused, revenue generating channel with less stress.
Wordpress Overview Wordpress is an open-source and free Web publishing application, content management system( CMS) and blogging tool built by a community.
GIT Version control. Version Control Sharing code via a centralized DB Also provides for Backtracking (going back to a previous version of code), Branching.
Security on the Internet Norman White ©2001. Security What is it? Confidentiality – Can my information be stolen? Integrity – Can it be changed? Availability.
Lesson 13 PROTECTING AND SHARING DOCUMENTS
Bug Bounty Hunting for Companies & Researchers
Introduction to Barracuda IM Firewall
CS5220 Advanced Topics in Web Programming Version Control with Git
Subversion Subversion is a brand of version control software that is frequently used to store the code and documentation of a project so as to permit.
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Development Environment
3.02H Publishing a Website 3.02 Develop webpages..
Project Management: Messages
SECTION 1: Add-ons to PowerPoint
Git & Github Timothy McRoy.
Jason Bury Dylan Drake Rush Corey Watt
Tutorial 2 Programming Editors Recommendation & Cordova Plugin Installation and Management Li Xu Department of Systems Engineering.
Version Control with Subversion
Common Methods Used to Commit Computer Crimes
LECTURE 2: Software Configuration Management
Content Management System
A Security Review Process for Existing Software Applications
CO6025 Advanced Programming
PHP / MySQL Introduction
Lesson 13 PROTECTING AND SHARING DOCUMENTS
How to Use Members Area of The Ninety-Nines Website
LECTURE 3: Software Configuration Management
Using K2 applications How can users interact with K2 applications?
JENKINS TIPS Ideas for making your life with Jenkins easier
4.02 Develop web pages using various layouts and technologies.
Git CS Fall 2018.
4.02 Develop web pages using various layouts and technologies.
Security Principles and Policies CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Web Application Development Using PHP
SHELLSHOCK ATTACK.
Presentation transcript:

Backup File Artifacts The Underrated Web Danger TESTING AND EXPLOITING BFA WITH BFAC By: Mazin mazin AT mazinahmed DOT net

WHO AM I?  Mazin Ahmed Freelancing Security Researcher at Bugcrowd, Inc. Security Contributor at ProtonMail Freelancing Information Security Specialist You can read more at

WHO AM I?  And I have contributed to the security of the following:

Table of Contents  Introduction  How BFA Occurs?  Background  Previous Researches  Wrapping Ideas Together  The Problem  BFA Findings in Real-World.  Introducing BFAC  Using BFAC  Mitigations  Questions

What is Backup-File Artifacts ?

Background Code Editors  Code editors makes a backup copy of the files that being edited.  Mostly, it's being done in the same directory of the file.  It's made using the same filename.  It uses predictable patterns.

Background Code Editors Product NameBackup Pattern (Assuming the filename is config.php) Emacs#config.php# Nanoconfig.php.save Vim (swap file)config.php.swp Vim (swap file)config.php.swo Vim, Geditconfig.php~

Background Code Editors The Problem  Developers mostly forgets to check for Backup File Artifacts caused by code editors, and underestimate the impact of leaving similar artifacts.  This would lead to the disclosure of the source code of the script that has been edited.

Background Version Control Systems  Version Control Systems (VCS) are systems made to manage changes on files, documents, computer programs, code, websites, etc…  All Version Control Systems has a directory by design that contains data and/or source-code.  The directory is made to have a backup of files, and to control the changes on the files within the project.  By design, we already know directories names, the important files, and the directories' structure of source-code version controller systems.

Background Version Control Systems Version Control SystemPre-known Files and Directories GIT/.git (Default Directory) GIT/.gitignore GIT/.git/index GIT/.git/HEAD GIT/.git/refs Mercurial/.hg (Default Directory) Mercurial/.hg/requires Bazaar/.bzr/ (Default Directory) Bazaar/.bzr/README Subversion/.svn (Default Directory) Subversion/.svn/entries Subversion/.svnignore

Background Version Control Systems The Problem  Companies and developers in many occasions clone or download the repository into production, and FORGETS TO DELETE THE VCS DIRECTORIES.  This would lead to the disclosure of the source code of the company's application.

 The worst part: many websites don't disable directory listing, which makes exploiting that like a piece of cake. Profit?  downloading the VCS directory would be as simple as: $ wget --mirror -np –I /[path_to_vcs_dir] Background Version Control Systems The Problem

 In case the website disables directory listing, exploitation is still possible. Background Version Control Systems The Problem

 Exploitation of Missed VCS Folders on Web-Apps When Directory Listing is Disabled:-  Simply: Brute-Forcing the VCS structure. Background Version Control Systems The Problem

 Exploitation of Missed VCS Folders on Web-Apps When Directory Listing is Disabled:-  There are tools that can do that too:  GIT-Tools by Internetwache: A collection of scripts that can be used to retrieved GIT repositories from the web-app, even if directory listing is disabled. Written in Bash and Python.  DVCS-Ripper A tool that can perform recover different repositories even if directory listing is disabled. Written in Perl.  DVCS-Pillage by Adam Baldwin: A tool that extracts and retrieves different DVCS repositories. Background Version Control Systems The Problem

Background Human-Based Missed Backup File Artifacts  Developers usually do a backup before attempting to edit files.  Example:- Editing index.php  Before editing, many developers do the following: $cp index.php index.php.bak

 Developers in many cases forgets to remove the backup file.  It may even be left on production. Background Human-Based Missed Backup File Artifacts The Problem

Impact  An unauthorized attacker can brute-forces through different patterns of human-based backing up, and check if the file exists and accessible to the public.  If succeeded, the unauthorized attacker would be able to view the source-code of the script (Source-Code Disclosure). Background Human-Based Missed Backup File Artifacts The Problem

Previous Researches Pillaging DVCS Repos For Fun And Profit - Defcon 19 - Adam Baldwin – 2011  The talk discusses different leakage of Distributed Version Control Systems, and how it can leak the website’s source-code and data if it’s incorrectly accessible by unauthorized users.  A test on Alexa top 1M was done and showed that roughly 2,000 websites were vulnerable.  A tool called DVCS-Pillage was released that helps retrieving repositories from websites that exposes them.

1% of CMS-Powered Sites Expose Their Database Passwords - Feross Aboukhadijeh – 2011  A research that shows how can human-based backup artifacts and backup artifacts made by code-editors leaks sensitive data on popular CMSs.  Also, tested Alexa top 200,000 websites for basic BFAs on CMSs configuration files.  Results showed a large number of high-profile websites had BFA left on production.  Wrote a tool that can detect basic BFAs for CMSs configuration files. Previous Researches

Don't publicly expose.git or how we downloaded your website's sourcecode – Internetwache  A research done by Internetwache on GIT VCS, and how it can leak web-applications' source-code and data.  Demonstrated different techniques for real-world exploitation of missed GIT repositories on production.  Tested Alexa top 1M websites for web-applications that left GIT repositories on production.  Published a set of scripts to automatically tries to retrieve files from GIT repositories. Previous Researches

 Backup-File Artifacts are caused by different ways, mostly, it’s the admin/developer mistake to allow it accessible.  Exploitation of Human-Based BFA and BFAs that is caused by code-editors can be done as the following: Example:- Saying that index.php.bak is discovered. Wrapping Ideas Together

 Having the meta directory of Control Version Systems accessible also leads to source-code and data disclosure. Wrapping Ideas Together

Source-Code and Data Disclosure Human-Based Backup File Artifacts Backup File Artifacts Caused by Code Editors Version Controlling System Meta Directories Backup File Artifacts

 Most Open-Source and Commercial Web Vulnerability Scanners DO NOT PERFORM TESTING FOR BACKUP FILE ARTIFACTS.  Examples of Tested Open-Source Scanners That Do Not Perform BFA Checks:- OWASP ZAP 2.4 Vega W3AF – There are partial plugins that does basic testing, but it’s disabled by default. Nikto The Problem

 There are very few current Scanners that performs Backup Artifacts. Testing. However, those rare scanners only test the very basic pattern of BFA.  Many Important patterns testing are MISSED! The Problem

BFA Findings in Real-World Paypal BFA That Lead to RCE - Ebraheem Hegazy  Ebraheem found a script called upload.php on a Paypal-owned server.  wrote script to test for BFA, and to check if the script exist on other subdomains.  Found a BFA for upload.php, and transformed the Blackbox testing to whitebox testing.  After source-code reviewing it, he found a bug that leads to RCE. Profit : Got an RCE exploit on a Paypal server. Paypal fixed the issue, and he was awarded a nice bounty.

BFA Findings in Real-World ISC.org BFA that Disclosed Database Credentials - Feross Aboukhadijeh  During Feross’s research, he tested ISC.org for BFA on Wordpress configuration files, wp-config.php.  He found a BFA left on the main production site of ISC.org, containing database credentials. Profit : The researcher had potentially valid credentials to ISC.org (“potentially” is said, as the researcher stated that he didn’t use it gain unauthorized access). Feross reported it to ISC.org, and they have fixed it.

BFA Findings in Real-World A Collection of BFAs - Mazin Ahmed  Used BFAC to discover a number of BFA issues on web-applications, mostly for confidential clients.  BFA Findings Leads To: Credentials leakage. Turning testing to whitebox. Finding additional security vulnerabilities. RCE. SQLI. XSS. Even more BFA issues. etc...

 About the Project:  BFAC (Backup-File Artifacts Checker) is an automated tool that checks for backup artifacts that may discloses the web- application's source code.  BFAC goal is to be an all-in-one tool for backup-file artifacts black- box testing.

 About the Project:  Code Specifications:-  Written in pure Python.  Compatible with both Python2.x and Python3.x.  Cross-Platform: Works on Linux, Windows, Mac, Android, and IOS.  Requires a slight amount of resources/modules.  API friendly.  Released under GNU GPLv3.0 License.

 About the Project:  Features:-  Testing all common types of backup-file artifacts patterns, including human- based BFAs, and BFA that can occur via code-editors.  Includes tests for common VCS artifacts, such as GIT, Subversion, Mercurial, and Bazaar.  Smart detection techniques: Capable of detecting "Not Found", and valid pages using different tests.  Stealthy Interaction with Web Servers.  Easy to edit and customize based on needs; easy to add custom BFA patterns.  Dynamic and generic; made to be not specified to test a specific environment or server.

 Performs basic tests on the link, showing all attempts, and using random user- agents on each request. $ bfac --url ' --verbose --random-agent  Ignore 500 and 503 HTTP response codes when is detected as findings. $ bfac --url ' --verbose --exclude- status-codes 500,503

 Default option to confirm the existence of the BFA is set to check both of the HTTP Status Codes and the Content Length (set to “both”).  Rely only on HTTP Status Codes for confirming the existence of the BFA. $ bfac --url ' --verbose --verify-file- availability status_code  Rely only on Content Length measures in order to confirm the existence of the BFA. $ bfac --url ' --verbose --verify-file- availability content_length

 Perform BFA testing for all current testing levels (Level 4 includes tests from all below levels). $ bfac --url ' --verbose --level 4  Print a clean output with only findings, separated by newlines. Suitable for APIs and integration with other tools. $ bfac --url ' --no-text --level 4

Mitigation Developer-Level:-  Awareness  Probably the only reliable solution.  Developers' behavior regarding actions on production-level and publicly accessible applications are the main reason for this vulnerability type to occur. Software-Level:-  Access rules seems to be useful in blocking some of the patterns. However, it does not protect as needed.

Questions? Mazin Ahmed mazin AT mazinahmed DOT net Website: LinkedIn: