search
HomeOperation and MaintenanceSafetyHow to analyze reflected XSS
How to analyze reflected XSSMay 13, 2023 pm 08:13 PM
xss

1. Reflected XSS

Reflected XSS means that the application obtains untrustworthy data through Web requests, without checking whether the data contains malicious code. It is delivered to Web users. Reflected XSS is generally constructed by attackers with URLs containing malicious code parameters. When the URL address is opened, the unique malicious code parameters are parsed and executed by HTML. It is characterized by non-persistence and requires the user to click on a link with specific parameters. can cause. The editor takes the JAVA language source code as an example to analyze CWE ID 80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)

2. The dangers of reflected XSS

When a user accesses a URL request with XSS code, the server receives the data and processes it, then sends the data with XSS code to the browser, and the browser parses the data with XSS code Finally, an XSS vulnerability is created, which may lead to stealing the cookies of the target website and transferring them to the attacker's server, reading the user's undisclosed information, or performing click hijacking to implement phishing attacks. From January to November 2018, there were a total of 126 vulnerability information related to it in CVE. Some of the vulnerabilities are as follows:

#CVEVulnerability OverviewCVE-2018-19091tianti is a free lightweight CMS system written in Java. It currently provides an overall solution from back-end management to front-end display. Among them, tianti 2.3 has a reflected XSS vulnerability in the user management module through the tianti-module-admin / user /list userName parameter. CVE-2018-14929Matera Banco 1.0.0 is vulnerable to multiple reflected XSS, as shown in /contingency/web/index.jsp (aka Home page) url parameters. CVE-2018-12996 ZohoManageEngine Applications Manager provides solutions for monitoring and managing J2EE underlying structures and J2EE applications. A reflected cross-site scripting (XSS) vulnerability in Zoho ManageEngine Applications Manager 13 (Build13800) allows remote attackers to inject arbitrary web script or HTML via the 'method' parameter to GraphicalView.do. CVE-2018-12090LAMS is a new generation of JAVA-based learning software jointly developed by Macquarie University in Australia, LAMS International Co., Ltd. and LAMS Foundation. . Unauthenticated reflected cross-site scripting (XSS) exists in LAMS before 3.1, allowing remote attackers in forgetPasswordChange.jsp? Introducing arbitrary JavaScript via manipulation of unspecified GET parameters during key = password change.

3. Sample code

The example comes from Samate Juliet Test Suite for Java v1.3 (https://samate.nist.gov/SARD/testsuite.php), source File name: CWE80_XSS__CWE182_Servlet_URLConnection_03.java.

3.1 Defect Code

How to analyze reflected XSSHow to analyze reflected XSS

The above example code operation is to obtain the user’s age and create a connection object on line 40 , create an input stream on line 44 to obtain the content of the urlConnection object response, read a row of data from the buffer stream on line 52, and on line 100, remove all from the obtained data. <script></script> tag and output the processed data to the page. Even if the <script></script> tag is filtered, other html tags can still be used, which is constructed here Malicious url, but when the website is not protected, the page will read the content of document.cookie and input it into the page. This creates reflected XSS.

Use 360 ​​Code Guard to detect the above sample code, you can detect the "reflected XSS" defect, and the display level is high. The source of data pollution and data flow direction can be analyzed from the tracking path, and the defect is reported at line 100 of the code, as shown in Figure 1:

How to analyze reflected XSSFigure 1: Reflective XSS detection example

3.2 Repair code

How to analyze reflected XSS

#In the above repair code, since the content output by the page is the user’s age, in line 96, the response The content is converted into numbers, thus filtering out other html characters. Even if characters exist, the code will report an exception and will not cause reflected XSS to occur.

Use 360 ​​Code Guard to detect the repaired code, and you can see that there is no "reflected XSS" defect. As shown in Figure 2:


How to analyze reflected XSS

Figure 2: Detection results after repair

4. How to avoid reflected XSS

To avoid reflective ;, ', ", etc.) and

<script><p>, <code class="prettyprint code-in-text prettyprinted">javascript, etc. to filter. <code class="prettyprint code-in-text prettyprinted">(2) According to the different locations where the data will be placed in the HTML context (HTML tags, HTML attributes, JavaScript scripts, CSS, URLs), and perform appropriate output encoding on all untrusted data. <p>(3) Set the HttpOnly<p> attribute to prevent attackers from exploiting# The ##XSS<code class="prettyprint code-in-text prettyprinted"> vulnerability carries out Cookie<code class="prettyprint code-in-text prettyprinted"> hijacking attack. In JavaEE, the code to add HttpOnly<code class="prettyprint code-in-text prettyprinted"> to Cookie<code class="prettyprint code-in-text prettyprinted"> is as follows: <code class="prettyprint code-in-text prettyprinted"></script>

The above is the detailed content of How to analyze reflected XSS. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
Laravel中的跨站脚本攻击(XSS)和跨站请求伪造(CSRF)防护Laravel中的跨站脚本攻击(XSS)和跨站请求伪造(CSRF)防护Aug 13, 2023 pm 04:43 PM

Laravel中的跨站脚本攻击(XSS)和跨站请求伪造(CSRF)防护随着互联网的发展,网络安全问题也变得越来越严峻。其中,跨站脚本攻击(Cross-SiteScripting,XSS)和跨站请求伪造(Cross-SiteRequestForgery,CSRF)是最为常见的攻击手段之一。Laravel作为一款流行的PHP开发框架,为用户提供了多种安全机

PHP防御XSS与远程代码执行攻击的方法PHP防御XSS与远程代码执行攻击的方法Jun 30, 2023 am 08:04 AM

如何使用PHP防御跨站脚本(XSS)与远程代码执行攻击引言:在当今互联网世界中,安全性成为了一个至关重要的问题。XSS(跨站脚本攻击)和远程代码执行攻击是两种最常见的安全漏洞之一。本文将探讨如何使用PHP语言来防御这两种攻击,并提供几种方法和技巧来保护网站免受这些攻击的威胁。一、了解XSS攻击XSS攻击是指攻击者通过在网站上注入恶意脚本来获取用户的个人信息、

PHP中的安全XSS过滤技术解析PHP中的安全XSS过滤技术解析Jun 29, 2023 am 09:49 AM

PHP是一种广泛应用于网站开发的编程语言,但在使用PHP开发网站时,安全问题常常引起人们的担忧。其中之一就是跨网站脚本攻击(Cross-SiteScripting,XSS),是一种常见的网络安全漏洞。为了解决这个问题,PHP提供了一些安全XSS过滤技术。本文将介绍PHP中的安全XSS过滤技术的原理和使用方法。首先,我们需要了解什么是XSS攻击。XSS攻击

PHP和Vue.js开发安全性最佳实践:防止XSS攻击PHP和Vue.js开发安全性最佳实践:防止XSS攻击Jul 06, 2023 pm 01:37 PM

PHP和Vue.js开发安全性最佳实践:防止XSS攻击随着互联网的快速发展,网络安全问题变得越来越重要。其中,XSS(跨站脚本攻击)是一种非常常见的网络攻击类型,旨在利用网站的安全漏洞,向用户注入恶意代码或篡改网页内容。在PHP和Vue.js开发中,采取一些安全性最佳实践是非常重要的,以防止XSS攻击。本文将介绍一些常用的防止XSS攻击的方法,并提供相应的代

怎么分析反射型XSS怎么分析反射型XSSMay 13, 2023 pm 08:13 PM

1、反射型XSS反射型XSS是指应用程序通过Web请求获取不可信赖的数据,在未检验数据是否存在恶意代码的情况下,便将其传送给了Web用户。反射型XSS一般由攻击者构造带有恶意代码参数的URL,当URL地址被打开时,特有的恶意代码参数被HTML解析、执行,它的特点是非持久化,必须用户点击带有特定参数的链接才能引起。小编以JAVA语言源代码为例,分析CWEID80:ImproperNeutralizationofScript-RelatedHTMLTagsinaWebPage(BasicXSS)2、

如何分析反射型XSS如何分析反射型XSSJun 03, 2023 pm 12:09 PM

1测试环境介绍测试环境为OWASP环境中的DVWA模块2测试说明XSS又叫CSS(CrossSiteScript),跨站脚本攻击。它指的是恶意攻击者往Web页面里插入恶意html代码,当用户浏览该页之时,嵌入其中Web里面的html代码会被执行,从而达到恶意攻击用户的特殊目的,比如获取用户的cookie,导航到恶意网站,携带攻击等等。利用该漏洞,攻击者可以劫持已通过验证的用户的会话。劫持到已验证的会话后,病毒发起者拥有该授权用户的所有权限。3测试步骤在输入框中输入javascrip脚本代码:al

PHP中的XSS攻击PHP中的XSS攻击May 23, 2023 am 09:10 AM

近年来,随着互联网信息技术的迅猛发展,我们的生活越来越离不开网络。而网络与我们日常生活的交互,离不开大量的代码编写、传输以及处理。而这些代码,需要我们保护它们安全,否则,恶意攻击者会利用它们发动各种攻击。其中的一种攻击就是XSS攻击。在本文中,我们将重点介绍PHP中的XSS攻击,并且给出相应的防御方法。一、XSS攻击概述XSS攻击,也称为跨站脚本攻击,通常是

PHP入门指南:跨站脚本攻击(XSS)PHP入门指南:跨站脚本攻击(XSS)May 21, 2023 am 10:51 AM

PHP是一种流行的服务器端编程语言,用于开发动态网页和Web应用程序。然而,由于其广泛的使用和易于学习的特性,它经常成为黑客入侵网站的攻击目标。本文将介绍跨站脚本攻击(XSS),并提供一些防范措施。什么是跨站脚本攻击?跨站脚本攻击(XSS)是一种利用Web应用程序存在的漏洞的攻击方式。攻击者通过注入恶意代码来控制网站,然后向用户发送欺骗性的链接或将恶意代码插

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools