WO2020259389A1 - 一种csrf漏洞的检测方法及装置 - Google Patents

一种csrf漏洞的检测方法及装置 Download PDF

Info

Publication number
WO2020259389A1
WO2020259389A1 PCT/CN2020/096900 CN2020096900W WO2020259389A1 WO 2020259389 A1 WO2020259389 A1 WO 2020259389A1 CN 2020096900 W CN2020096900 W CN 2020096900W WO 2020259389 A1 WO2020259389 A1 WO 2020259389A1
Authority
WO
WIPO (PCT)
Prior art keywords
access
detected
token
access request
url site
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.)
Ceased
Application number
PCT/CN2020/096900
Other languages
English (en)
French (fr)
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.)
WeBank Co Ltd
Original Assignee
WeBank 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 WeBank Co Ltd filed Critical WeBank Co Ltd
Publication of WO2020259389A1 publication Critical patent/WO2020259389A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0807Network architectures or network communication protocols for network security for authentication of entities using tickets, e.g. Kerberos
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1433Vulnerability analysis

Definitions

  • the present invention relates to the technical field of financial technology (Fintech), in particular to a method and device for detecting CSRF vulnerabilities.
  • Cross-site request forgery is a malicious use of websites. Some financial platforms have loopholes in business functions. CSRF allows hackers to impersonate legitimate users, allowing legitimate users to trigger dangerous operations such as financial payments and transfers without their knowledge, directly affecting the security of users’ funds and accounts.
  • the embodiment of the present invention provides a method for detecting CSRF vulnerabilities, which aims to solve the problems of single detection means for CSRF vulnerabilities and low detection accuracy in the prior art.
  • an embodiment of the present invention provides a method for detecting cross-site request forgery CSRF vulnerabilities, including:
  • the third access request carrying the first user login status information is sent to the URL site to be detected; if the third access response corresponding to the third access request is in the third access response If the third Token is consistent with the first Token, it is determined that the URL site to be detected has a CSRF vulnerability.
  • the detection method of CSRF vulnerabilities adds Tokens for different user information to detect. If different users have the same token in the access response, there is a greater possibility of CSRF vulnerabilities; After the Token of the information is detected, Token detection in different periods is performed; if the same user has the same Token in different periods, there is a greater possibility of CSRF vulnerability. It can be seen that the above technical solution enriches the Token detection methods by introducing the Token detection of different user information and the Token detection of the same user at different times, thereby improving the detection accuracy.
  • the method further includes:
  • the fourth access response corresponding to the fourth access request matches the fifth access response, it is determined that the URL site to be detected has a CSRF vulnerability; the fifth access response is a legitimate access request of the URL site to be detected the response to. It should be noted that the fourth access request may also be the first access request, and therefore the fifth access response may also be the first access response.
  • the detection method of the constructed access request and the legal access request is further provided; if the response of the constructed access request is the same as the legal one If the response of the access request matches, it is determined that there is a CSRF vulnerability. It can be seen from the above technical solutions that the embodiment of the present invention further adds detection means, thereby improving the detection accuracy.
  • the interaction mode of the URL site is Ajax format; before sending the fourth access request to the URL site to be detected, the method further includes:
  • blacklist judgment is also performed before the token detection of different user information; if the Token is in the blacklist, it is determined that there is a CSRF vulnerability; otherwise, the token detection of different user information is performed.
  • This technical solution can further improve the detection efficiency of CSRF vulnerabilities.
  • embodiments of the present invention also provide a device for detecting CSRF vulnerabilities in cross-site request forgery, the device including:
  • the detection unit when the first Token and the second Token are inconsistent, when a set time arrives, send a third access request carrying the login status information of the first user to the URL site to be detected; If the third Token in the third access response corresponding to the third access request is consistent with the first Token, it is determined that the URL site to be detected has a CSRF vulnerability.
  • the detection unit is further configured to:
  • the fourth access response corresponding to the fourth access request matches the fifth access response, it is determined that the URL site to be detected has a CSRF vulnerability; the fifth access response is a legitimate access request of the URL site to be detected the response to.
  • the detection device further includes:
  • the obtaining unit is used to crawl each data packet of the URL site to be detected
  • the determining unit is further configured to determine that the first Token and the second Token are not in the blacklist.
  • an embodiment of the present invention also provides a computing device, including:
  • the processor is configured to call the program instructions stored in the memory, and execute the method of the first aspect or any one of the embodiments of the first aspect according to the obtained program.
  • FIG. 1 is a schematic diagram of a possible system architecture provided by an embodiment of the present invention
  • FIG. 2 is a schematic diagram of the implementation process of a CSRF vulnerability detection method provided by an embodiment of the present invention
  • an embodiment of the present invention provides a method for detecting a cross-site request forgery CSRF vulnerability, which includes the following steps:
  • S12. Determine the second Token carried in the second access response returned by the URL site to be detected; the second access response is sent in response to the second access request carrying the login status information of the second user; the first user Different from the second user.
  • the set time in step S14 can be set by itself, so as to meet the effective use time of the cookie information. Although this step is explained by taking the first token as an example, in fact it can also be the second token or the third token, as long as the token meets the time of two visits and reaches the set time.
  • step S15 If the third token in the third access response corresponding to the third access request is consistent with the first token, it is determined that the URL site to be detected has a CSRF vulnerability.
  • Token detection of different user information is performed in step S13 to avoid CSRF vulnerabilities caused when different users have the same Token; in step S15, Token detection of the same user in different periods is performed, thereby avoiding the validity period of the token. CSRF vulnerability caused by too long.
  • the method further includes if the third Token and the third access response in the third access response corresponding to the third access request of the URL site to be detected If the Token is inconsistent, the method further includes:
  • Manner 1 Crawling each data packet of the URL site to be detected; obtaining the first access response and the second access response from the data packets.
  • Manner 2 Construct the first access request and send it to the URL site to be detected; construct the second access request and send it to the URL site to be detected.
  • Ajax tag in the crawled page code Through the Ajax tag in the crawled page code, it can be judged whether it is an Ajax interactive access request. If it is judged that the submission is the Ajax interactive mode, the fourth access request sent by the Ajax interactive mode is constructed by replacing the send data.
  • An example of Ajax interaction is as follows code 3:
  • the browser will verify whether the client and server are in the same domain, and if they are not in the same domain. You need to set the withCredentials attribute of the sender to True, that is, support for carrying cookie information during cross-domain access. In other words, the browser of the access device 101 needs to be set to carry cookie information when supporting cross-domain access, so that the above detection process can be performed.
  • a cross-domain request means that the domain of the current request is different from the domain of the resource pointed to by the request.
  • the protocol, domain name, and port number are the same, it is the same domain.
  • the browser of the access device 101 does not verify whether its domain is the same as the domain of the site to be detected, and sends it directly, so there is no need to set the browser of the access device 101 to support cross Domain request.
  • the browser of the access device 101 will check whether the domain it is in is the same as the domain of the site to be detected. If it is different, the browser of the access device 101 will not send the request. When going out, you need to set the browser of the access device 101 to support cross-domain requests.
  • the embodiment of the present invention also provides a detection device for cross-site request forgery CSRF vulnerabilities. Since the principle of the above device to solve the problem is similar to the method for detecting cross-site request forgery CSRF vulnerabilities, the implementation of the above device can be See the implementation of the method, and the repetition will not be repeated.
  • FIG. 3 it is a schematic structural diagram of a CSRF vulnerability detection device provided by an embodiment of the present invention, including: a determination unit 32 and a detection unit 33, wherein:
  • the determining unit used to determine whether the first access identifier Token carried in the first access response returned by the URL site to be detected is consistent with the second Token carried in the second access response returned by the URL site to be detected;
  • the access response is sent in response to the first login request carrying the login status information of the first user;
  • the second access response is sent in response to the second access request carrying the login status information of the second user; the first user and the first user Two users are different;
  • the detection unit when the first Token and the second Token are inconsistent, when a set time arrives, send a third access request carrying the login status information of the first user to the URL site to be detected; If the third Token in the third access response corresponding to the third access request is consistent with the first Token, it is determined that the URL site to be detected has a CSRF vulnerability.
  • the fourth access response corresponding to the fourth access request is consistent with the fifth access response, it is determined that the URL site to be detected has a CSRF vulnerability; the fifth access response is a legitimate access request of the URL site to be detected the response to.
  • the detection device further includes:
  • the acquiring unit 31 is configured to crawl each data packet of the URL site to be detected;
  • the determining unit is further configured to determine that the first Token and the second Token are not in the blacklist.
  • the cross-site request forgery CSRF defense authentication device provided by the foregoing embodiment of the present application can be implemented by a computer program.
  • Those skilled in the art should be able to understand that the above module division method is only one of many module division methods. If it is divided into other modules or not divided into modules, as long as the cross-site request forgery CSRF defense authentication device has the above functions, it should be Within the scope of protection of this application.
  • the processor is configured to call the program instructions stored in the memory, and execute the CSRF vulnerability detection method in the foregoing embodiment according to the obtained program.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

一种CSRF漏洞的检测方法及装置,其中方法包括:确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与待检测URL站点返回的第二访问响应中携带的第二Token是否一致;第一访问响应是针对携带第一用户登录态信息的第一访问请求发送的;第二访问响应是针对携带第二用户登录态信息的第二访问请求发送的;第一用户与第二用户不同;若不一致,则在设定时间到达时,向待检测URL站点发送携带第一用户登录态信息的第三访问请求;若第三访问请求对应的第三访问响应中的第三Token与第一Token一致,则确定待检测URL站点存在CSRF漏洞。由此,解决了现有技术中对CSRF漏洞检测存在检测手段单一、检测准确度不高的问题。

Description

一种CSRF漏洞的检测方法及装置
相关申请的交叉引用
本申请要求在2019年06月24日提交中国专利局、申请号为201910549709.X、申请名称为“一种CSRF漏洞的检测方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及金融科技(Fintech)技术领域,尤其涉及一种CSRF漏洞的检测方法及装置。
背景技术
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Finteh)转变,由于金融行业的安全性、实时性要求,因而对漏洞检测技术也提出了更高的要求。
跨站请求伪造(cross-site request forgery,CSRF)是一种对网站的恶意利用。部分金融平台在业务功能上存在着漏洞,CSRF使黑客可以冒充合法用户的身份,使合法用户在不知情的情况下触发如金融支付、转帐等危险操作,直接影响用户的资金、账号的安全。
目前已有针对CSRF的检测方法,但无论是手工检测还是自动化检测都存在检测手段单一、检测准确度不高的问题。
发明内容
本发明实施例提供一种CSRF漏洞的检测方法,旨在解决现有技术中对CSRF漏洞的检测手段单一、检测准确度不高的问题。
第一方面、本发明实施例提供一种跨站请求伪造CSRF漏洞的检测方法,包括:
确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL站点返回的第二访问响应中携带的第二Token是否一致;所述第一访问响应针对携带第一用户登录态信息的第一访问请求发送的;所述第二访问响应是针对携带第二用户登录态信息的第二访问请求发送的;所述第一用户与所述第二用户不同;
若不一致,则在设定时间到达时,向所述待检测URL站点发送携带所述第一用户登录态信息的第三访问请求;若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token一致,则确定所述待检测URL站点存在CSRF漏洞。
上述技术方案中,在CSRF漏洞的检测方式上增加了针对不同用户信息的Token进行检测,若不同用户在访问响应中的Token相同,则存在CSRF漏洞的可能性较大;在通过了针对不同用户信息的Token检测后,进行不同时段的Token检测;若同一用户在不同的时段内的Token相同,则存在CSRF漏洞的可能性较大。可以看出,上述技术方案中通过引入不同用户信息的Token检测及同一用户不同时段的Token检测,丰富了Token检测的手段,从而提升了检测准确度。
在一种可能的实现方式里,若服务器所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token不一致,还包括:
构造符合所述待检测URL站点的交互方式的第四访问请求;
向所述待检测URL站点发送所述第四访问请求;
若所述第四访问请求对应的第四访问响应与第五访问响应匹配,则确定所述待检测URL站点存在CSRF漏洞;所述第五访问响应是所述待检测URL站点的针对合法访问请求的响应。需要说明的是:第四访问请求也可以是第一访问请求,因而第五访问响应也可以是第一访问响应。
上述技术方案中,在不同用户信息的Token检测及同一用户不同时段的Token检测均通过后,进一步提供了构造的访问请求与合法的访问请求的检测方式;若构造的访问请求的响应与合法的访问请求的响应匹配,则确定存在 CSRF漏洞。从上述技术方案可以看出,本发明实施例进一步新增了检测手段,从而提升了检测准确度。
在一种可能的实现方式里,所述URL站点的交互方式为Ajax格式;向所述待检测URL站点发送所述第四访问请求之前,还包括:
设置所述第四访问请求的发送端支持跨域访问时携带cookie信息。
上述技术方案中,针对交互方式不同,构造出不同的访问请求从而使得CSRF漏洞的检测可实现,确保检测准确度。
在一种可能的实现方式里,确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL页面返回的第二访问响应中携带的第二Token是否一致之前,还包括:
爬取所述待检测URL站点的各数据包;从所述各数据包中获取所述第一访问响应和所述第二访问响应;或构造所述第一登录请求并发送至所述待检测URL站点;构造所述第二登录请求并发送至所述待检测URL站点。
上述技术方案中,提供了两种关于登录请求的实现方式,一种为通过爬取网络上的数据包,此方式可以使得构造的登录请求与实际情况相符合;另一种为直接构造登录请求,并发送至所述待检测URL站点,此方式可以使得构造更灵活。
在另一种可能的实现方式里,确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL页面返回的第二访问响应中携带的第二Token是否一致之前,还包括:
确定所述第一Token和所述第二Token不在黑名单中。
上述技术方案,在进行不同用户信息的Token检测之前,还进行黑名单判断;若Token在黑名单中,则确定存在CSRF漏洞;否则才进行不同用户信息的Token检测。此技术方案可以进一步提升CSRF漏洞的检测效率。
第二方面、本发明实施例还提供了一种跨站请求伪造CSRF漏洞的检测装置,所述装置包括:
确定单元:用于确定待检测URL站点返回的第一访问响应中携带的第一 访问标识Token与所述待检测URL站点返回的第二访问响应中携带的第二Token是否一致;所述第一访问响应针对携带第一用户登录态信息的第一登录请求发送的;所述访问响应是针对携带第二用户登录态信息的第二登录请求发送的;所述第一用户与所述第二用户不同;
检测单元:用于在所述第一Token和所述第二Token不一致时,在设定时间到达时,向所述待检测URL站点发送携带所述第一用户登录态信息的第三访问请求;若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token一致,则确定所述待检测URL站点存在CSRF漏洞。
在一种可能的实现方式里,所述检测单元还用于:
构造符合所述待检测URL站点的交互方式的第四访问请求;
向所述待检测URL站点发送所述第四访问请求;
若所述第四访问请求对应的第四访问响应与第五访问响应匹配,则确定所述待检测URL站点存在CSRF漏洞;所述第五访问响应是所述待检测URL站点的针对合法访问请求的响应。
在一种可能的实现方式里,检测装置还包括:
获取单元,用于爬取所述待检测URL站点的各数据包;
所述确定单元:还用于确定所述第一Token和所述第二Token不在黑名单中。
第三方面、本发明实施例还提供了一种计算设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行第一方面或第一方面中任一实施例的方法。
第四方面、本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行第一方面或第一方面中任一实施例的方法。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本发明的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1为本发明实施例提供的一种可能的系统架构示意图;
图2为本发明实施例提供的一种CSRF漏洞的检测方法实施流程示意图;
图3为本发明实施例提供的一种CSRF漏洞的检测置示意图。
具体实施方式
为了使本发明的目的、技术方案及有益效果更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
图1为本申请提供的一种可能的系统架构示意图,如图1所示,包括:多个访问设备101、访问服务器102。其中访问设备101可以为个人电脑、手机终端等,访问服务器102为用户提供页面访问服务的站点。
针对每个访问设备101,在对访问服务器102进行访问时,一般需要先进行登录操作。具体为,访问设备101向访问服务器102发送登录请求,登录请求中包含了标识用户身份的信息,通常为用户名及密码。访问服务器102在验证通过登录请求后,会向访问设备101发送访问响应,该访问响应中一般会携带访问服务器102为用户分配的Cookie信息。Cookie信息会预先存储在访问设备101的浏览器中,这样以来用户在后续访问该访问服务器102时无需再次填写登录信息。但是,若访问设备101被植入了CSRF漏洞,则浏览器会在用户不知情的情况下,通过使用Cookie信息向访问服务器102发送各种访问请求。
实施例一:
为了检测上述CSRF漏洞,如图2所示,本发明实施例提供了一种的跨站请求伪造CSRF漏洞的检测方法,包括以下步骤:
S11、确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token;所述第一访问响应针对携带第一用户登录态信息的第一访问请求发送的。
S12、确定所述待检测URL站点返回的第二访问响应中携带的第二Token;所述第二访问响应是针对携带第二用户登录态信息的第二访问请求发送的;所述第一用户与所述第二用户不同。
上述步骤S11和步骤S12之前没有先后关系,只要能获取到两个不同用户针对同一URL站点返回的两个Token即可。
S13、判断第一访问标识Token与第二Token是否一致。
S14、若不一致,则在设定时间到达时,向所述待检测URL站点发送携带所述第一用户登录态信息的第三访问请求。
步骤S14中的设定时间可以自行设定,以满足Cookie信息的有效使用时长为准。此步骤虽然以第一Token为例进行说明,实际上也可以是第二Token,或者第三Token,只要Token满足两次访问的时间达到了设定时间。
具体来说,比如上午10:00一个银行用户查询了帐户余额,假设此时获取的为TokenA,如果设定时间为2分钟,上午10:03再次查询了帐户余额或转帐,假设此时获取的为TokenB,TokenA和TokenB不同。
S15、若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token一致,则确定所述待检测URL站点存在CSRF漏洞。上述实施方案中,在步骤S13中进行了不同用户信息的Token检测,避免不同用户具有相同Token时导致的CSRF漏洞;在步骤S15中进行了同一用户不同时段的Token检测,从而避免因Token有效时长过长导致的CSRF漏洞。
在一种可能的实现方式中,以图2为例,在步骤S15之后,还包括若所述待检测URL站点所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token不一致,所述方法还包括:
S16、构造符合所述待检测URL站点的交互方式的第四访问请求。
S17、向所述待检测URL站点发送所述第四访问请求。
S18、若所述第四访问请求对应的第四访问响应与第五访问响应匹配,则确定所述待检测URL站点存在CSRF漏洞;所述第五访问响应是所述待检测URL站点的针对合法访问请求的响应。
在上述实现方式中,针对合法访问请求的响应,构造一个与合法访问请求类似或一致的第四访问请求;若第四访问请求对应的第四访问响应与第五访问响应匹配,则确定所述待检测URL站点存在CSRF漏洞。
以合法访问请求为针对发表内容的修改请求为例,根据爬取到的合法访问请求,构造第四访问请求;第四访问请求的内容可以与合法访问请求一样。若接到第四访问响应,则确定第四访问响应和合法访问请求对应的第五访问响应是否匹配,如返回的页面是否一致或相似度是否大于相似阈值;若匹配则确定所述待检测URL站点存在CSRF漏洞。若待检测URL站点拒绝第四访问请求,则认为具有CSRF漏洞的防御能力。需要说明的是:第四访问请求可以是上述步骤S11中的第一访问请求,因而第五访问响应也可以是第一访问响应。
在一种可能的实现方式中,以图2为例,在步骤S11之前,还包括:
步骤S10、确定所述第一Token和所述第二Token不在黑名单中。在进行不同用户信息的Token检测之前,还进行黑名单判断;若爬取的Token在黑名单中,则确定存在CSRF漏洞;否则才进行不同用户信息的Token检测。此技术方案可以进一步提升CSRF漏洞的检测效率。
针对步骤S11中的第一访问响应和步骤S12中的第二访问响应,提供如下两种可能的实现方式。
方式一:爬取所述待检测URL站点的各数据包;从所述各数据包中获取所述第一访问响应和所述第二访问响应。
方式二:构造所述第一访问请求并发送至所述待检测URL站点;构造所述第二访问请求并发送至所述待检测URL站点。
通过网络爬取来获取用户的历史访问信息可以构造更有效更简洁的检测方式。如对步骤S11和步骤S12,只要比对爬取的不同用户的Token信息即可, 同时,还可以对网络上诸多用户进行比较,进一步确保了检测手段的准确性。
目前,针对CSRF漏洞的检测方式中,基本是提交Form格式的访问请求;但待检测站点可能会存在JSON、XML格式的请求体,此时会出现无法用Form格式来提供可进行访问的访问请求。基于此,本发明实施例提供了一种基于待检测站点不同格式的访问请求进行CSRF漏洞检测。具体来说,针对步骤S16构造符合所述待检测URL站点的交互方式的第四访问请求,提供如下两种实现方式。
通常情况下,通过爬取到的页面代码中的Form标签,就能判断是否为Form格式的访问请求。如下代码1为一个合法访问请求,可以看出为具有Form标签的Form格式的访问请求。
<form action="action_page.php">
First name:<br>
<input type="text"name="firstname"value="Mickey">
<br>
Last name:<br>
<input type="text"name="lastname"value="Mouse">
<br><br>
<input type="submit"value="Submit">
</form>
如果为Form格式的访问请求,在本地HTML文件中增加代码,通过替换<input>的name和value来构造第四访问请求,如下代码2为一个示例:
<body onload="document.forms[0].submit()">
<form action="http://bank.com/transfer.do"method="POST">
<input type="hidden"name="acct"value="MARIT"/>
<input type="hidden"name="amount"value="100000"/>
<input type="submit"name="View my picture"/>
<form>
通过比对代码1的合法访问请求对应的第五访问应答与第四访问请求对 应的第四访问应答,来确定是否存在CSRF漏洞。
通过爬取到的页面代码中的Ajax标签,就能判断是否为Ajax交互方式的访问请求。如果判断该提交是ajax交互方式,则通过替换send的数据来构造Ajax交互方式发送的第四访问请求。Ajax交互方式的例子如下代码3:
Figure PCTCN2020096900-appb-000001
在实施上述检测方式,如果构造Ajax交互方式发送的请求,浏览器会校验客户端和服务器端是不是在同一个域,如果不在同一个域。则需要设置发送端的withCredentials属性为True,即支持跨域访问时携带cookie信息。换言之,需要将访问设备101的浏览器设置为支持跨域访问时携带cookie信息,从而可以进行上述的检测过程。
跨域请求是指当前发起的请求的域与该请求指向的资源所在的域不同,这里协议、域名、端口号皆相同的就是同域。
如果是构造的Form表单格式提交的请求,访问设备101的浏览器不去校验其所在的域与待检测站点的域是否相同,直接发送出去,因此不需要设置访问设备101的浏览器支持跨域请求。
但当构造Ajax交互方式的发送请求时,访问设备101的浏览器就会去校验其所在的域与待检测站点所在的域是否相同,如果不同,访问设备101的浏览器不会将请求发出去,这时需要设置访问设备101的浏览器支持跨域请求。
上述技术方案中,针对报文格式不同,构造出不同的访问请求从而使得 CSRF漏洞的检测可实现,确保检测准确度。
基于同一发明构思,本发明实施例中还提供了一种跨站请求伪造CSRF漏洞的检测装置,由于上述装置解决问题的原理与跨站请求伪造CSRF漏洞的检测方法相似,因此上述装置的实施可以参见方法的实施,重复之处不再赘述。
如图3所示,为本发明实施例提供的一种CSRF漏洞的检测装置的结构示意图,包括:确定单元32和检测单元33,其中:
确定单元:用于确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL站点返回的第二访问响应中携带的第二Token是否一致;所述第一访问响应针对携带第一用户登录态信息的第一登录请求发送的;所述第二访问响应是针对携带第二用户登录态信息的第二访问请求发送的;所述第一用户与所述第二用户不同;
检测单元:用于在所述第一Token和所述第二Token不一致时,在设定时间到达时,向所述待检测URL站点发送携带所述第一用户登录态信息的第三访问请求;若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token一致,则确定所述待检测URL站点存在CSRF漏洞。
进一步地,所述检测单元还用于:
构造符合所述待检测URL站点的交互方式的第四访问请求;
向所述待检测URL站点发送所述第四访问请求;
若所述第四访问请求对应的第四访问响应与第五访问响应一致,则确定所述待检测URL站点存在CSRF漏洞;所述第五访问响应是所述待检测URL站点的针对合法访问请求的响应。
具体实施时,所述检测装置,还包括:
获取单元31,用于爬取所述待检测URL站点的各数据包;
所述确定单元:还用于确定所述第一Token和所述第二Token不在黑名单中。
本申请的上述实施例所提供的跨站请求伪造CSRF防御认证装置可通过 计算机程序实现。本领域技术人员应该能够理解,上述的模块划分方式仅是众多模块划分方式中的一种,如果划分为其他模块或不划分模块,只要跨站请求伪造CSRF防御认证装置具有上述功能,都应该在本申请的保护范围之内。
基于同一发明构思,本发明实施例还提供了一种计算机设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述实施例中CSRF漏洞的检测方法。
基于同一发明构思,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述实施例中的CSRF漏洞的检测方法。本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (10)

  1. 一种跨站请求伪造CSRF漏洞的检测方法,其特征在于,所述方法包括:
    确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL站点返回的第二访问响应中携带的第二Token是否一致;所述第一访问响应针对携带第一用户登录态信息的第一访问请求发送的;所述第二访问响应是针对携带第二用户登录态信息的第二访问请求发送的;所述第一用户与所述第二用户不同;
    若不一致,则在设定时间到达时,向所述待检测URL站点发送携带所述第一用户登录态信息的第三访问请求;
    若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token一致,则确定所述待检测URL站点存在CSRF漏洞。
  2. 如权利要求1所述的检测方法,其特征在于,若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token不一致,所述方法还包括:
    构造符合所述待检测URL站点的交互方式的第四访问请求;
    向所述待检测URL站点发送所述第四访问请求;
    若所述第四访问请求对应的第四访问响应与第五访问响应匹配,则确定所述待检测URL站点存在CSRF漏洞;所述第五访问响应是所述待检测URL站点的针对合法访问请求的响应。
  3. 如权利要求2所述的检测方法,其特征在于,所述URL站点的交互方式为Ajax;
    向所述待检测URL站点发送所述第四访问请求之前,还包括:
    设置所述第四访问请求的发送端支持跨域访问时携带cookie信息。
  4. 如权利要求1所述的检测方法,其特征在于,确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL页面返 回的第二访问响应中携带的第二Token是否一致之前,还包括:
    爬取所述待检测URL站点的各数据包;从所述各数据包中获取所述第一访问响应和所述第二访问响应;或
    构造所述第一访问请求并发送至所述待检测URL站点;构造所述第二访问请求并发送至所述待检测URL站点。
  5. 如权利要求1所述的检测方法,其特征在于,确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL页面返回的第二访问响应中携带的第二Token是否一致之前,还包括:
    确定所述第一Token和所述第二Token不在黑名单中。
  6. 一种跨站请求伪造CSRF漏洞的检测装置,其特征在于,所述装置包括:
    确定单元:用于确定待检测URL站点返回的第一访问响应中携带的第一访问标识Token与所述待检测URL站点返回的第二访问响应中携带的第二Token是否一致;所述第一访问响应针对携带第一用户登录态信息的第一登录请求发送的;所述第二访问响应是针对携带第二用户登录态信息的第二访问请求发送的;所述第一用户与所述第二用户不同;
    检测单元:用于在所述第一Token和所述第二Token不一致时,在设定时间到达时,向所述待检测URL站点发送携带所述第一用户登录态信息的第三访问请求;若所述第三访问请求对应的第三访问响应中的第三Token与所述第一Token一致,则确定所述待检测URL站点存在CSRF漏洞。
  7. 如权利要求6所述的检测装置,其特征在于,所述检测单元还用于:
    构造符合所述待检测URL站点的交互方式的第四访问请求;
    向所述待检测URL站点发送所述第四访问请求;
    若所述第四访问请求对应的第四访问响应与第五访问响应匹配,则确定所述待检测URL站点存在CSRF漏洞;所述第五访问响应是所述待检测URL站点的针对合法访问请求的响应。
  8. 如权利要求6所述的检测装置,其特征在于,还包括:
    获取单元,用于爬取所述待检测URL站点的各数据包;
    所述确定单元:还用于确定所述第一Token和所述第二Token不在黑名单中。
  9. 一种计算机设备,其特征在于,包括:
    存储器,用于存储程序指令;
    处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至5任一项所述的方法。
  10. 一种计算机可读非易失性存储介质,其特征在于,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如权利要求1至5任一项所述的方法。
PCT/CN2020/096900 2019-06-24 2020-06-18 一种csrf漏洞的检测方法及装置 Ceased WO2020259389A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910549709.XA CN110113366B (zh) 2019-06-24 2019-06-24 Csrf漏洞的检测方法及装置,计算设备和存储介质
CN201910549709.X 2019-06-24

Publications (1)

Publication Number Publication Date
WO2020259389A1 true WO2020259389A1 (zh) 2020-12-30

Family

ID=67495661

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/096900 Ceased WO2020259389A1 (zh) 2019-06-24 2020-06-18 一种csrf漏洞的检测方法及装置

Country Status (2)

Country Link
CN (1) CN110113366B (zh)
WO (1) WO2020259389A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114357460A (zh) * 2021-12-28 2022-04-15 中国农业银行股份有限公司 漏洞检测方法、装置、设备及存储介质
CN114499960A (zh) * 2021-12-24 2022-05-13 深圳开源互联网安全技术有限公司 一种csrf漏洞识别方法、装置及计算机可读存储介质

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110113366B (zh) * 2019-06-24 2022-12-27 深圳前海微众银行股份有限公司 Csrf漏洞的检测方法及装置,计算设备和存储介质
CN111104675A (zh) * 2019-11-15 2020-05-05 泰康保险集团股份有限公司 系统安全漏洞的检测方法和装置
CN111404937B (zh) * 2020-03-16 2021-12-10 腾讯科技(深圳)有限公司 一种服务器漏洞的检测方法和装置
CN111737695B (zh) * 2020-06-24 2025-02-07 深圳前海微众银行股份有限公司 白名单优化方法、装置、设备与计算机可读存储介质
CN111597424A (zh) * 2020-07-21 2020-08-28 平安国际智慧城市科技股份有限公司 爬虫识别方法、装置、计算机设备和存储介质
CN112419674A (zh) * 2020-10-26 2021-02-26 四川大学 一种泥石流地质灾害的监测系统及方法
CN112866265B (zh) * 2021-01-27 2023-03-24 湖南快乐阳光互动娱乐传媒有限公司 一种csrf攻击防护方法及装置
CN114567472B (zh) * 2022-02-22 2024-07-09 深信服科技股份有限公司 一种数据处理方法、装置、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100146291A1 (en) * 2008-12-08 2010-06-10 Oracle International Corporation Secure framework for invoking server-side apis using ajax
CN108429746A (zh) * 2018-03-06 2018-08-21 华中科技大学 一种面向云租户的隐私数据保护方法及系统
CN108769070A (zh) * 2018-06-30 2018-11-06 平安科技(深圳)有限公司 一种越权漏洞检测方法及装置
CN110113366A (zh) * 2019-06-24 2019-08-09 深圳前海微众银行股份有限公司 一种csrf漏洞的检测方法及装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8601586B1 (en) * 2008-03-24 2013-12-03 Google Inc. Method and system for detecting web application vulnerabilities
CN104573486B (zh) * 2013-10-16 2018-09-28 深圳市腾讯计算机系统有限公司 漏洞检测方法和装置
CN104660556B (zh) * 2013-11-20 2018-06-01 深圳市腾讯计算机系统有限公司 跨站伪造请求漏洞检测的方法及装置
CN108197467A (zh) * 2018-01-11 2018-06-22 郑州云海信息技术有限公司 一种csrf漏洞的自动化检测方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100146291A1 (en) * 2008-12-08 2010-06-10 Oracle International Corporation Secure framework for invoking server-side apis using ajax
CN108429746A (zh) * 2018-03-06 2018-08-21 华中科技大学 一种面向云租户的隐私数据保护方法及系统
CN108769070A (zh) * 2018-06-30 2018-11-06 平安科技(深圳)有限公司 一种越权漏洞检测方法及装置
CN110113366A (zh) * 2019-06-24 2019-08-09 深圳前海微众银行股份有限公司 一种csrf漏洞的检测方法及装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114499960A (zh) * 2021-12-24 2022-05-13 深圳开源互联网安全技术有限公司 一种csrf漏洞识别方法、装置及计算机可读存储介质
CN114499960B (zh) * 2021-12-24 2024-03-22 深圳开源互联网安全技术有限公司 一种csrf漏洞识别方法、装置及计算机可读存储介质
CN114357460A (zh) * 2021-12-28 2022-04-15 中国农业银行股份有限公司 漏洞检测方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN110113366A (zh) 2019-08-09
CN110113366B (zh) 2022-12-27

Similar Documents

Publication Publication Date Title
WO2020259389A1 (zh) 一种csrf漏洞的检测方法及装置
US10554655B2 (en) Method and system for verifying an account operation
US8122251B2 (en) Method and apparatus for preventing phishing attacks
US9578004B2 (en) Authentication of API-based endpoints
US9870464B1 (en) Compromised authentication information clearing house
KR102069759B1 (ko) 캡차(captcha) 챌린지의 동적 업데이트
US9838384B1 (en) Password-based fraud detection
TWI620090B (zh) 用於偵測網路釣魚之登入失敗序列
US10574697B1 (en) Providing a honeypot environment in response to incorrect credentials
CN102571846B (zh) 一种转发http请求的方法及装置
US10015191B2 (en) Detection of man in the browser style malware using namespace inspection
US10176318B1 (en) Authentication information update based on fraud detection
CN103618717B (zh) 多账户客户信息的动态认证方法、装置和系统
US10015171B1 (en) Authentication using metadata from posts made to social networking websites
US20210099431A1 (en) Synthetic identity and network egress for user privacy
US10630574B2 (en) Link processing method, apparatus, and system
US11770385B2 (en) Systems and methods for malicious client detection through property analysis
CN104734849A (zh) 对第三方应用进行鉴权的方法及系统
US10834074B2 (en) Phishing attack prevention for OAuth applications
CN110704820A (zh) 登录处理方法、装置、电子设备和计算机可读存储介质
CN104601558A (zh) 防御跨站请求伪造攻击的方法及装置
CA2844888A1 (en) System and method of extending a host website
US20200110868A1 (en) Augmented push authentication
US12039054B2 (en) Systems and methods for dynamic detection of vulnerable credentials
CN110858836A (zh) 网络攻击防御方法及设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20830733

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20830733

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 05/04/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20830733

Country of ref document: EP

Kind code of ref document: A1