9/21/2015 1 Giảng viên: Lê Phúc Email: [email protected]Website: http://is.ptithcm.edu.vn/~lephuc Software security INT1303 Information security, PTITHCM, 2015 Lỗi phần mềm 2 Bình quân có 5 lỗi trong 10.000 dòng lệnh Mỗi máy tính có khoảng 3000 file thực thi, mỗi file có khoảng 100.000 dòng lệnh Mỗi chương trình có khoảng 50 lỗi, mỗi máy tính có khoảng 150.000 lỗi. Có khoảng 10% lỗi nghiêm trọng, trong đó 10% lỗi có thể khai thác từ xa.
16
Embed
An toàn và bảo mật hệ thống thông tin - C7: software security
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Improper Neutralization of Special Elements used in an SQL Command (“SQL Injection”)
Improper Neutralization of Special Elements used in an OS Command (“OS Command Injection”)
Improper Neutralization of Input During Web Page Generation (“Cross-site Scripting”)
Unrestricted Upload of File with Dangerous Type
Cross-Site Request Forgery (CSRF)
URL Redirection to Untrusted Site (“Open Redirect”)
Lỗi quản lý tài nguyên
INT1303 Information security, PTITHCM, 2015
6
Buffer Copy without Checking Size of Input (“Classic Buffer Overflow”)
Improper Limitation of a Pathname to a Restricted Directory (“Path Traversal”)
Download of Code Without Integrity Check
Inclusion of Functionality from Untrusted Control Sphere
Use of Potentially Dangerous Function
Incorrect Calculation of Buffer Size
Uncontrolled Format String
Integer Overflow or Wraparound
9/21/2015
4
Lỗi bảo vệ hệ thống
INT1303 Information security, PTITHCM, 2015
7
Missing Authentication for Critical Function
Missing Authorization
Use of Hard-coded Credentials
Missing Encryption of Sensitive Data
Reliance on Untrusted Inputs in a Security Decision
Execution with Unnecessary Privileges
Incorrect Authorization
Incorrect Permission Assignment for Critical Resource
Use of a Broken or Risky Cryptographic Algorithm
Improper Restriction of Excessive Authentication Attempts
Use of a One-Way Hash without a Salt
OWASP top 10
INT1303 Information security, PTITHCM, 2015
8
A1-Injection
A2-Broken Authentication and Session Management
A3-Cross-Site Scripting (XSS)
A4-Insecure Direct Object References
A5-Security Misconfiguration
A6-Sensitive Data Exposure
A7-Missing Function Level Access Control
A8-Cross-Site Request Forgery (CSRF)
A9-Using Components with Known Vulnerabilities
A10-Unvalidated Redirects and Forwards
9/21/2015
5
Phần mềm an toàn
INT1303 Information security, PTITHCM, 2015
9
Các bước đảm bảo an toàn trong xây dựng
phần mềm
Xử lý dữ liệu nhập
Viết mã nguồn an toàn
Đảm bảo an toàn khi tương tác với Hệ điều hành
và các thành phần khác
Xử lý dữ liệu xuất
Phần mềm máy tính
INT1303 Information security, PTITHCM, 2015
10
9/21/2015
6
Xử lý dữ liệu nhập
INT1303 Information security, PTITHCM, 2015
11
Kiểm tra dung lượng dữ liệu nhập
Phân tích dữ liệu nhập
Injection attacks
Cross-site scripting attacks
Kiểm tra cú pháp nhập liệu
Input fuzzing
Kiểm tra kích thước dữ liệu nhập
INT1303 Information security, PTITHCM, 2015
12
Lỗi buffer overflow thường khó phát hiện trong
quá trình kiểm tra phần mềm. Khi lập trình cần
chủ động:
Dùng các hàm nhập liệu an toàn (tránh các thư
viện C truyền thống).
Cấp phát bộ nhớ động.
Kiểm tra kích thước dữ liệu trước khi thực hiện
thao tác gán.
9/21/2015
7
Phân tích dữ liệu nhập
INT1303 Information security, PTITHCM, 2015
13
Phân biệt dữ liệu nhị phân và dữ liệu text.
Xử lý đúng kiểu dữ liệu.
Phân tích các cấu trúc một cách chính xác, có kiểm tra tính hợp hệ của từng thành phần (kiểu cấu trúc, đối tượng, các gói dữ liệu của từng giao thức khác nhau)
Hai loại tấn công điển hình liên quan:
Injection attack
XSS attack
Injection attacks
INT1303 Information security, PTITHCM, 2015
14
Các kiểu injection:
Command injection
SQL injection
Các ngôn ngữ liên quan:
PHP
Perl
Python, ...
9/21/2015
8
Command injection
INT1303 Information security, PTITHCM, 2015
15
Server-side script:
$q = new CGI;
print $q->header,
$q-> start_html('Finger User');
$user = $q->param("user");
print ‘/usr/bin/finger -sh $user’;
print $q->end_html;
Command injection
INT1303 Information security, PTITHCM, 2015
16
Client-side form:
<html><head><title>Finger User </title> </head> <body> </html>
<h1>Finger User</h1>
<form method=post action="finger.cgi">
<b>Username to finger</b>: <input type=text name=user value="">