160129-Paper 11 - Understanding File Upload Security
160129-Paper 11 - Understanding File Upload Security
Abstract- In today’s times the web model has to phish for user information or implant malware.
become an important mechanism in terms of According to a report by the Web Application
information and services delivery over the internet. Security Consortium, about 49% of the web
With the success of the internet, it becomes important applications being reviewed contain vulnerabilities of
to take into account the security of the web high risk level and more than 13% of the websites can
application layer from various unauthorized user be compromised completely automatically [2].
attacks. There are many factors due to which it becomes
The main reason for security awareness is due to lack difficult to secure applications which have be taken
of trustworthiness of the applications programming into consideration to improve application security.
logic or input validation. The best way of preventing Insecure applications are built due to shortcomings of
application exploitability is to enforce good security many factors such as security testing done too late in
policies through the applications. This can be done the SDLC, skipping out on security testing because of
only when the client and server collaborate to the release rush, budget restraints and more
achieve the desired security goals eliminating the commonly, the lack of security awareness by
possibility of such attacks. In this paper we focus on developers. The lack of developer awareness of
file upload exploits with respect to web application secure coding standards along with the lack of budget
security. Various test cases will be explained along spent on mobile application security are two of the
with the impact which will help security testers and scariest issues. The primary goal of this paper is for
application developers to maintain the confidentiality developers and testers to understand the common
and integrity of user data. Finally, potential steps for vulnerabilities on file upload functionality which
mitigation will be provided in order to restrict such leads to attacks and their respective mitigations for
attacks. future secure development.
Keywords— Web Application Security, Malicious
File Upload, File Upload Security II. LITERATURE REVIEW
I. INTRODUCTION The following papers were referred to understand
web application security:
World Wide Web is considered as the main
infrastructure of the global information society on
A. A Survey on Web Application Security
which the world is highly dependent. The Web
X. Li | Y. Xue [1] have conducted surveys with respect
platform is a complex ecosystem composed of a large
to web application security techniques. They have
number of components and technologies, including
categorized three essential properties: state integrity,
HTTP protocol, web server and server-side
input validation and logic correctness required for
application development technologies, web browser
application security along with the future scope of the
and client-side technologies [1]. The internet and its
research.
services are now easily accessible to us on portable
devices Web applications have had a huge impact on
B. End-to-end Web Application Security
fields such as business, education, health and social
U. Erlingsson | B. Livshits | Y. Xie [3] support the
life, drastically changing the cultural norms and
argument that there should be collaboration between
individual behaviors. Every week thousands of new
the server and client to improve security. They also
web applications with the power to simplify and ease
provide examples mechanisms in order to achieve
the human activity process hit the market. But it is
end-to-end security.
also important to understand that with such power it
also becomes the responsibility of application
C. A review on Application Security Vulnerabilities
builders to be vigilant about security to protect users.
A. Garg | S. Singh [4] provides a look at common web
With the growing popularity of the good guys
application vulnerabilities such as remote code
developing the applications, there are thousands of
execution, SQL injection, format string
hackers working hard to break into these apps to try
vulnerabilities, cross site scripting, username
From annotations, select attach file and place the Do not place the .htaccess file in the same
cursor in the document and browse the file you directory where the uploaded files will be
want to attach. Attach an excel file with an stored. It should be placed in the parent
executable file embedded into it. directory.
Thus a pdf file is created where malicious excel A typical .htaccess which allows only gif,
file is embedded. jpg, jpeg and png files should include the
Upload this file and observe if the file was following (adapt it for your own need). This
uploaded successfully. will also prevent double extension attacks.
Vulnerability Reason:
The most important thing is to keep
The attack is possible since there is no validation
uploaded files in a location that can’t access
done at client side to check the body contents of
the attached file. though the Internet. This can be done either
by storing uploaded files outside of the web
P. Case 16 – Overwriting critical files root or configuring the web server to deny
Summary: access to the uploads directory.
In this type we try to overwrite critical files on the Prevent overwriting of existing files (to
webserver such as .htaccess or web.config file. prevent the .htaccess overwrite attack).
Steps: Don’t rely on client-side validation only,
Find the path of the .htaccess file onto the server since it is not enough. Ideally one should
using information gathering. have both server-side and client-side
Following line can be added in .htaccess file validation implemented. The application
before uploading: should use client- and server-side input
AddType application/x-httpd-php .gif validation to ensure evasion techniques have
Once the path is found, the above manipulated not been used to bypass the whitelist filter.
.htaccess file can be uploaded on the desired path Set a pre-defined size and file name length.
using the file upload feature. Files that are uploaded should be scanned by
Vulnerability Reason: antivirus software.
If the webserver allows to modify sensitive files The application should not use the file name
such as .htaccess file or web.config file, we can
supplied by the user. Instead, the uploaded
upload files to modify how different files should
file should be renamed according to a
be executed on the server. The .htaccess file
predetermined convention. Thus, the
contains restrictions for a particular folder. Now
there are locations where the server allows the user attacker will encounter problems trying to
to upload and overwrite files. Using this feature of determine the name of the file in the
over writing an attacker can replace the .htaccess uploaded folder.
file with a manipulated one allowing permissions
VI. CONCLUSION
to execute scripts.
The above malicious line (AddType application/x-
In this paper we have highlighted the importance of
httpd-php .gif) explained would basically execute
application security and how users could be affected
every gif file inside the webserver as a PHP. So
by such data loss. Due to large user base of web
once an attacker uploads .htaccess file containing
applications it becomes necessary to make
that code, attacker can rename any malicious file
organizations aware of application security practices
as Test.gif which will be interpreted as a PHP file
to prevent these types of break-ins. We have
by the webserver.
demonstrated various ways to bypass the file upload
V. MITIGATION vulnerability using open source tools, along with their
mitigations. Security is not a one-time event due to
The application should use a whitelist of which it insufficient to perform security analysis on
allowed file types. This list determines the the application just once. An application can meet the
types of files that can be uploaded, and security requirements only when all the stages of an
rejects all files that do not match approved application development cycle are analyzed securely
types. by developers and testers. This paper aims at
Only allow authorized and authenticated providing awareness to apply security measures for
users to use the feature. file uploads at client and server side which will
Serve fetched files from your application reduce the security testing cost by itself.
rather than directly via the web server.
ACKNOWLEDGEMENT
Write to the file when you store it to include
a header that makes it non-executable. I offer my profound gratitude towards all the staff
Define a .htaccess file that will only allow members of K. J. Somaiya College of Engineering,
access to files with allowed extensions.
REFERENCES