Mais conteúdo relacionado
Semelhante a Web應用程式以及資安問題的探討 (20)
Mais de Mu Chun Wang (20)
Web應用程式以及資安問題的探討
- 14. OWASP Top 10 - #10
疏於限制URL存取
Failure to Restrict URL Access
- 15. OWASP Top 10 - #10
[WEB ROOT]
/admin/[admin.html | index.html | index.jsp | index.asp | index.php]
/products
/sales
...
index.html
login.html
...
/backup/
/logs/
/vulnerable.cgi
- 17. OWASP Top 10 - #10 – 解決
• 阻擋存取所有不會在伺服器上執行的
檔案
• 將所有需要加入權限控管的檔案,設
定正確的權限
• 利用MVC架構(如RoR)控制所有需要
加入權限控管的檔案
• 不要把使用者當笨蛋
17
- 23. OWASP Top 10 - #8
不安全的密碼儲存器
Insecure Cryptographic Storage
- 24. OWASP Top 10 - #8
• this is a text
• MD4: 24886fa61e16a6e5dd12fd180c878251
• MD5: 78821a05d282822e4abec190c061ba78
• SHA-1: 703c445982e074e33a05c161d221217f2facbf5e
• RSA:
45683425c7df8a78f80d4801ff277888fdba7a72150541e8eca1d7329ca
2cf53f8ca1f2d2dcd34513067b1f6db402bfee48143288f2b7b448da015
e5a6b0aababb1f95ef4a653547c98c6492a552d0d7f7425c1663f4f3008
91b6d0abc0ee17a499ad4f46ace65182c5bf26577021d49f26abb1a496
1f3e9e7e339ff2b4e778a
24
- 25. OWASP Top 10 - #8 – 解決
• 使用較安全的加密演算法
– AES
– RSA
– SHA-256
25
- 27. OWASP Top 10 - #7
遭破壞的鑑別與連線管理
Broken Authentication and
Session Management
- 29. OWASP Top 10 - #7 – 解決
• 不要允許來自網址列或是外部request的
session id
• 將隱密性的資料使用已註冊的email傳送
• 修改密碼時需要再次確認舊密碼
• 每個網頁都需要有登出連結
29
- 31. OWASP Top 10 - #6
資訊揭露與不適當錯誤處置
Information Leakage and
Improper Error Handling
- 33. OWASP Top 10 - #6 – 解決
• 確保每一個專案在開發時,都會有一個共同的
例外處理方法(exception handling approach)
• 關閉/限制顯示錯誤資訊的大小
33
- 35. OWASP Top 10 - #5
跨網站的偽造要求
Cross-Site Request Forgery,
CSRF
- 36. OWASP Top 10 - #5
• clickme.html
– <body><iframe width=quot;1quot; height=quot;1quot;
src=quot;attack.htmlquot;></iframe></body>
• attack.html
– <body onload=quot;document.frm.submit() quot;><form
name=quot;frmquot; method=quot;postquot;
action=http://a.com/atk.cgi><input type=quot;hiddenquot;
name=quot;artquot; value=quot;tttquot;><input type=quot;submitquot;
value=quot;sendquot;></form>
36
- 37. OWASP Top 10 - #5 – 解決
• 在每個form加入一個隨機值,代表目前執行動
作的使用者
• 針對敏感性資料的修改,在修改前請再次認證
• 不要把GET傳輸方式用在敏感性資料的修改
37
- 39. OWASP Top 10 - #4
不安全的物件參考
Insecure Direct Object Reference
- 40. OWASP Top 10 - #4
• <select name=quot;languagequot;><option
value=quot;frquot;>Francais</option></select>
…
require_once
($_REQUEST['language'].quot;lang.phpquot;);
40
- 41. OWASP Top 10 - #4
• 避免在HTML上顯示任何私人的檔案路徑,或
是在HTML上使用id代表檔案名稱
• 可以利用白名單的方式驗證私人檔案路徑
41
- 45. OWASP Top 10 - #3 – 解決
require_once($safe['file'] .
'inc.php');
- 49. OWASP Top 10 - #2
• strSQL = quot;SELECT * FROM users WHERE (name =
'quot; + userName + quot;') and (pw = 'quot;+ passWord +quot;');quot;
• userName = quot;' OR '1'='1quot;;
• passWord = quot;' OR '1'='1quot;;
• strSQL = quot;SELECT * FROM users WHERE (name =
'' OR '1'='1') and (pw = '' OR '1'='1');quot;
49
- 50. OWASP Top 10 - #2 – 解決
• Parameterized Query
– SqlCommand sqlcmd = new
SqlCommand(quot;INSERT INTO myTable (c1, c2, c3,
c4) VALUES (@c1, @c2, @c3, @c4)quot;, sqlconn);
sqlcmd.Parameters.AddWithValue(quot;@c1quot;, 1);
sqlcmd.Parameters.AddWithValue(quot;@c2quot;, 2);
sqlcmd.Parameters.AddWithValue(quot;@c3quot;, 3);
sqlcmd.Parameters.AddWithValue(quot;@c4quot;, 4);
50
- 53. OWASP Top 10 - #1
• echo $_REQUEST['userinput'];
• <script>alert(document.cookie)</script>
53
- 54. OWASP Top 10 - #1 – 解決
• PHP
– htmlentities()
– htmlspecialchars()
• ASP.NET
– Server.HtmlEncode()
– Microsoft Anti-Cross Site Scripting Library
54
- 56. 程式碼安全品質
• [必要]
– A1. 跨網站的入侵字串(XSS)
– A2. 注入缺失(SQL Injection)
• [建議]
– A3. 惡意檔案執行
– A4. 不安全的物件參考
• [選擇]
– A5. 跨網站的偽造要求(CSRF)
56