TWI506471B - System and method for defending against cross-site scripting - Google Patents

System and method for defending against cross-site scripting Download PDF

Info

Publication number
TWI506471B
TWI506471B TW100148781A TW100148781A TWI506471B TW I506471 B TWI506471 B TW I506471B TW 100148781 A TW100148781 A TW 100148781A TW 100148781 A TW100148781 A TW 100148781A TW I506471 B TWI506471 B TW I506471B
Authority
TW
Taiwan
Prior art keywords
webpage
address
checked
cross
script
Prior art date
Application number
TW100148781A
Other languages
Chinese (zh)
Other versions
TW201327250A (en
Inventor
Shi Jinn Horng
Wei Feng Hsu
Original Assignee
Univ Nat Taiwan Science Tech
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 Univ Nat Taiwan Science Tech filed Critical Univ Nat Taiwan Science Tech
Priority to TW100148781A priority Critical patent/TWI506471B/en
Publication of TW201327250A publication Critical patent/TW201327250A/en
Application granted granted Critical
Publication of TWI506471B publication Critical patent/TWI506471B/en

Links

Landscapes

  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Description

跨網站攻擊防範系統及方法Cross-site attack prevention system and method

本發明係與一種跨網站攻擊防範系統及方法有關,並且係特別地與一種設置於網站伺服器中,可簡化架設流程並提供有效防禦機制之跨網站攻擊防範系統及方法有關。The present invention relates to a cross-site attack prevention system and method, and is particularly related to a cross-site attack prevention system and method that is installed in a web server to simplify the setup process and provide an effective defense mechanism.

隨著網際網路的快速發展與普及化,網頁內容也變得越來越豐富,同時,網頁的構成方式亦從早期的靜態網頁,發展成為大量運用動態網頁技術之動態網頁。由於網頁技術的發展使得網頁應用更多元化,並提供了更多互動性。然而,其也同時產生了各種網頁系統的安全性問題,而增加電腦防護系統偵測入侵及安全防護的困難度。With the rapid development and popularization of the Internet, web content has become more and more abundant. At the same time, the composition of web pages has evolved from an early static web page to a dynamic web page using a large number of dynamic web technologies. Due to the development of web technology, web applications are more diversified and provide more interactivity. However, it also creates security issues for various web systems, and increases the difficulty of computer protection systems to detect intrusions and security.

跨網站攻擊(Cross-Site Scripting,XSS)是目前全球最嚴重的資安弱點之一,其係為一種典型的網頁安全漏洞,攻擊者可利用這個漏洞來竊取使用者cookie或是使用者資料。跨網站攻擊的攻擊手法,通常是攻擊者會在網站伺服器所提供的網頁之程式碼內,嵌入惡意的腳本參數(script),接著再利用社交工程手法來吸引網頁瀏覽者點擊。當瀏覽者點擊後,若網路伺服器所提供網頁的應用程式並未將多餘程式碼濾除,其之瀏覽器便會執行惡意的腳本參數程式碼,而將受害者的cookie傳送到攻擊者預先建立的第三方網站,因此攻擊者可藉此竊取受害者的私密資料,例如網路帳號、密碼、甚至是信用卡號碼等。其不僅對於使用者個人的資訊安全而言傷害甚大,跨網站攻擊的影響層面可說不論是對民生、經濟、甚至國防方面都有重大影響。Cross-Site Scripting (XSS) is one of the most serious security weaknesses in the world. It is a typical web security vulnerability that can be exploited by attackers to steal user cookies or user data. The attack method of cross-site attack is usually that the attacker embeds malicious script parameters in the code of the webpage provided by the web server, and then uses social engineering techniques to attract webpage viewers to click. When the browser clicks, if the application provided by the web server does not filter the redundant code, the browser will execute the malicious script parameter code and transmit the victim's cookie to the attacker. Pre-established third-party websites, so attackers can steal private information about victims, such as online accounts, passwords, and even credit card numbers. Not only does it hurt the user's personal information security, but the impact of cross-site attacks can be said to have a major impact on people's livelihood, economy, and even national defense.

基於現今網路應用程式講求互動性的趨勢,網頁架構相較之前更趨複雜,在在增加了偵測跨網站攻擊的技術困難度與複雜度,即使是經驗豐富的程式開發人員也不容易針對各類程式碼做完全的過濾。此外,就使用者觀點而言,一般大眾對跨網站攻擊的認知更為薄弱,因此要期待一般使用者發現或防禦跨網站攻擊是極為困難的。Based on the trend of interactive web applications today, the web architecture is more complex than before, and the technical difficulty and complexity of detecting cross-site attacks are increasing. Even experienced programmers are not easy to target. All kinds of code are completely filtered. In addition, from a user's point of view, the general public's perception of cross-site attacks is weaker, so it is extremely difficult to expect general users to discover or defend against cross-site attacks.

目前對於防範跨網站攻擊的系統架設,包含設置於用戶端、設置於伺服器端,以及混合設置於用戶端與伺服器端等三種架構。設置於用戶端之方法對於大多數的網路使用者來說,安裝及設定防範系統的步驟過於複雜,大多數使用者無法對跨網站攻擊做出判定,因此這樣的解決方法不容易導入在日常生活應用上。混合設置於用戶端與伺服器端之方法則更為繁瑣,除了必須克服上述設置於用戶端之困難外,在伺服器端所設置之系統也需要配合用戶端之系統,因而倍增其複雜度。At present, the system erection for preventing cross-site attacks includes three configurations: setting on the client side, setting on the server side, and mixing on the client side and the server side. The method of setting up on the user side is too complicated for most network users to install and set up the prevention system. Most users cannot make judgments on cross-site attacks, so this solution is not easy to import into daily life. Life application. The method of mixing and setting on the client side and the server side is more complicated. In addition to the difficulty of setting the above-mentioned setting on the user side, the system set on the server side also needs to cooperate with the system of the user end, thereby multiplying the complexity.

此外,設置於伺服器端之系統需要程式開發人員花時間設定及測試防火牆規則,雖然比起上述兩種方式較不複雜,然而,設定這樣的法則仍然相當不容易,程式開發人員必須經驗豐富並且相當謹慎,才能設定出具有足夠防範能力之系統。因此,有必要發展一種可簡易設定的偵測系統,同時具有效率的防禦能力,以便應付隨時可能發生的跨網站攻擊,而將危害降到最低。In addition, the system set on the server side requires the programmer to take the time to set and test the firewall rules. Although it is less complicated than the above two methods, it is still not easy to set such a rule. The program developer must be experienced and Be cautious to set up a system with sufficient defense capabilities. Therefore, it is necessary to develop an easily configurable detection system with an efficient defense capability to cope with cross-site attacks that may occur at any time to minimize the harm.

因此,本發明之一範疇在於提供一種跨網站攻擊防範系統,其可簡易地設置於網站伺服器端並提供有效的防禦能力,以解決先前技術之問題。Accordingly, one aspect of the present invention is to provide a cross-site attack prevention system that can be easily placed on a web server side and provides an effective defense capability to solve the problems of the prior art.

根據一具體實施例,本發明之跨網站攻擊防範系統係被設置於網站伺服器中,其中,網站伺服器可供用戶端登入並根據用戶端之要求,來將網頁資料提供給用戶端。跨網站攻擊防範系統包含有資料庫、過濾引擎、網頁爬蟲以及腳本參數偵測器。According to a specific embodiment, the cross-site attack prevention system of the present invention is set in a website server, wherein the website server is available for the user to log in and provide the webpage information to the client according to the requirements of the user. The cross-site attack prevention system includes a database, a filtering engine, a web crawler, and a script parameter detector.

於本具體實施例中,資料庫內儲存有白名單表格,並且白名單表格中存有至少一個允許網頁位址。過濾引擎係連接至資料庫,其可用來比對網站伺服器所提供之網頁資料中所包含的待查網頁位址,與白名單表格中的允許網頁位址是否相同,並且可判斷網頁位址是否包含腳本參數,同時可以空白字元來取代網頁資料中之待查網頁位址。網頁爬蟲係連接至過濾引擎與資料庫,以讀取待查網頁位址並下載其中之腳本參數。腳本參數偵測器係連接至網頁爬蟲,以偵測網頁爬蟲所下載的腳本參數中,是否包含有將用戶端的資料傳送至第三方網站的行為。由於本具體實施例之網站攻擊防範系統,係將可疑的待查網頁位址先以空白字元輸出,故可防止使用者點擊惡意程式碼而導致其遭受跨網站攻擊的情況。In this embodiment, a whitelisted form is stored in the database, and at least one allowed webpage address is stored in the whitelisted form. The filtering engine is connected to the database, which can be used to compare the address of the to-be-checked webpage included in the webpage provided by the web server, and whether the allowed webpage address in the whitelisted table is the same, and can determine the webpage address. Whether the script parameter is included, and the blank character is used instead of the web address to be checked in the webpage data. The web crawler is connected to the filtering engine and database to read the web address to be checked and download the script parameters. The script parameter detector is connected to the web crawler to detect whether the script parameters downloaded by the web crawler contain the behavior of transmitting the data of the client to the third party website. Because the website attack defense system of the specific embodiment outputs the suspicious webpage address to be searched by blank characters, it can prevent the user from clicking the malicious code and causing the cross-site attack.

本發明之一範疇在於提供一種跨網站攻擊防範方法,其係應用於網站伺服器中,以有效地提供對抗跨網站攻擊的防禦能力。One aspect of the present invention is to provide a cross-site attack prevention method that is applied to a web server to effectively provide defense against cross-site attacks.

根據一具體實施例,本發明之跨網站攻擊防範方法首先可比對網站伺服器所提供之網頁資料中,所包含的待查網頁位址,與白名單表格所儲存的允許網頁位址是否相同。接著,根據比對之結果,選擇性地以空白字元取代網頁資料中的待查網頁位址,同時判斷待查網頁位址中是否包含有腳本參數。根據判斷之結果,再選擇性地下載待查網頁位址之腳本參數。最後,偵測所下載之腳本參數是否有將用戶端的資料傳送至第三方網站之行為。According to a specific embodiment, the cross-site attack prevention method of the present invention can first compare whether the webpage address to be inspected included in the webpage information provided by the web server is the same as the allowable webpage address stored in the whitelisted form. Then, according to the result of the comparison, the blank page character is used to replace the to-be-checked webpage address in the webpage data, and the script parameter is included in the webpage address to be checked. According to the result of the judgment, the script parameter of the webpage address to be checked is selectively downloaded. Finally, it is detected whether the downloaded script parameter has the function of transmitting the data of the client to the third-party website.

於本具體實施例中,跨網站攻擊防範方法可於待查網頁位址與白名單表格中之允許網頁位址之比對不相同時,將網頁資料中之待查網頁位址以空白字元取代,而使網站伺服器以空白字元取代後之網頁資料提供給用戶端,並進一步判斷待查網頁位址中是否包含有腳本參數。當判斷待查網頁位址中包含腳本參數時,在背景狀態下載待查網頁所包含的腳本參數,並偵測所下載的腳本參數是否有將用戶端的資料傳送至第三方網站之行為。由於本具體實施例之網站攻擊防範方法,係將可疑的待查網頁位址先以空白字元輸出,故可防止使用者點擊惡意程式碼導致其遭受跨網站攻擊的情況。In this embodiment, the cross-site attack prevention method may use a blank character in the webpage of the webpage to be inspected when the ratio of the webpage address to the webpage address in the whitelisted table is different from the allowed webpage address. Instead, the webpage data replaced by the blank character is provided to the client, and the webpage address is further determined whether the script parameter is included in the webpage address to be checked. When it is determined that the webpage address to be checked includes the script parameter, the script parameter included in the webpage to be checked is downloaded in the background state, and the downloaded script parameter is detected whether there is a behavior of transmitting the data of the client to the third-party website. Because of the website attack prevention method in the specific embodiment, the suspicious webpage address to be inspected is first outputted as a blank character, thereby preventing the user from clicking a malicious code to cause a cross-site attack.

關於本發明之優點與精神可以藉由以下的發明詳述及所附圖式得到進一步的瞭解。The advantages and spirit of the present invention will be further understood from the following detailed description of the invention.

請參閱圖一,圖一係繪示根據本發明之一具體實施例之跨網站攻擊防範系統1的示意圖。如圖一所示,跨網站攻擊防範系統1係設置於網站伺服器2之中,而網站伺服器2可供用戶端3登入。網站伺服器2中具有應用程式20可供用戶端3登入,當用戶端3登入應用程式20時會對網站伺服器2提出瀏覽網頁資料的請求,應用程式20則可根據請求而自網頁資料庫22中取出相對應的網頁資料輸出給用戶端3。Referring to FIG. 1, FIG. 1 is a schematic diagram of a cross-site attack defense system 1 according to an embodiment of the present invention. As shown in FIG. 1, the cross-site attack prevention system 1 is installed in the website server 2, and the website server 2 is available for the client 3 to log in. The web server 2 has an application 20 for the client 3 to log in. When the client 3 logs in to the application 20, the web server 2 is requested to browse the webpage, and the application 20 can request the webpage from the webpage according to the request. 22 takes out the corresponding webpage data and outputs it to the client 3.

於本具體實施例中,跨網站攻擊防範系統1可包含資料庫10、過濾引擎12、網頁爬蟲14以及腳本參數偵測器16。資料庫10中建立有白名單表格100,並且,白名單表格100中係儲存有至少一個允許網頁位址。請注意,白名單表格100中之允許網頁位址,係為已經過判斷無跨網站攻擊之網頁位址,用戶端3利用其瀏覽器點擊允許網頁位址時並不會遭受到跨網站攻擊。白名單表格100中之允許網頁位址可由網站伺服器2的管理者進行手動儲存,也可由本具體實施例之跨網站攻擊防範系統1進行自動儲存,關於以跨網站攻擊防範系統1將允許網頁位址自動儲存於白名單表格100之詳細內容,將於以下段落中進行說明。In this embodiment, the cross-site attack prevention system 1 may include a database 10, a filtering engine 12, a web crawler 14, and a script parameter detector 16. A whitelisted form 100 is created in the database 10, and at least one allowed webpage address is stored in the whitelisted form 100. Please note that the allowed webpage address in the whitelisting table 100 is a webpage address that has been judged to have no cross-site attack, and the client 3 does not suffer from cross-site attacks when clicking on the allowed webpage address by using the browser. The allowable webpage address in the whitelist table 100 can be manually stored by the administrator of the web server 2, or can be automatically stored by the cross-site attack prevention system 1 of the specific embodiment, and the webpage will be allowed for the cross-site attack prevention system 1 The details of the address automatically stored in the whitelist form 100 are described in the following paragraphs.

過濾引擎12係連接到資料庫10,網頁爬蟲14係連接至過濾引擎12以及資料庫10,並且,腳本參數偵測器16係連接至到網頁爬蟲14。過濾引擎12係於本具體實施例中進一步連接到應用程式20,然而,於實務中,過濾引擎12也可直接設置於應用程式20中,本發明對此並不加以限制。過濾引擎12可比對應用程式20自應用程式資料庫22內所取出之網頁資料中的待查網頁位址,與資料庫10之白名單表格100中所儲存的允許網頁位址是否相同。此外,過濾引擎12還可判斷待查網頁位址是否包含有腳本參數,例如,javascript。更甚者,過濾引擎12亦可將網頁資料中之待查網頁位址以空白字元來取代,而使應用程式20可將以空白字元取代後之網頁資料輸出給用戶端3。The filtering engine 12 is connected to the repository 10, the web crawler 14 is connected to the filtering engine 12 and the repository 10, and the script parameter detector 16 is connected to the web crawler 14. The filtering engine 12 is further connected to the application 20 in this embodiment. However, in practice, the filtering engine 12 can also be directly disposed in the application 20, which is not limited by the present invention. The filtering engine 12 can compare whether the to-be-checked webpage address in the webpage data extracted from the application repository 22 by the application 20 is the same as the allowed webpage address stored in the whitelisted table 100 of the repository 10. In addition, the filtering engine 12 can also determine whether the web address to be checked contains script parameters, such as javascript. Moreover, the filtering engine 12 can also replace the to-be-checked webpage address in the webpage data with a blank character, so that the application 20 can output the webpage data replaced by the blank character to the client 3.

網頁爬蟲14係連接至過濾引擎12以及資料庫10,以讀取待查網頁位址並下載待查網頁位址中所包含之腳本參數,例如,javascript等。於本具體實施例中,資料庫10除了包含有白名單表格100之外,還包含有連接到過濾引擎12及網頁爬蟲14之待查名單暫存表格102,待查名單暫存表格102可自過濾引擎12接收並儲存待查網頁位址,網頁爬蟲14則可自待查名單暫存表格102中,讀取待查網頁位址以下載其中之腳本參數。請注意,網頁爬蟲14讀取待查網頁位址與下載腳本參數之動作,均可在背景狀態下作業,亦即,網頁爬蟲14之動作不會影響到用戶端3透過應用程式20瀏覽與操作網頁。The web crawler 14 is connected to the filtering engine 12 and the database 10 to read the web address to be checked and download the script parameters included in the web address to be checked, for example, javascript. In this embodiment, the database 10 includes, in addition to the whitelist table 100, a temporary list 102 to be checked connected to the filtering engine 12 and the web crawler 14. The temporary list 102 to be checked may be self-checked. The filtering engine 12 receives and stores the address of the webpage to be inspected, and the web crawler 14 can read the webpage address of the webpage to be downloaded from the list to be checked to download the script parameters. Please note that the web crawler 14 can read the webpage address to be checked and download the script parameters, and can work in the background state, that is, the web crawler 14 does not affect the browsing and operation of the client 3 through the application 20. Web page.

腳本參數偵測器16係連接到網頁爬蟲14,並可偵測網頁爬蟲14所下載的腳本參數,是否包含有將用戶端的資料傳送至第三方網站之行為。於實務中,腳本參數偵測器16的種類可根據腳本參數而有所不同,舉例而言,若腳本參數為javascript,則腳本參數偵測器16可為js-detector。同樣地,腳本參數偵測器16之動作同樣可在背景狀態下操作,而不影響到用戶端瀏覽與操作網頁。由於惡意的腳本參數通常會經過不同的編碼以躲避偵測,因此腳本參數偵測器16可先對腳本參數進行解碼,再偵測解碼後之腳本參數是否有將用戶端的資料傳送至第三方網站的行為。此外,在惡意攻擊的狀況下,腳本參數通常會將用戶端的私密資料,例如,用戶端瀏覽器上所記錄之cookie,傳送至第三方網站進行收集。然而,跨網站攻擊的方法日新月異,除了cookie之外,攻擊者也有可能利用用戶端其他資訊進行攻擊,因此,本具體實施例之腳本參數偵測器16可偵測腳本參數是否有將用戶端的任何資料傳送至第三方網站的行為,而不限定資料的類型,以做為判斷腳本參數是否為惡意腳本參數的依據。The script parameter detector 16 is connected to the web crawler 14 and can detect the script parameters downloaded by the web crawler 14 and whether it includes the act of transmitting the data of the client to the third party website. In practice, the type of the script parameter detector 16 may vary according to the script parameters. For example, if the script parameter is javascript, the script parameter detector 16 may be a js-detector. Similarly, the action of the script parameter detector 16 can also operate in the background state without affecting the browsing and operation of the web page by the user. Since the malicious script parameters are usually coded to avoid detection, the script parameter detector 16 can first decode the script parameters, and then detect whether the decoded script parameters have the user-side data transmitted to the third-party website. the behavior of. In addition, in the case of malicious attacks, the script parameters usually transmit the private information of the client, for example, the cookie recorded on the client browser, to a third-party website for collection. However, the method of cross-site attack is changing with each passing day. In addition to the cookie, the attacker may also use other information of the user to attack. Therefore, the script parameter detector 16 of the specific embodiment can detect whether the script parameter has any user side. The behavior of the data transmitted to the third-party website, without limiting the type of the data, as a basis for judging whether the script parameter is a malicious script parameter.

上述之跨網站攻擊防範系統1可根據一定處理程序而有效率防範跨網站攻擊。請參閱圖二,圖二係繪示根據本發明之另一具體實施例之跨網站攻擊防範方法的步驟流程圖。本具體實施例之方法可應用圖一之網站攻擊防範系統1來進行,以下請一併參閱圖一以詳細說明本具體實施例之方法的詳細流程步驟。The cross-site attack prevention system 1 described above can effectively prevent cross-site attacks according to certain processing procedures. Referring to FIG. 2, FIG. 2 is a flow chart showing the steps of a cross-site attack prevention method according to another embodiment of the present invention. The method of this embodiment can be implemented by using the website attack defense system 1 of FIG. 1. Please refer to FIG. 1 for details of the detailed process steps of the method of the specific embodiment.

如圖二所示,本具體實施例之跨網站攻擊防範方法包含有下列步驟:於步驟S40,比對在網頁資料中所包含之待查網頁位址,與白名單表格內所儲存之至少一允許網頁位址是否相同;接著,於步驟S42,根據步驟S40之比對結果,選擇性地以至少一空白字元來取代待查網頁位址,並判斷待查網頁位址是否包含腳本參數;以及,於步驟S44,根據步驟S42之判斷結果,選擇性地下載待查網頁位址之腳本參數;最後,於步驟S46,偵測所下載的腳本參數是否有傳送資料至第三方網站之行為。As shown in FIG. 2, the cross-site attack prevention method in this embodiment includes the following steps: in step S40, comparing at least one of the to-be-checked webpage address included in the webpage data and the whitelisted table. Allowing the webpage addresses to be the same; then, in step S42, selectively replacing the to-be-checked webpage address with at least one blank character according to the comparison result of step S40, and determining whether the webpage address to be checked contains script parameters; And, in step S44, according to the determination result of step S42, the script parameter of the webpage address to be checked is selectively downloaded; finally, in step S46, it is detected whether the downloaded script parameter has the behavior of transmitting the data to the third-party website.

以上述具體實施例之跨網站攻擊防範系統1為例,於步驟S40中,過濾引擎12會比對應用程式20所取出之網頁資料中所包含的待查網頁位址,與資料庫10之白名單表格100內所儲存的允許網頁位址是否相同。接著,於步驟S42中,過濾引擎12會根據步驟S40比對之結果,選擇性地將網頁資料中的待查網頁位址以空白字元取代,並判斷待查網頁位址中是否包含有任何腳本參數。於實務中,應用程式20可直接先以經空白字元取代之待查網頁位址輸出給用戶端3,因此,可避免用戶端3點擊到惡意的腳本參數。接著,於步驟S44中,根據步驟S42判斷待查網頁位址是否包含腳本參數的結果,網頁爬蟲14可讀取待查網頁位址並下載其腳本參數。於步驟S46中,腳本參數偵測器16可偵測所下載之腳本參數,是否有將用戶端的資料傳送至第三方網站之行為,同樣地,實務上步驟S46之進行方式,可為腳本參數偵測器16先對腳本參數解碼,再偵測是否有將用戶端的資料傳送至第三方網站之行為。Taking the cross-site attack prevention system 1 of the above specific embodiment as an example, in step S40, the filtering engine 12 compares the to-be-checked webpage address included in the webpage data extracted by the application 20 with the whitelist of the database 10. Whether the allowed webpage addresses stored in the list table 100 are the same. Next, in step S42, the filtering engine 12 selectively replaces the to-be-checked webpage address in the webpage data with a blank character according to the result of the step S40, and determines whether the webpage address to be inspected contains any Script parameters. In practice, the application 20 can directly output the to-be-checked webpage address replaced by a blank character to the client 3, so that the client 3 can be prevented from clicking on malicious script parameters. Next, in step S44, according to step S42, it is determined whether the webpage address to be checked contains the result of the script parameter, and the web crawler 14 can read the webpage address to be checked and download its script parameter. In step S46, the script parameter detector 16 can detect the downloaded script parameters, and whether there is a behavior of transmitting the data of the user terminal to the third-party website. Similarly, the manner of performing the step S46 in the practice can be the script parameter detection. The detector 16 first decodes the script parameters and then detects whether there is a behavior of transmitting the data of the client to the third party website.

請參閱圖三,圖三係繪示圖二之跨網站攻擊防範方法更為詳細的步驟流程圖。Please refer to FIG. 3, which is a flow chart showing the steps of the cross-site attack prevention method in FIG.

如圖三所示,於步驟S40過濾引擎12在比對待查網頁位址,與白名單表格所儲存之允許網頁位址是否相同後,若比對結果為是,則於步驟S420中,應用程式20會直接將網頁資料輸出給用戶端3,此時所輸出的網頁資料中包含的待查網頁位址,已被確認為允許網頁位址的其中之一。若步驟S40之比對結果為否,亦即,待查網頁位址與白名單表格之允許網頁位址中的任何一者均不相同,則於步驟S422中過濾引擎12會將網頁資料之待查網頁位址以空白字元取代,並且應用程式20將以經空白字元取代後之網頁資料輸出給用戶端3,接著,在步驟S424中,過濾引擎12會進一步判斷待查網頁位址是否包含有腳本參數。As shown in FIG. 3, after the filtering engine 12 compares the webpage address to be checked and the allowed webpage address stored in the whitelisting table, the result is YES in step S420. 20 will directly output the webpage data to the client 3, and the webpage address to be checked included in the webpage data outputted at this time has been confirmed as one of the allowed webpage addresses. If the result of the comparison in step S40 is no, that is, if any of the to-be-checked webpage address and the allowed webpage address of the whitelisted form is different, then the filtering engine 12 will treat the webpage data in step S422. The webpage address is replaced by a blank character, and the application 20 outputs the webpage data replaced by the blank character to the client 3, and then, in step S424, the filtering engine 12 further determines whether the webpage address to be checked is Contains script parameters.

當步驟S424判斷結果為否時,於步驟S440中判斷待查網頁位址為不包含跨網站攻擊,便可將待查網頁位址做為允許網頁位址而儲存於白名單表格100中。因此,當下次過濾引擎14再遇到相同的待查網頁位址時,便可經由步驟S40而比對出其為與白名單表格100之允許網頁位址相同,並在步驟S420中直接輸出給用戶端3。When the result of the determination in step S424 is no, in step S440, it is determined that the webpage address to be inspected does not include a cross-site attack, and the webpage address to be inspected can be stored in the whitelisted table 100 as the allowed webpage address. Therefore, when the next time the filter engine 14 encounters the same webpage address to be checked, it can be compared with the allowed webpage address of the whitelisted table 100 via step S40, and directly output to the SMB in step S420. Client 3.

另外,當步驟S424判斷結果為是時,於步驟S442中,過濾引擎12可將待查網頁位址儲存於待查名單暫存表格102中,網頁爬蟲14則可自待查名單暫存表格102讀取此待查網頁位址並下載其中之腳本參數。於實務中,一個網頁資料可能包含多個待查網頁位址,由於網路爬蟲14讀取並下載腳本參數的動作較耗費時間,因此,上述跨網站攻擊防範系統及方法,可先將非白名單表格上的所有待查網頁位址,以空白字元取代而提供給用戶端3,接著再於判斷是否有腳本參數後,將這些具腳本參數之待查網頁位址存放於待查名單暫存表格102,並令網頁爬蟲14可在背景狀態下,依序執行讀取這些待查網頁資料及下載腳本參數的動作。換言之,用戶端3可於過濾引擎12確認待查網頁位址為允許網頁位址,或以空白字元取代待查網頁位址後即獲得網頁資料,而不會因等待網頁爬蟲14下載腳本參數而拖延應用程式20的反應速度。In addition, when the determination result in step S424 is YES, in step S442, the filtering engine 12 may store the to-be-checked webpage address in the to-be-checked list temporary storage table 102, and the webpage crawler 14 may self-check the list temporary storage form 102. Read the URL of the web page to be checked and download the script parameters. In practice, a webpage data may contain multiple webpage addresses to be inspected. Since the web crawler 14 reads and downloads the script parameters, the action is relatively time consuming. Therefore, the cross-site attack prevention system and method may be non-white. All the addresses of the to-be-checked webpages on the list form are replaced by blank characters and provided to the client 3, and then, after determining whether there are script parameters, the webpage addresses of the scripted parameters are stored in the list to be checked. The table 102 is saved, and the web crawler 14 can perform the actions of reading the webpage data to be inspected and downloading the script parameters in the background state. In other words, the user terminal 3 can obtain the webpage information after the filtering engine 12 confirms that the webpage address to be checked is the allowed webpage address, or replaces the webpage address to be inspected with a blank character, without waiting for the webpage crawler 14 to download the script parameter. And delay the response speed of the application 20.

步驟S442下或腳本參數後,於步驟S46,腳本參數偵測器16可偵測所下載的腳本參數,是否有將用戶端的資料傳送至第三方網站之行為。當步驟S46偵測之結果為否時,本具體實施例之方法會回到步驟S440,並將待查網頁位址做為允許網頁位址而儲存於白名單表格100中。另外,當步驟S46偵測之結果為是時,則會於步驟S48中,將待查網頁位址判斷為包含跨網站攻擊的惡意程式碼。同樣地,腳本參數偵測器16偵測所下載的腳本參數是否有傳送資料行為之動作,亦可於背景狀態下執行,而不會影響應用程式20回應用戶端3的速度。After step S442 or after the script parameter, in step S46, the script parameter detector 16 can detect the downloaded script parameter and whether there is a behavior of transmitting the data of the client to the third party website. When the result of the detection in step S46 is NO, the method of the specific embodiment returns to step S440, and stores the to-be-checked webpage address as the allowed webpage address in the whitelisted table 100. In addition, when the result of the detection in step S46 is YES, in step S48, the website address to be checked is determined to be a malicious code containing a cross-site attack. Similarly, the script parameter detector 16 detects whether the downloaded script parameter has an action of transmitting data behavior, and can also be executed in the background state without affecting the speed at which the application 20 responds to the client 3.

此外,為了加快上述具體實施例之跨網站攻擊防範系統1及方法的比對速度,各允許網頁位址會經過編碼得到一雜湊(hash)值,而各雜湊值係被存入白名單表格100中,對應於各允許網頁位址之雜湊欄。當過濾引擎12比對待查網頁位址時,會先將待查網頁位址編碼得到其待查雜湊值,再以此待查網頁位址之待查雜湊值來搜尋白名單表格100中是否有符合的雜湊值,藉此可加速比對待查網頁位址是否為已允許之網頁位址。In addition, in order to speed up the comparison speed of the cross-site attack prevention system 1 and method of the above specific embodiment, each allowed webpage address is encoded to obtain a hash value, and each hash value is stored in the whitelist table 100. Medium, corresponding to the hash bar of each allowed web page address. When the filtering engine 12 compares the address of the webpage, it first encodes the address of the webpage to be checked to obtain the hash value to be checked, and then searches for the hash value of the webpage address to be searched to search for the whitelisted table 100. The hash value that is matched, thereby speeding up the comparison of the web address to the allowed web address.

綜上所述,本發明之跨網站攻擊防範系統及方法,係先比對網站伺服器端輸出網頁資料中之待查網頁位址,與資料庫之白名單表格內的允許網頁位址是否相同,若待查網頁位址不為允許網頁位址,則系統將網頁資料中之待查網頁位址將以空白字元來取代並輸出給用戶端,以避免用戶端遭受惡意程式碼攻擊。經比對出與白名單表格內的允許網頁位址不相同的待查網頁位址,可在背景狀態下下載其腳本參數,並偵測腳本參數中是否包含有將用戶端的資料傳送至第三方網站的行為,若待查網頁位址的資料中不包含腳本參數,或其之腳本參數不包含將用戶端的資料傳送至第三方網站的行為,則可將待查網頁位址做為允許網頁位址再存入白名單表格中,待用戶端下次讀取時就能夠正常存取。相較於先前技術,本發明之跨網站攻擊防範系統及方法係建立於網站伺服器端,不須設定及測試防火牆規則而可簡單地架設,並且可有效地避免使用者端遭受惡意程式碼攻擊。In summary, the cross-site attack prevention system and method of the present invention compares the address of the webpage to be checked in the webpage data outputted by the web server, and whether the webpage address in the whitelisted table of the database is the same. If the address of the webpage to be checked is not the allowed webpage address, the system will replace the webpage address of the webpage in the webpage data with a blank character and output it to the client to avoid the malicious end of the client. By comparing the URL of the to-be-checked webpage with the allowed webpage address in the whitelisted form, the script parameter can be downloaded in the background state, and the script parameter is detected whether the data of the client is transmitted to the third party. The behavior of the website, if the information of the webpage address to be checked does not contain the script parameter, or the script parameter does not include the behavior of transmitting the data of the client to the third party website, the webpage address to be checked may be used as the allowed webpage address. The address is then stored in the whitelist form and can be accessed normally when the client reads it next time. Compared with the prior art, the cross-site attack prevention system and method of the present invention is established on the server server side, can be simply set up without setting and testing firewall rules, and can effectively prevent the user terminal from being attacked by malicious code. .

藉由以上較佳具體實施例之詳述,係希望能更加清楚描述本發明之特徵與精神,而並非以上述所揭露的較佳具體實施例來對本發明之範疇加以限制。相反地,其目的是希望能涵蓋各種改變及具相等性的安排於本發明所欲申請之專利範圍的範疇內。因此,本發明所申請之專利範圍的範疇應該根據上述的說明作最寬廣的解釋,以致使其涵蓋所有可能的改變以及具相等性的安排。The features and spirit of the present invention will be more apparent from the detailed description of the preferred embodiments. On the contrary, the intention is to cover various modifications and equivalents within the scope of the invention as claimed. Therefore, the scope of the patented scope of the invention should be construed as broadly construed in the

1...跨網站攻擊防範系統1. . . Cross-site attack prevention system

10...資料庫10. . . database

12...過濾引擎12. . . Filter engine

14...網頁爬蟲14. . . Web crawler

16...腳本參數偵測器16. . . Script parameter detector

100...白名單表格100. . . Whitelist form

102...待查名單暫存表格102. . . Temporary list of pending lists

2...網站伺服器2. . . Website server

20...應用程式20. . . application

122...應用程式資料庫122. . . Application database

3...用戶端3. . . user terminal

S40~S48...流程步驟S40~S48. . . Process step

圖一係繪示根據本發明之一具體實施例之跨網站攻擊防範系統的示意圖。FIG. 1 is a schematic diagram showing a cross-site attack prevention system according to an embodiment of the present invention.

圖二係繪示根據本發明之另一具體實施例之跨網站攻擊防範方法的步驟流程圖。FIG. 2 is a flow chart showing the steps of a cross-site attack prevention method according to another embodiment of the present invention.

圖三係繪示圖二之跨網站攻擊防範方法更為詳細的步驟流程圖。Figure 3 is a flow chart showing the steps of the cross-site attack prevention method in Figure 2.

1...跨網站攻擊防範系統1. . . Cross-site attack prevention system

10...資料庫10. . . database

12...過濾引擎12. . . Filter engine

14...網頁爬蟲14. . . Web crawler

16...腳本參數偵測器16. . . Script parameter detector

100...白名單表格100. . . Whitelist form

102...待查名單暫存表格102. . . Temporary list of pending lists

2...網站伺服器2. . . Website server

20...應用程式20. . . application

122...應用程式資料庫122. . . Application database

3...用戶端3. . . user terminal

Claims (10)

一種跨網站攻擊防範系統,其係設置於一網站伺服器中,該網站伺服器能供一用戶端登入,並根據該用戶端要求來提供一網頁資料給該用戶端,該跨網站攻擊防範系統包含:一資料庫,其係儲存有一白名單表格,該白名單表格儲存有至少一允許網頁位址;一過濾引擎,其係連接至該資料庫,該過濾引擎係用於比對該網頁資料中所包含之一待查網頁位址,與該白名單表格中之該至少一允許網頁位址是否相同,若比對結果相同,則由與該過濾引擎連接之一應用程式直接將該網頁資料輸出給該用戶端;若比對結果不相同,則該過濾引擎以至少一空白字元來取代該網頁資料中之該待查網頁位址,且進一步判斷該待查網頁位址是否包含一腳本參數;一網頁爬蟲,其係連接至該過濾引擎及該資料庫,該網頁爬蟲係於當該過濾引擎判斷該待查網頁位址包含該腳本參數時,用來讀取該待查網頁位址以下載該腳本參數;以及一腳本參數偵測器,其係連接至該網頁爬蟲,以用來偵測該網頁爬蟲所下載之該腳本參數,是否包含有將該用戶端之一資料傳送至一第三方網站之行為。 A cross-site attack prevention system is provided in a website server, the website server can be used for a user to log in, and a webpage information is provided to the user end according to the request of the user end, the cross-site attack prevention system The method includes: a database storing a whitelist table, the whitelist table storing at least one allowed webpage address; a filtering engine connected to the database, the filtering engine is used to compare the webpage data One of the to-be-checked webpage addresses included in the whitelisted table is the same as the at least one allowed webpage address in the whitelisted form. If the comparison result is the same, the webpage data is directly connected by the application connected to the filtering engine. Outputting to the client; if the comparison result is different, the filtering engine replaces the to-be-checked webpage address in the webpage data with at least one blank character, and further determines whether the to-be-checked webpage address contains a script a web crawler, which is connected to the filter engine and the database, the web crawler is when the filter engine determines that the web address to be checked contains the script a time interval for reading the web page address to be downloaded to download the script parameter; and a script parameter detector connected to the web crawler for detecting the script parameter downloaded by the web crawler, Whether it includes the transmission of one of the data of the client to a third-party website. 如申請專利範圍第1項所述之跨網站攻擊防範系統,其中該資料庫進一步包含一待查名單暫存表格,其係連接至該過濾引擎以及該網頁爬蟲,該待查名單暫存表格係用於儲存該待查網頁位址,並且該網頁爬蟲係自該待查名單暫存 表格讀取該待查網頁位址以下載該腳本參數。 The cross-site attack prevention system of claim 1, wherein the database further comprises a pending list temporary storage form, which is connected to the filtering engine and the web crawler, and the pending list temporary table is For storing the address of the web page to be inspected, and the web crawler is temporarily stored from the list to be checked The form reads the to-be-checked web address to download the script parameters. 如申請專利範圍第1項所述之跨網站攻擊防範系統,其中當該腳本參數偵測器偵測出該腳本參數不包含將該用戶端之該資料傳送至該第三方網站之行為時,該網頁爬蟲會將該待查網頁位址存於該白名單表格。 The cross-site attack defense system of claim 1, wherein the script parameter detector detects that the script parameter does not include the act of transmitting the data of the client to the third-party website, The web crawler will store the to-be-checked webpage address in the whitelisted form. 如申請專利範圍第1項所述之跨網站攻擊防範系統,其中該白名單表格會進一步儲存與該至少一允許網頁位址所對應之一雜湊(hash)值,並且該過濾引擎係根據該待查網頁位址所對應之一待查雜湊值,來與該至少一允許網頁位址所對應之該雜湊值進行比對,以比對該待查網頁位址與該至少一允許網頁位址是否相同。 The cross-site attack prevention system of claim 1, wherein the whitelist table further stores a hash value corresponding to the at least one allowed webpage address, and the filtering engine is configured according to the Querying a hash value corresponding to the webpage address to compare the hash value corresponding to the at least one allowed webpage address, to compare whether the webpage address to be checked and the at least one allowed webpage address are the same. 如申請專利範圍第1項所述之跨網站攻擊防範系統,其中該腳本參數偵測器係用於解碼該腳本參數,並偵測解碼後之該腳本參數,是否包含有將該用戶端之該資料傳送至該第三方網站之行為。 The cross-site attack prevention system described in claim 1, wherein the script parameter detector is configured to decode the script parameter, and detect the decoded script parameter, whether the user terminal is included The act of transmitting the data to this third party website. 一種跨網站攻擊防範方法,用於一網站伺服器,該網站伺服器能供一用戶端登入,並根據該用戶端要求而將一網頁資料提供給該用戶端,該方法包含下列步驟:(a)比對該網頁資料中所包含之一待查網頁位址,與一白名單表格所儲存之至少一允許網頁位址是否相同;(b)若該待查網頁位址與該白名單所儲存之該至少一允許網頁位址中之任何一者之比對結果為不相同,以至少一空白字元來取代該待查網頁位址,並判斷該待查網頁位址是否包含一腳本參數;(c)根據判斷該待查網頁位址時是否包含該腳本參數 之判斷結果,選擇性地下載該待查網頁位址之該腳本參數;以及(d)偵測下載之該腳本參數是否有將該用戶端之一資料傳送至一第三方網站之行為。 A cross-site attack prevention method is provided for a website server, wherein the website server can be used by a client to log in, and a webpage data is provided to the client according to the request of the client. The method comprises the following steps: (a Whether the address of the web page to be inspected included in the webpage data is the same as the at least one webpage address stored in the whitelisting form; (b) if the webpage address to be inspected is stored in the whitelist The comparison result of the at least one allowed webpage address is different, the at least one blank character is used to replace the to-be-checked webpage address, and it is determined whether the to-be-checked webpage address contains a script parameter; (c) Whether the script parameter is included according to the judgment of the address of the webpage to be checked As a result of the determination, the script parameter of the to-be-checked webpage address is selectively downloaded; and (d) detecting whether the downloaded script parameter has a behavior of transmitting the data of one of the client terminals to a third-party website. 如申請專利範圍第6項所述之跨網站攻擊防範方法,其中步驟(b)進一步包含下列步驟:(b1)若步驟(a)中該待查網頁位址與該白名單所儲存之至少一允許網頁位址之比對結果為相同,則將包含該待查網頁位址之該網頁資料提供給該用戶端。 The cross-site attack prevention method described in claim 6 , wherein the step (b) further comprises the following steps: (b1) if the address of the to-be-checked webpage in the step (a) and the whitelist are stored at least one If the comparison result of the webpage address is the same, the webpage data including the address of the webpage to be inspected is provided to the client. 如申請專利範圍第6項所述之跨網站攻擊防範方法,其中步驟(c)進一步包含下列步驟:(c1)若判斷該待查網頁位址是否包含該腳本參數之結果為否時,將該待查網頁位址存於該白名單表格。 The method for preventing cross-site attack as described in claim 6 , wherein the step (c) further comprises the following steps: (c1) if it is determined whether the result of the script parameter is not included in the website address to be checked, The web page address to be checked is stored in the white list form. 如申請專利範圍第6項所述之跨網站攻擊防範方法,其中步驟(c)進一步包含下列步驟:(c2)若判斷該待查網頁位址是否包含該腳本參數之結果為是時,下載該待查網頁位址之該腳本參數。 The cross-site attack prevention method described in claim 6 , wherein the step (c) further comprises the following steps: (c2) downloading the result if the result of determining whether the web page address to be checked includes the script parameter is The script parameter of the web page address to be checked. 如申請專利範圍第6項所述之跨網站攻擊防範方法,進一步包含下列步驟:(e1)若步驟(d)中偵測下載之該腳本參數有將該用戶端之該資料傳送至該第三方網站之行為,判斷該待查網頁位址為一跨網站攻擊;以及(e2)若步驟(d)中偵測下載之該腳本參數無將該用戶端之該資料傳送至該第三方網站之行為,將該待查網頁位址存於該白名單表格。 The cross-site attack prevention method described in claim 6 further includes the following steps: (e1) if the script parameter detected in the step (d) is downloaded, the data of the client is transmitted to the third party. The behavior of the website, determining that the address of the web page to be inspected is a cross-site attack; and (e2) if the script parameter detected in step (d) does not transmit the data of the client to the third party website And storing the to-be-checked webpage address in the whitelisted form.
TW100148781A 2011-12-27 2011-12-27 System and method for defending against cross-site scripting TWI506471B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW100148781A TWI506471B (en) 2011-12-27 2011-12-27 System and method for defending against cross-site scripting

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW100148781A TWI506471B (en) 2011-12-27 2011-12-27 System and method for defending against cross-site scripting

Publications (2)

Publication Number Publication Date
TW201327250A TW201327250A (en) 2013-07-01
TWI506471B true TWI506471B (en) 2015-11-01

Family

ID=49225052

Family Applications (1)

Application Number Title Priority Date Filing Date
TW100148781A TWI506471B (en) 2011-12-27 2011-12-27 System and method for defending against cross-site scripting

Country Status (1)

Country Link
TW (1) TWI506471B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107454041B (en) 2016-05-31 2020-06-02 阿里巴巴集团控股有限公司 Method and device for preventing server from being attacked

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200825835A (en) * 2006-12-13 2008-06-16 Inst Information Industry System and method of detecting web page vulnerability and recording medium thereof
US20090119769A1 (en) * 2007-11-05 2009-05-07 Microsoft Corporation Cross-site scripting filter
US20090292983A1 (en) * 2007-11-30 2009-11-26 Kunal Anand Html filter for prevention of cross site scripting attacks
CN101964025A (en) * 2009-07-23 2011-02-02 中联绿盟信息技术(北京)有限公司 XSS (Cross Site Scripting) detection method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200825835A (en) * 2006-12-13 2008-06-16 Inst Information Industry System and method of detecting web page vulnerability and recording medium thereof
US20090119769A1 (en) * 2007-11-05 2009-05-07 Microsoft Corporation Cross-site scripting filter
US20090292983A1 (en) * 2007-11-30 2009-11-26 Kunal Anand Html filter for prevention of cross site scripting attacks
CN101964025A (en) * 2009-07-23 2011-02-02 中联绿盟信息技术(北京)有限公司 XSS (Cross Site Scripting) detection method and device

Also Published As

Publication number Publication date
TW201327250A (en) 2013-07-01

Similar Documents

Publication Publication Date Title
Balduzzi et al. A solution for the automated detection of clickjacking attacks
JP6624771B2 (en) Client-based local malware detection method
Canali et al. Prophiler: a fast filter for the large-scale detection of malicious web pages
Nikiforakis et al. SessionShield: Lightweight protection against session hijacking
Kirda et al. Noxes: a client-side solution for mitigating cross-site scripting attacks
Wurzinger et al. SWAP: Mitigating XSS attacks using a reverse proxy
Kirda et al. Client-side cross-site scripting protection
Liu et al. A novel approach for detecting browser-based silent miner
US20100037317A1 (en) Mehtod and system for security monitoring of the interface between a browser and an external browser module
US20120222117A1 (en) Method and system for preventing transmission of malicious contents
US20170353434A1 (en) Methods for detection of reflected cross site scripting attacks
CN105959324A (en) Regular matching-based network attack detection method and apparatus
Bach-Nutman Understanding the top 10 owasp vulnerabilities
EP3518135B1 (en) Protection against third party javascript vulnerabilities
CN113645234A (en) Honeypot-based network defense method, system, medium and device
Deng et al. Lexical analysis for the webshell attacks
Süren et al. Know Your EK: A Content and Workflow Analysis Approach for Exploit Kits.
Shukla et al. PythonHoneyMonkey: Detecting malicious web URLs on client side honeypot systems
Satish et al. Web browser security: different attacks detection and prevention techniques
Snehi et al. Web client and web server approaches to prevent xss attacks
Sandhu et al. Google safe browsing-web security
Selvamani et al. Protection of web applications from cross-site scripting attacks in browser side
TWI506471B (en) System and method for defending against cross-site scripting
Sahani et al. Clickjacking: Beware of clicking
CN112287349A (en) Security vulnerability detection method and server

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees