Sie sind auf Seite 1von 4

Prevention of Cross Site Scripting (XSS) and securing web

application atclient side

Akhil Nair, Pallavi Chame, Shital Gaikwad, Swapnil Ethape, Prof.Shikha Agarwal
akhil6169@gmail.com, chamepallavi@gmail.com, sdgaikwad.9822@gmail.com, reymee2141@gmail.com,
shikhamailme84@gmail.com
Computer Department AISSMS IOIT, Pune.

ABSTRACT environment where the resources are limited and has to be


In this paper we have implemented a complete API dedicated optimized for best performance. It can be implemented
to XSS protection and prevention such attacks at browser without disturbing the other implementations of the website.
level. This project also holds the real time notification service
which is implemented using google firebase notification API,
there are multiple digital signature methods used for
2. PREVIOUS WORKS
preventing such attacks. The API was designed using easy to All protection based services for securing the web application
incorporate architecture. Any kind of web based scripting or a website from cross site scripting based vulnerability is
language attacks can be prevented using this API different sever side and very hard to implement. They does not ensure
hashing algorithms are also used in this project. protection from every kind of script those are specifically
designed for exploiting the vulnerability at the client side.
General Terms Although current system can detect a plain text based
Web Security, Context Finder
injection they are not able to detect a script which are
Keywords represented using a different encoding scheme.In current
Code Injection, Cross Site Scripting, Content Security Policy, system protection layer is at the server side. When attacker
Nonce inject malicious code on website and that code is validated at

1. INTRODUCTION .
server side in non-persistent attack Validation and escape of
Cross Site Scripting attack (XSS) is a very serious code code is done at server side. If script is in encoded format
injection based computer security threat which enables the system is not able to detect this encoded script. Server side
unauthorized users or hackers to gain access over the web security layer implementation is hard and costly so it is not
application or site’s confidential information, when the reliable and in persistent attack malicious code is already
embedded code injected gets executed at the client side which present in database when any client request page with that
may be an HTML, JavaScript or any other scripting language page malicious code is also executed and security get
code. These kind of attacks can be performed on any site compromise. To overcome all these issues we implement
which has no input validation and has a poor security better solution in this project.
implementation over users input. The existing systems fall
short for major code injection based attacks. These attacks are
increasing day by day as the ratio of vulnerable sites are very
3. SURVEY
Mukesh Gupta, et al [1] proposed an identification and
high. This attacks are targeted and specifically designed to prediction scheme for Cross Site Scripting based attacks. Also
interfere with user interface and steal sensitive data. A better the classification of XSS attacks have be briefly explained.
security layer has to be implemented to prevent such attacks. Cross Site Scripting is a security bug that can affect web
We presented the design and implementation of a web based applications. This bug allows an attacker to inject their own
API which can be used to protect any website or web malicious code into HTML pages that are displayed to the
application against cross site scripting (XSS) based attack users. On successful execution of the malicious code, the
using content security policy (CSP). As the Internet becomes system or website action or behavior can be completely
more and more complex, newly found vulnerabilities continue changed. It also can steal user’s private data or can be
to develop and through web-based applications, these performed on behalf of the user and specifically speaking one
vulnerabilities are exploited as XSS.In our project we of the most application layer web attacks, it targets scripts
represent design and implementation of a web based security which are dynamically included in a page which executes on
API which can be used to protect any cross site scripting the client-side rather than executing on the server-side.
based attack using content security policy (CSP). This
security API is integrated on website. The API is designed in AnkitShrivastava, et al [2] proposed assessment and
such a way that resource consumption is very less and prevention mechanism’s for prevention of XSS in web
efficient. This makes the application feasible to an

Volume 3 Issue 2 April – 2018 83


applications. This papers has additional information about the basic from of XSS protection performed manually at client
things to consider while creating a secure web application. side.
XSS is a threat that occurs because of security flaws of client
5.2 Escaping
side scripting languages like JavaScript and HTML. The
model of XSS is to handle client-side scripts of a web-app to This mechanism of XSS security works by escaping the user
execute in the order preferred by the malicious manipulator. content before the browser intercepts it and then executes it.
These kinds of manipulations can embed a script in a page Escaping can be defined as changing the character encoding
of certain symbols there by preventing these attacks
that could be executed each and every time when it is loaded,
or whenever an associated event is executed. 5.3 Nonce Verification
SamerMhanaThe, et al [3] proposed a system for generating The implementation of security is based on CSP (Content
Security Policy) which implements Nonce values and this
dynamic Content Security Policy (CSP) at run time to avoid
value is uniquely generated for each request within the server
Cross Site Scripting vulnerabilities. Implementation of and is included with the response to the server.
security is based on CSP (Content Security Policy) which
implements Nonce values and this value is uniquely generated 5.4 SHA256 Validation
for each request within the server and is included with the SHA-256 Cryptographic Hashing Algorithm. A digest or in
response to the server. Also the concept of SHA- 256 hashing other terms also called as a cryptographic hash is a form of
algorithm is used for static key generation. digital signature for a text based content or a file. A unique
256-bit (32 bytes) string or digital signature is generated from
PunamThopate, et al [4] proposed a dynamic detection system the content or file.
for prevention of Cross Site Scripting (XSS). Additionally this
paper consist of all the information regarding various different
kinds of XSS attacks and also technical information related to
the already existing system to prevent XSS. Automated
detection mechanisms or tools are preferred to prevent cross
site scripting. The rate of XSS detection of many a Cross Site
Scripts are very less as compared to many other kind of
scripts. In general, scanners are unable to detect code injection
attacks which are based on persistent code which resides in
the server itself.

4. TYPES OF XSS ATTACKS


4.1 Persistent or Stored
One of the most prominent type of XSS attacks is generally
Fig 1: SHA256 Validation
persistent attacks. In this kind of attacks the data submitted by
the user is saved on the server side. This kind of system is 6. CSP BASED IMPLEMENTATION
vulnerable as the data submitted by the user may contain Content Security Policy (CSP) is an extra security layer added
malicious content. This malicious content received from the to eliminate and detect certain types of scripting or code
server is trusted by the browser which executes it. Although injection based attacks. These attacks are generally used for
HTML escaping can be used to prevent this type of attacks data stealing and site manipulation or distribution of malwares
encoding the malicious content allows it to go through this on the internet.
security mechanism undetected. Content Security Policy is a computer security standard
introduced to prevent XSS attack. It provide standard for
4.2 Non-Persistent or Reflected website owner to implement their security manually. CSP is
Non-persistent attacks are the basic from of XSS based an improved and advanced layer of XSS security and detect
all kinds of code injection based attacks.
attacks. These attacks are also known as reflection based
attacks. In these kind of data is never stored anywhere. The 7. PROPOSED SYSTEM
data is reflected back from the server with the malicious code
embedded in it, which then gets executed at the client side or 7.1 System Architecture
Generally the attack occurs at client side and the data migrates
browser.
to the server and then the data is validated and inspected for
any type of malicious content. This system is completed
5. PREVENTION METHODS flawed as data can be in any encoding scheme which the
5.1 Validation security systems fail to identify or verify [1]. Thus the code
Common mistake of many developers is that they tends to migrates and resides in the data base. Upon next request this
ignore the fact that client side data needs to be validated code again migrates to other client computers and thus
before it is allowed to enter the system database. It is the most making this attack even more devastating. As the below

Volume 3 Issue 2 April – 2018 84


diagram illustrates all the defense system is client side based This module is the actual web application on top of which the
in our API implementation. As stated above the API we other modules have been implemented to protect this module.
implemented generates a new nonce value for every new In our case this module is the Paper Checking Management
request and assigns this key to all the script included on that System we developed. Any application which implements this
page. Now the implementation of CSP helps us to define rules web security API can be termed under this module.
that only the scripts with this values will be executed once [3].
8.3Administrative Module
As soon a script or malicious content is entered by the user
and it does not match the nonce value provided by the server Administrative module is another important module in our
the code is rejected at the client side itself. A report is send projects. This module helps the administrator to remotely
back to server to notify all the administrators and to take manage the security API and the web application itself. This
adequate action against this attack.Another implementation module allows the admins to block or unblock certain IP
with works with CSP is that to implement a SHA-256 value addresses. Also allows the admins to communicate with each
which is generated by evaluating the script that is to be other. It also helps the admins in managing the web
included on the page [3]. Any script that does not match this application by changing the current state of the web
values is rejected at client side itself. application. This module consist of multiple sub modules for
various tasks.

1. Access Modifier
2. Mobile Application Interfacing Module
3. Access Control Module

9. ANALYSIS AND CONCLUSION


Cross Site Scripting is a security bug that can affect web
applications. This bug allows an attacker to inject their own
malicious code into HTML pages that are displayed to the
users. On successful execution of the malicious code, the
system or website action or behavior can be completely
changed. It also can steal user’s private data or can be
performed on behalf of the user and specifically speaking one
of the most application layer web attacks, it targets scripts
which are dynamically included in a page which executes on
the client-side rather than executing on the server-side. After
Fig 2:System Architecture examining all these prevention and detection mechanisms, we
came to the conclusion that designing a security API which
8. SYSTEM DESIGN will work very fine in validating and removing stripping the
The system consist of the following modules: legitimate cross-site scripts (XSS), XSS worms and virus as
well. The implementation of security is based on CSP
8.1 XSS Security API (Content Security Policy) which implements Nonce values
This module is the primary component of the entire project. and this value is uniquely generated for each request within
This module itself manages the security implementations like the server and is included with the response to the server. Also
generation of nonce value and SHA-256 keys and appending the concept of SHA-256 hashing algorithm is used for static
it to the response header. It is also responsible for generating a key generation.
CSP header for every request dynamically and generating new
secret keys for every single request. Upon any violation of the 10. ACKNOWLEDGEMENT
rules specified in CSP this module is responsible for notifying We would like to express gratitude to our project guide Prof.
all the admins to real time notifications and emails. This Shikha Agarwal for her expert advice and encouragement
throughout this difficult project, as well as project coordinator
module is further divided into sub modules.
Dr.K.S. Wagh and Head of Department Prof. S.N. Zaware.
Without their continuous support and encouragement this
8.1.1 Key generation module project might not have been possible.
8.1.2 Mobile Application Interfacing Module
8.1.3 Access Control Module
REFERENCES
[1] Mukesh Gupta, Mahesh Govil, Girdhari Singh.
8.2Client Web Application “Predicting Cross-Site Scripting (XSS) Security

Volume 3 Issue 2 April – 2018 85


Vulnerabilities in Web Applications”, Malviya National [9] Imran Yusof, Al-Sakib Khan Pathan, “Preventing
Institute of Technology, IJCSSE, 2015 Persistent Cross-Site Scripting (XSS) Attack by
[2] Ankit Shrivastava, Santosh Choudhary,Ashish Kumar. Applying Pattern Filtering Approach”, International
“XSS Vulnerability Assessment and Prevention in Web Islamic University Malaysia, IEEE, 2013
Application”, Manipal University Jaipur, INGCT, 2016 [10] Rahul Johari, Pankaj Sharma. “A Survey On Web
[3] Samer Mhana, Jamilah Din, Rodziah Atan. “Automatic Application Vulnerabilities (SQLIA, XSS) Exploitation
Generation of Content Security Policy to Mitigate Cross and Security Engine for SQL Injection”, Ministry of
Site Scripting”, Universiti Putra Malaysia Serdang, Communications and IT Govt. of India, ICCSNT, 2012
ICSITech, 2016 [11] Guowei Dong, YanZhang, Xin Wang, Peng Wang.
[4] Punam Thopate, Purva Bamm, Snehal Kunjir. “Cross “Detecting Cross Site Scripting Vulnerabilities
Site Scripting Attack Detection & Prevention System”, Introduced by HTML5”, Renmin University of China,
IJARCET, Vol 3 Issue 11, 2014 IJCSSE, 2014
[5] Mohit Dayal, Nanhay Singh Ambedkar. “A [12] Hiroya Takahashi, Kenji Yasunaga, Masahiro Mambo.
Comprehensive Inspection Of Cross Site Scripting “Preventing Abuse of Cookies Stolen by XSS”,
Attack”, Institute of Advanced Communication Kanazawa University Japan, AJCIS, 2013
Technologies and Research, New Delhi, ICCCA, 2016 [13] Prof. Piyush A. Sonewar, Prof. Sonali D. Thosar.
[6] Mahmoud Mohammadi, Bill Chu, Emerson Murphy-Hill. “Detection of SQL Injection and XSS Attacks in Three
“Automatic Web Security Unit Testing: XSS Tier Web Applications”, Prawara Rural Education
Vulnerability Detection, NC State University Raleigh”, Society, Loni, IJARCET, 2015
IEEE/ACM, 2016
[7] Vikas K. Malviya, Saket Saurav, Atul Gupta. “On
Security Issues in Web Applications through Cross Site
Scripting (XSS)”, Computer Science & Engineering
PDPM IIITDM Jabalpur, APSEC, 2013
[8] M. Ridwan Zalbina, Deris Stiawan, Ahmad Heryanto.
“Payload Recognition and Detection of Cross Site
Scripting Attack”, College of Computer Science & IT
Albaha University, IEEE, 2016

Scene", 2015 15th International Conference on


Intelligent Sysems Design and Applications (ISDA) .

Volume 3 Issue 2 April – 2018 86

Das könnte Ihnen auch gefallen