C1. Consider OWASP ASVS
• Choose the level of security for your application
• Extract the requirements for that level
• Use requirements to generate test cases
• Integrate security testing in SDLC.
C1. Vulnerabilities Addressed - All Top Ten!
A1 – Injection A2 – Broken Auth.
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
A9 – Using Comp.
with Known
Vulnerabilities
A10 - Unvalidated
Redirects and
Forwards
SQL injection example
$email=‘;- - @owasp.org;
$sql = UPDATE user set email=‘$email’ WHERE id=‘1’;
$sql = UPDATE user SET email=‘'; -- @owasp.org' WHERE id=‘1’;
Becomes
C2. Query Parameterization Example
String cmd = String.Format(“SELECT * FROM users where userID = {}”,userID)
reader = cmd.ExecuteReader();
Example of Query ParameterisationHow not to do it ! .
C2. Query Parameterization - Correct Usage
string cmd= "SELECT * FROM users WHERE userId = @Id";
SqlCommand sql = new SqlCommand(cmd);
sql.SqlParameter("@Id", System.Data.SqlDbType.Int));
sql.Parameters["@Id"].Value = ID;
reader = sql.ExecuteReader();
Secure Database Access
Credentials:
• Store encrypted credentials out of the source code
Database user:
• Grant least privilege
• Remove unrequired users
Stored procedures:
• Grant EXECUTE permissions on the stored procedures
• Revoke or deny all permissions to the underlying tables for all roles
C2: Vulnerabilities Addressed
A1 – Injection A2 – Broken Auth.
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
A9 – Using Comp.
with Known
Vulnerabilities
A10 – Unvalidated
Redirects and
Forwards
NIST: 2017 Digital Identity Guidelines
• Allow all ASCII printable characters, including space
• Minimum 8 characters length
• Allow users to passwords lengthy as they want, within reason.
• Offer guidance, such as a password-strength meter
• Do not require password to be changed periodically
• Permit to use “paste” functionality
• Check against a list of bad password
Source: https://pages.nist.gov/800-63-3/sp800-63b.html
Hash Password with a modern Hash
Problem:
• Long passwords can cause DoS
• bcrypt truncates passwords to 72 bytes
Solution:
• SHA-512 - converts long passwords to 512 bits
C5. Secure Password Storage
protect(sha512(password), [salt], [workFactor])
+
2nd Factor Authentication
Don’t use SMS as multi-factor (use FIDO or dedicated app)
C5. Password Storage – How Not To Do It!
$password=bcrypt([salt] + [password], work_factor);
$loginkey =md5(lc([username]).”::”.lc([password]))
C5. Error Messages - How Not To Do It!
Error message for not-registered userError message for valid user
C5. Vulnerabilities Addressed
A1 – Injection A2 – Broken Auth.
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
A9 – Using Comp.
with Known
Vulnerabilities
A10 – Unvalidated
Redirects and
Forwards
C7. Data in Transit
Data in transit: HTTPS
• Confidentiality: Spy cannot view your data
• Integrity: Spy cannot change your data
• Authenticity: Server you visit is the right one
MITM Protection - HSTS
• HTTPS + Strict Transport Security Header
C7. Data at Rest
1. Strong algorithm – AES
2. Secure key management
3. Adequate access controls and auditing
C7. Vulnerabilities Addressed
A1 – Injection A2 – Broken Auth.
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
A9 – Using Comp.
with Known
Vulnerabilities
A10 – Unvalidated
Redirects and
Forwards
C8. Examples of Intrusion Detection Points
• Application receives GET when expecting POST
• Additional form or URL parameters submitted with request
• Input validation failure server side when client side validation exists
• Input validation failure server side on non-user editable parameters
such as hidden fields, checkboxes, radio buttons or select lists
• HTTP headers, Cookies received differ from the expected
Source: https://www.owasp.org/index.php/OWASP_AppSensor_Project
Logging Frameworks
• Use logging framework
• Encode untrusted data -> protection against Log injection attacks
• Validate untrusted data-> protection against Log forging attacks
C8. Vulnerabilities Addressed - All Top Ten!
A1 – Injection A2 – Broken Auth.
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
A9 – Using Comp.
with Known
Vulnerabilities
A10 - Unvalidated
Redirects and
Forwards
C9. API Integration Best Practices
“When you wrap a third-party API, you minimize
your dependencies upon it: You can choose to move
to a different library in the future without much
penalty. “
Robert C. Martin
Join the conversation #DevSecCon
Thank you
Katy Anton
Application Security Consultant
Ca / Veracode
Hinweis der Redaktion
Think for example of coordinates: latitude and longitude have no value by themselves, but put them together, and they can pin-point the exact location on earth!
The same thing can happened with error messages when attackers will aggregate /^ them from different parts /^ of the application.
One way to deal with this, is to present the end user an error code, and store the details of the error in the database.
——>
American English uses the Z, and British uses the S.