CN108171051A - 一种对抗xss攻击的方法 - Google Patents

一种对抗xss攻击的方法 Download PDF

Info

Publication number
CN108171051A
CN108171051A CN201711428031.7A CN201711428031A CN108171051A CN 108171051 A CN108171051 A CN 108171051A CN 201711428031 A CN201711428031 A CN 201711428031A CN 108171051 A CN108171051 A CN 108171051A
Authority
CN
China
Prior art keywords
iframe
parent page
data
submitting button
sent
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201711428031.7A
Other languages
English (en)
Inventor
张伟荣
季统凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
G Cloud Technology Co Ltd
Original Assignee
G Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by G Cloud Technology Co Ltd filed Critical G Cloud Technology Co Ltd
Priority to CN201711428031.7A priority Critical patent/CN108171051A/zh
Publication of CN108171051A publication Critical patent/CN108171051A/zh
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明涉及网站安全技术领域,具体涉及一种对抗XSS攻击的方法。本发明所述的方法是通过脚本创建一个提交按钮放在不同源的iframe中,通过iframe中的提交按钮提交父页面的表单,服务端通过检测referer是否由iframe发起判断提交合法性。本发明解决对外开放的网页表单提交功能容易受到跨站脚本攻击(XSS)的问题。

Description

一种对抗XSS攻击的方法
技术领域
本发明涉及网站安全技术领域,具体涉及一种对抗XSS攻击的方法。
背景技术
目前网站的表单很多都是通过点击提交按钮发起的,例如提交评论、发布留言。如果留言***有XSS漏洞,用户中招后,除了基本攻击外,XSS还会自动填入留言内容并模拟点击提交按钮发布带有恶意代码的留言。其他用户看到中招后又传播给其他用户,从而形成蠕虫扩散。
发明内容
本发明解决的技术问题在于提供一种对抗XSS攻击的方法,解决原来对外开放的网页表单提交功能容易受到跨站脚本攻击(XSS)的问题。
本发明解决上述技术问题的技术方案是:
所述的方法是通过脚本创建一个提交按钮放在不同源的iframe中,通过iframe中的提交按钮提交父页面的表单,服务端通过检测referer是否由iframe发起判断提交合法性。
所述的方法具体包含以下几个步骤:
步骤一、父页面初始化,通过脚本创建一个提交按钮,放在不同源的iframe中;
步骤二、用户点击iframe的提交按钮,设置变量clicked为true,同时通知父页面;
步骤三、父页面收到消息后,将表单数据发送到iframe并调用iframe页面的提交方法;
步骤四、iframe页面的提交方法检验变量clicked,如果为true,则将父页面发过来的数据通过Ajax发送;
步骤五、服务端接收数据,检验referer,如果为iframe的地址,则检验通过,否则提示数据来源错误;
步骤六、iframe页面的提交方法收到服务端返回数据后,将结果发送回父页面;
步骤七、父页面处理收到的返回数据,如果成功则提示提交成功,如果失败则提示详细错误。
本发明的有益效果:在页面中通过脚本创建提交按钮,放在不同源的iframe中,这样就和XSS所在的环境隔离了,XSS无法访问到这个提交按钮也就无法模拟点击提交恶意代码。而且通过iframe提交父页面的表单,服务端通过referer即可检测请求是否由iframe发起的,这样就算XSS破解上一道防线,通过直接调用http接口提交数据,XSS也无法伪造referer。采用这种方法可以实现对抗XSS攻击的目的。本发明有效解决了对外开放的网页表单提交功能容易受到跨站脚本攻击(XSS)的问题。
附图说明
下面结合附图对本发明进一步说明:
图1为本发明的方法流程图。
具体实施方式
如图1所示,本发明采用如下步骤:
步骤一、父页面初始化,通过脚本创建一个提交按钮,放在不同源的iframe中,父页面url为“http://www.test.com/form.html”,iframe的url为“http://cross.test.com/proxy.html”;
步骤二、用户点击iframe的提交按钮,设置变量clicked为true,同时通知父页面;
步骤三、父页面收到消息后,将表单数据发送到iframe并调用iframe页面的提交方法;
步骤四、iframe页面的提交方法检验变量clicked,如果为true,则将父页面发过来的数据通过Ajax发送;
步骤五、服务端接收数据,检验referer,如果为iframe的地址,则检验通过,否则提示数据来源错误;
步骤六、iframe页面的提交方法收到服务端返回数据后,将结果发送回父页面;
步骤七、父页面处理收到的返回数据,如果成功则提示提交成功,如果失败则提示详细错误。

Claims (2)

1.一种对抗XSS攻击的方法,其特征在于:所述的方法是通过脚本创建一个提交按钮放在不同源的iframe中,通过iframe中的提交按钮提交父页面的表单,服务端通过检测referer是否由iframe发起判断提交合法性。
2.根据权利要求1所述的方法,其特征在于:所述的方法具体包含以下几个步骤:
步骤一、父页面初始化,通过脚本创建一个提交按钮,放在不同源的iframe中;
步骤二、用户点击iframe的提交按钮,设置变量clicked为true,同时通知父页面;
步骤三、父页面收到消息后,将表单数据发送到iframe并调用iframe页面的提交方法;
步骤四、iframe页面的提交方法检验变量clicked,如果为true,则将父页面发过来的数据通过Ajax发送;
步骤五、服务端接收数据,检验referer,如果为iframe的地址,则检验通过,否则提示数据来源错误;
步骤六、iframe页面的提交方法收到服务端返回数据后,将结果发送回父页面;
步骤七、父页面处理收到的返回数据,如果成功则提示提交成功,如果失败则提示详细错误。
CN201711428031.7A 2017-12-26 2017-12-26 一种对抗xss攻击的方法 Pending CN108171051A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711428031.7A CN108171051A (zh) 2017-12-26 2017-12-26 一种对抗xss攻击的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711428031.7A CN108171051A (zh) 2017-12-26 2017-12-26 一种对抗xss攻击的方法

Publications (1)

Publication Number Publication Date
CN108171051A true CN108171051A (zh) 2018-06-15

Family

ID=62520593

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711428031.7A Pending CN108171051A (zh) 2017-12-26 2017-12-26 一种对抗xss攻击的方法

Country Status (1)

Country Link
CN (1) CN108171051A (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101588382A (zh) * 2008-05-19 2009-11-25 北京亿企通信息技术有限公司 一种在Web页面中附件提交的方法
CN102447726A (zh) * 2010-10-15 2012-05-09 中兴通讯股份有限公司 页面访问方法及***
CN103581321A (zh) * 2013-11-06 2014-02-12 北京奇虎科技有限公司 一种refer链的创建方法、装置及安全检测方法和客户端
CN103856493A (zh) * 2012-11-28 2014-06-11 纽海信息技术(上海)有限公司 跨域登录***及方法
CN105512559A (zh) * 2014-10-17 2016-04-20 阿里巴巴集团控股有限公司 一种用于提供访问页面的方法与设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101588382A (zh) * 2008-05-19 2009-11-25 北京亿企通信息技术有限公司 一种在Web页面中附件提交的方法
CN102447726A (zh) * 2010-10-15 2012-05-09 中兴通讯股份有限公司 页面访问方法及***
CN103856493A (zh) * 2012-11-28 2014-06-11 纽海信息技术(上海)有限公司 跨域登录***及方法
CN103581321A (zh) * 2013-11-06 2014-02-12 北京奇虎科技有限公司 一种refer链的创建方法、装置及安全检测方法和客户端
CN105512559A (zh) * 2014-10-17 2016-04-20 阿里巴巴集团控股有限公司 一种用于提供访问页面的方法与设备

Similar Documents

Publication Publication Date Title
US11126723B2 (en) Systems and methods for remote detection of software through browser webinjects
US8448241B1 (en) Browser extension for checking website susceptibility to cross site scripting
US8528079B2 (en) System and method for combating phishing
US8839369B1 (en) Methods and systems for detecting email phishing attacks
US8474048B2 (en) Website content regulation
CN101964025B (zh) Xss检测方法和设备
CA2673322C (en) Method and apparatus for detecting computer fraud
US8782157B1 (en) Distributed comment moderation
US20110225234A1 (en) Preventing Cross-Site Request Forgery Attacks on a Server
Shrivastava et al. XSS vulnerability assessment and prevention in web application
CN105635064B (zh) Csrf攻击检测方法及装置
US20170371888A1 (en) Method for advertisement interception in dual-kernel browser and browser apparatus
Ambedkar et al. A comprehensive inspection of cross site scripting attack
CN104660556B (zh) 跨站伪造请求漏洞检测的方法及装置
CN108171051A (zh) 一种对抗xss攻击的方法
CN104732144A (zh) 一种基于伪协议的远程代码注入漏洞检测方法
CN108650230A (zh) 一种防止按钮自动点击的方法及***
Hadpawat et al. Analysis of prevention of XSS attacks at client side
US20230007913A1 (en) Rendering of unsafe webpages
Liu et al. Financial websites oriented heuristic anti-phishing research
CN113656674B (zh) 关于网站爬虫中点击类型超链接的自动化处理方法及装置
TWI506471B (zh) 跨網站攻擊防範系統及方法
Nagarjun et al. ImageSubXSS: an image substitute technique to prevent Cross-Site Scripting attacks
Dalziel How to attack and defend your website
Kumar Classification of Malicious Webpages in Mobile Environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20180615