SlideShare uma empresa Scribd logo
1 de 153
What application security tools vendors don’t want you to know and holes they will never find! Mark Curphey John Viega
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
How Important is Context?
 
 
 
 
Mozilla vs. Klocwork  611 “defects”  72 “vulnerabilities”  3 verified bugs  99.5% useless?
 
 
 
What kind of talk is this? Tools that try to find security holes in software Way for us to understand and rationalize why they are so bad and unlikely to get much better soon It is a realistic state of the union about the current state of application security technology and how it is being marketed and applied Dr. Holger Peine http://fhgonline.fraunhofer.de/server?suche-publica&num=048.06/D&iese (N.B. about overly generous quote to Cenzic) Arian Evans http://www.owasp.org/index.php/Image:AppSec2005DC-Arian_Evans_Tools-Taxonomy.ppt
New Topic ,[object Object],[object Object],[object Object],[object Object]
 
 
 
How is security built in the real world?
 
 
 
How is security built in the real world?
How is security built in the real world?
 
Implementation Bugs  vs. Design Flaws
Security Frame of Reference Name Description Configuration Management Configs, security managers, web server settings etc. Authentication Knowing users and entities are who they claim to be Authorization Who can do what to whom, TOCTOU etc. Data Protection (Transit & Storage) Encrypted passwords, on-wire protection, channel sinks, encrypted configuration files etc. Data Validation Valid, well formed, free of malicious payloads etc. Auditing and Logging Knowing who does what to whom etc. Error & Exception Handling What happens when the pooh hits the fan etc. User Management Password reset, registration, licensing etc.
 
Scorecard * unscientific, based on experience ,[object Object],[object Object],[object Object],Security Reference Frame Effectiveness of Assessment Tools Web App Scanners Static Code Analysis Binary Analysis Bug Flaw Bug  Flaw Bug Flaw Configuration Management * * Authentication * * Authorization * * Data Protection (Transit & Storage) * * Data Validation * * Auditing and Logging * * Error & Exception Handling * * User Management * *
Configuration Management  ASP.NET application running in  partial trust Revert.ToSelf(); Implementation Bug Design Flaw * good at many web server config issues Web App Scanners Hard coded connection string in configuration files Use of common crypto keys across Implemntations Hosted Environment
Data Validation Implementation Bug Design Flaw Web App Scanners Canonicalization Internationalization Stored cross site scripting (even basic XSS in some cases) SQL injection (non ‘) Buffer overflows NOT HTTP 500’s! * Their strongest category
Data protection Implementation Bug Design Flaw Web App Scanners Clear text passwords stored  in database Weak algorithms * Reusing keys with stream ciphers Weak random number generators Secure memory management issues
User Management Clear text passwords in  the database Password expiry Password reset sent in clear Implementation Bug Design Flaw Web App Scanners Password generation on reset Weak session ID’s
Grep: Lack of Context … strcpy(dst, src);  // Generally a “high severity” error … strncpy(dst, src); // Generally a filtered out “low sev” …
Grep: Lack of Context … // Generally a “high severity” error strcpy(dst, src);  // Generally a “high severity” error … // Generally “low severity”, filtered out by default strncpy(dst, src, n);  …
Grep: Lack of Context void copy_20(char *src) { char dst[20]; int  n; if (strlen(src) > 19) { return 0; } strcpy(dst, src);  return strdup(dst); }
Grep: Lack of Context void copy(char *dst, char *src) { int  n = strlen(src); strncpy(dst, src, n);  return strdup(dst); } … char d[20]; copy(d, arbitrary_user_input);
Grep-style ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Let’s try to do better with “real” static analysis!
 
Sample program ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Another program ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,0] alloc(B2) [100,100] len(B2) [0,0] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,0] alloc(B2) [100,100] len(B2) [0,0] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,0] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,1] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,1] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] 4 len(ARGV)  -> len(B1) len(B2) -> len(B2) + 1 i [0,max] i <- i + 1
alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] Okay: no incoming edges to len(ARGV) RANGE OVERLAPS: B1 MAY OVERFLOW RANGE OVERLAPS: B2 MAY OVERFLOW
The Program Again ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Is this the b2 vuln?
The Program Again ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Or is this?
The Program Again ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A good analysis requires some understanding of control flow!
Many analyses aren’t worth it! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Control Flow ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Entry argc: [0,max]  others: nil
Control Flow void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max]  others: nil alloc(b): 100
Control Flow void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max]  others: nil alloc(b): 100 len(b): 4
Control Flow void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max]  others: nil Write to B.  Does it overflow? alloc(b): 100 len(b): 4
Control Flow void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max]  others: nil No.  At this node, B is alloc’d to 100, actual len of 4. alloc(b): 100 len(b): 4
Control Flow B: alloc(100) B: len(4) void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max]  others: nil
Control Flow void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False Entry argc: [0,max]  others: nil alloc(b): 100 len(b): 4
Control Flow argc: [2, max] Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if( argc > 1  && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False alloc(b): 100 len(b): 4
Control Flow argc: [2, max] len(argv): [0, 100] alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 &&  len(argv[1]) < 100 ) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]  No overflow.  b is alloc’d to 100, len can be no more than 100 after null is added.
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for ( i=0 ;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 100] Use the worst case assumption for the length of b.
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 100] len(b): [0, 101]
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil void main(int argc, char **argv) {  char *b = malloc(100);  int  i; strcpy(b, “foo”);  if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]);  for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 100] len(b): [0, 101] ERROR:  len(b) > alloc(b)!!!
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 100] len(b): [0, 101] Could show you the graph to help you debug…
Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 100] len(b): [0, 101] If you’re a rocket scientist   (graphs get big and complex in real programs)
Control Flow ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Though, we could show you (one possible) “stack trace” instead… (far better than dynamic analysis tools!)
Control Flow ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Or, we could show where the data came from
Not just memory stuff… ,[object Object],[object Object],[object Object],[object Object]
Issue 1 void main(int argc, char **argv) {  char *b = malloc( 100000 );  int  n = argc; for (i=0;i<n;i++) strcat(b, “.”); }
Issue 1 void main(int argc, char **argv) {  char *b = malloc(100000);  int  n = argc; for (i=0;i<n;i++) strcat(b, “.”); } In a more complex example, would we really have to “run” the loop MAX_INT times?
Issue 1 void main(int argc, char **argv) {  char *b = malloc(100000);  int  n = argc; for (i=0;i<n;i++) strcat(b, “.”); } In this case, we could multiply the effect by the maximum value of n.
Issue 1 void main(int argc, char **argv) {  char *b = malloc(100000);  int  n = argc; for (i=0;i<n;i++) strcat(b, “.”); } More complex cases aren’t that easy, and require approximations!
Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 100] We lost accuracy when we merged.
Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 101] i = 0 len(b): 4
Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 We can show which path is bad! And, future calculations become much more accurate. len(b): [0, 101] i = 0 len(b): 4
Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 101] i = 0 len(b): 4 An exponential explosion of nodes Only feasible for single functions (intraprocedural analysis)
Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max]  others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]   i = 0 len(b): [0, 101] i = 0 len(b): 4 Full path analysis is even less feasible when we consider exits from complex loops
The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; }
The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } No matter how accurate we get inside the procedure, we are in a catch-22 (spam vs. ignore)
The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } Instead of erroring, we can “summarize” the generic properties.
The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } e.g., len(a) <- len(b)
The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } Scaling algorithms to an entire program can greatly improve accuracy… and decrease efficiency!
Using environmental knowledge ,[object Object],[object Object],[object Object]
There will always be falses ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Building good tools is hard! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Everybody gets this right… for the wrong reasons secureConnect (host, port): s = sslConnect(gethostbyaddr(host), port) cert = get_cert(s) if ! certSignedByTrustedRoot(cert): raise “SSLError” if  cert.DN <> host: raise “SSLError” if ! subjAltNameMatches(cert, host): raise “SSLError” if certRevoked(cert): raise “SSLError” return s
If you’re not an auditor, it probably isn’t cost effective!
Notes on Buying Automated Tools Trials are limited for a reason (as are the EULA’s) Make sure you test them on your own site / code
“ The height of mediocrity is still low” Basic Conclusion
Accuracy on basic software today is mediocre at best It is really easy to write an application that can’t be automatically scanned It is really hard to write an automated scanner than can effectively analyze software Basic Conclusion
 
PCI Data Security Standards
 
6.6 Ensure that all web-facing applications are protected against known  attacks by applying either of the following methods:  •  Having all custom application code reviewed for  common vulnerabilities  by an  organization that specializes in application security  •  Installing an  application layer firewall  in front of web-facing applications.    Note: This method is considered a best practice until June 30, 2008,  after which it becomes a requirement.    Full document at  https://www.pcisecuritystandards.org/tech/download_the_pci_dss.htm PCI-DSS is now managed by an industry consortium at  www.pcisecuritystandards.org
…… or go straight to the document here! https://www.pcisecuritystandards.org/pdfs/pci_dss_v1-1.pdf
 
Introducing the only tool in the world that really works effectively today……
 
News for people who run tools
A fool with a tool … .is still a fool
China!
China!
China!
People Process Technology
Fair and Balance ,[object Object],[object Object]
What sort of tool do we want? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
 
That’s all folks!

Mais conteúdo relacionado

Mais procurados

Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterCodeIgniter Conference
 
jQuery Plugin Creation
jQuery Plugin CreationjQuery Plugin Creation
jQuery Plugin Creationbenalman
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with MooseDave Cross
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09Elizabeth Smith
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Balázs Tatár
 
With a Mighty Hammer
With a Mighty HammerWith a Mighty Hammer
With a Mighty HammerBen Scofield
 
New Features in PHP 5.3
New Features in PHP 5.3New Features in PHP 5.3
New Features in PHP 5.3Bradley Holt
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2Elizabeth Smith
 

Mais procurados (20)

Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
 
jQuery Plugin Creation
jQuery Plugin CreationjQuery Plugin Creation
jQuery Plugin Creation
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
TDD with PhpSpec
TDD with PhpSpecTDD with PhpSpec
TDD with PhpSpec
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
RSpec 2 Best practices
RSpec 2 Best practicesRSpec 2 Best practices
RSpec 2 Best practices
 
Spl in the wild
Spl in the wildSpl in the wild
Spl in the wild
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
 
New in php 7
New in php 7New in php 7
New in php 7
 
With a Mighty Hammer
With a Mighty HammerWith a Mighty Hammer
With a Mighty Hammer
 
New Features in PHP 5.3
New Features in PHP 5.3New Features in PHP 5.3
New Features in PHP 5.3
 
Php go vrooom!
Php go vrooom!Php go vrooom!
Php go vrooom!
 
Getting testy with Perl
Getting testy with PerlGetting testy with Perl
Getting testy with Perl
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
PHP - Introduction to PHP Functions
PHP -  Introduction to PHP FunctionsPHP -  Introduction to PHP Functions
PHP - Introduction to PHP Functions
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 

Semelhante a Hack in the Box Keynote 2006

Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab FileKandarp Tiwari
 
Secure Programming
Secure ProgrammingSecure Programming
Secure Programmingalpha0
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python scriptsaniac
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsBG Java EE Course
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semesterDOSONKA Group
 
PesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShell
PesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShellPesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShell
PesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShellDaniel Bohannon
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstackThierry Gayet
 
Introduction to Snort Rule Writing
Introduction to Snort Rule WritingIntroduction to Snort Rule Writing
Introduction to Snort Rule WritingCisco DevNet
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonPython Ireland
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertextfrankieroberto
 

Semelhante a Hack in the Box Keynote 2006 (20)

Buffer OverFlow
Buffer OverFlowBuffer OverFlow
Buffer OverFlow
 
Price of an Error
Price of an ErrorPrice of an Error
Price of an Error
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Secure Programming
Secure ProgrammingSecure Programming
Secure Programming
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Effective Object Oriented Design in Cpp
Effective Object Oriented Design in CppEffective Object Oriented Design in Cpp
Effective Object Oriented Design in Cpp
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
PesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShell
PesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShellPesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShell
PesterSec: Using Pester & ScriptAnalyzer to Detect Obfuscated PowerShell
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstack
 
Introduction to Snort Rule Writing
Introduction to Snort Rule WritingIntroduction to Snort Rule Writing
Introduction to Snort Rule Writing
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
 

Mais de Mark Curphey

Curphey AppSecUSA - Community The Killer Application
Curphey AppSecUSA - Community The Killer ApplicationCurphey AppSecUSA - Community The Killer Application
Curphey AppSecUSA - Community The Killer ApplicationMark Curphey
 
Software Security in the Real World
Software Security in the Real WorldSoftware Security in the Real World
Software Security in the Real WorldMark Curphey
 
Product Definition
Product DefinitionProduct Definition
Product DefinitionMark Curphey
 
Product Positioning and Lifecycle
Product Positioning and LifecycleProduct Positioning and Lifecycle
Product Positioning and LifecycleMark Curphey
 
Marketing Introduction
Marketing IntroductionMarketing Introduction
Marketing IntroductionMark Curphey
 
Advertising Theory
Advertising TheoryAdvertising Theory
Advertising TheoryMark Curphey
 
Innovators Dilemma Slides
Innovators Dilemma SlidesInnovators Dilemma Slides
Innovators Dilemma SlidesMark Curphey
 
Managing Corporate Information Security Risk in Financial Institutions
Managing Corporate Information Security Risk in Financial InstitutionsManaging Corporate Information Security Risk in Financial Institutions
Managing Corporate Information Security Risk in Financial InstitutionsMark Curphey
 

Mais de Mark Curphey (12)

Curphey AppSecUSA - Community The Killer Application
Curphey AppSecUSA - Community The Killer ApplicationCurphey AppSecUSA - Community The Killer Application
Curphey AppSecUSA - Community The Killer Application
 
Software Security in the Real World
Software Security in the Real WorldSoftware Security in the Real World
Software Security in the Real World
 
Research
ResearchResearch
Research
 
Product Definition
Product DefinitionProduct Definition
Product Definition
 
Product and Brand
Product and BrandProduct and Brand
Product and Brand
 
Product Positioning and Lifecycle
Product Positioning and LifecycleProduct Positioning and Lifecycle
Product Positioning and Lifecycle
 
New product Offer
New product OfferNew product Offer
New product Offer
 
Marketing Introduction
Marketing IntroductionMarketing Introduction
Marketing Introduction
 
Advertising Theory
Advertising TheoryAdvertising Theory
Advertising Theory
 
Innovators Dilemma Slides
Innovators Dilemma SlidesInnovators Dilemma Slides
Innovators Dilemma Slides
 
Managing Corporate Information Security Risk in Financial Institutions
Managing Corporate Information Security Risk in Financial InstitutionsManaging Corporate Information Security Risk in Financial Institutions
Managing Corporate Information Security Risk in Financial Institutions
 
Naked Security
Naked SecurityNaked Security
Naked Security
 

Último

Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsP&CO
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataExhibitors Data
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfAmzadHosen3
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayNZSG
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxWorkforce Group
 

Último (20)

Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pillsMifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors Data
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 

Hack in the Box Keynote 2006

  • 1. What application security tools vendors don’t want you to know and holes they will never find! Mark Curphey John Viega
  • 2.  
  • 3.  
  • 4.  
  • 5.  
  • 6.  
  • 7.  
  • 8.  
  • 9.  
  • 10.  
  • 11.  
  • 12.  
  • 13.  
  • 14.  
  • 15.  
  • 16.  
  • 17.  
  • 18.  
  • 19.  
  • 20.  
  • 21.  
  • 22.  
  • 23.  
  • 24.  
  • 25.  
  • 26.  
  • 27.  
  • 28.  
  • 29.  
  • 30.  
  • 31.  
  • 32.  
  • 33.  
  • 34.  
  • 35.  
  • 36.  
  • 37.  
  • 38.  
  • 39.  
  • 40.  
  • 41.  
  • 42. How Important is Context?
  • 43.  
  • 44.  
  • 45.  
  • 46.  
  • 47. Mozilla vs. Klocwork 611 “defects” 72 “vulnerabilities” 3 verified bugs 99.5% useless?
  • 48.  
  • 49.  
  • 50.  
  • 51. What kind of talk is this? Tools that try to find security holes in software Way for us to understand and rationalize why they are so bad and unlikely to get much better soon It is a realistic state of the union about the current state of application security technology and how it is being marketed and applied Dr. Holger Peine http://fhgonline.fraunhofer.de/server?suche-publica&num=048.06/D&iese (N.B. about overly generous quote to Cenzic) Arian Evans http://www.owasp.org/index.php/Image:AppSec2005DC-Arian_Evans_Tools-Taxonomy.ppt
  • 52.
  • 53.  
  • 54.  
  • 55.  
  • 56. How is security built in the real world?
  • 57.  
  • 58.  
  • 59.  
  • 60. How is security built in the real world?
  • 61. How is security built in the real world?
  • 62.  
  • 63. Implementation Bugs vs. Design Flaws
  • 64. Security Frame of Reference Name Description Configuration Management Configs, security managers, web server settings etc. Authentication Knowing users and entities are who they claim to be Authorization Who can do what to whom, TOCTOU etc. Data Protection (Transit & Storage) Encrypted passwords, on-wire protection, channel sinks, encrypted configuration files etc. Data Validation Valid, well formed, free of malicious payloads etc. Auditing and Logging Knowing who does what to whom etc. Error & Exception Handling What happens when the pooh hits the fan etc. User Management Password reset, registration, licensing etc.
  • 65.  
  • 66.
  • 67. Configuration Management ASP.NET application running in partial trust Revert.ToSelf(); Implementation Bug Design Flaw * good at many web server config issues Web App Scanners Hard coded connection string in configuration files Use of common crypto keys across Implemntations Hosted Environment
  • 68. Data Validation Implementation Bug Design Flaw Web App Scanners Canonicalization Internationalization Stored cross site scripting (even basic XSS in some cases) SQL injection (non ‘) Buffer overflows NOT HTTP 500’s! * Their strongest category
  • 69. Data protection Implementation Bug Design Flaw Web App Scanners Clear text passwords stored in database Weak algorithms * Reusing keys with stream ciphers Weak random number generators Secure memory management issues
  • 70. User Management Clear text passwords in the database Password expiry Password reset sent in clear Implementation Bug Design Flaw Web App Scanners Password generation on reset Weak session ID’s
  • 71. Grep: Lack of Context … strcpy(dst, src); // Generally a “high severity” error … strncpy(dst, src); // Generally a filtered out “low sev” …
  • 72. Grep: Lack of Context … // Generally a “high severity” error strcpy(dst, src); // Generally a “high severity” error … // Generally “low severity”, filtered out by default strncpy(dst, src, n); …
  • 73. Grep: Lack of Context void copy_20(char *src) { char dst[20]; int n; if (strlen(src) > 19) { return 0; } strcpy(dst, src); return strdup(dst); }
  • 74. Grep: Lack of Context void copy(char *dst, char *src) { int n = strlen(src); strncpy(dst, src, n); return strdup(dst); } … char d[20]; copy(d, arbitrary_user_input);
  • 75.
  • 76. Let’s try to do better with “real” static analysis!
  • 77.  
  • 78.
  • 79.
  • 80. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,0] alloc(B2) [100,100] len(B2) [0,0] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 81. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,0] alloc(B2) [100,100] len(B2) [0,0] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 82. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,0] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 83. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,1] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 84. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,1] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 85. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 86. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,0] i <- i + 1
  • 87. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] 4 len(ARGV) -> len(B1) len(B2) -> len(B2) + 1 i [0,max] i <- i + 1
  • 88. alloc(ARGV) [0,max] alloc(B1) [100,100] len(ARGV) [0,max] len(B1) [0,max] alloc(B2) [100,100] len(B2) [0,max] Okay: no incoming edges to len(ARGV) RANGE OVERLAPS: B1 MAY OVERFLOW RANGE OVERLAPS: B2 MAY OVERFLOW
  • 89.
  • 90.
  • 91.
  • 92. A good analysis requires some understanding of control flow!
  • 93.
  • 94.
  • 95. Control Flow void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max] others: nil alloc(b): 100
  • 96. Control Flow void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max] others: nil alloc(b): 100 len(b): 4
  • 97. Control Flow void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max] others: nil Write to B. Does it overflow? alloc(b): 100 len(b): 4
  • 98. Control Flow void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max] others: nil No. At this node, B is alloc’d to 100, actual len of 4. alloc(b): 100 len(b): 4
  • 99. Control Flow B: alloc(100) B: len(4) void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } Entry argc: [0,max] others: nil
  • 100. Control Flow void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False Entry argc: [0,max] others: nil alloc(b): 100 len(b): 4
  • 101. Control Flow argc: [2, max] Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if( argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False alloc(b): 100 len(b): 4
  • 102. Control Flow argc: [2, max] len(argv): [0, 100] alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100 ) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False
  • 103. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100]
  • 104. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] No overflow. b is alloc’d to 100, len can be no more than 100 after null is added.
  • 105. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for ( i=0 ;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0
  • 106. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 100] Use the worst case assumption for the length of b.
  • 107. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 100] len(b): [0, 101]
  • 108. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil void main(int argc, char **argv) { char *b = malloc(100); int i; strcpy(b, “foo”); if(argc > 1 && len(argv[1]) < 100) strcpy(b, argv[1]); for (i=0;i<3;i++) strcat(b, “.”); } True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 100] len(b): [0, 101] ERROR: len(b) > alloc(b)!!!
  • 109. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 100] len(b): [0, 101] Could show you the graph to help you debug…
  • 110. Control Flow alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 100] len(b): [0, 101] If you’re a rocket scientist  (graphs get big and complex in real programs)
  • 111.
  • 112.
  • 113.
  • 114. Issue 1 void main(int argc, char **argv) { char *b = malloc( 100000 ); int n = argc; for (i=0;i<n;i++) strcat(b, “.”); }
  • 115. Issue 1 void main(int argc, char **argv) { char *b = malloc(100000); int n = argc; for (i=0;i<n;i++) strcat(b, “.”); } In a more complex example, would we really have to “run” the loop MAX_INT times?
  • 116. Issue 1 void main(int argc, char **argv) { char *b = malloc(100000); int n = argc; for (i=0;i<n;i++) strcat(b, “.”); } In this case, we could multiply the effect by the maximum value of n.
  • 117. Issue 1 void main(int argc, char **argv) { char *b = malloc(100000); int n = argc; for (i=0;i<n;i++) strcat(b, “.”); } More complex cases aren’t that easy, and require approximations!
  • 118. Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 100] We lost accuracy when we merged.
  • 119. Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 101] i = 0 len(b): 4
  • 120. Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 We can show which path is bad! And, future calculations become much more accurate. len(b): [0, 101] i = 0 len(b): 4
  • 121. Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 101] i = 0 len(b): 4 An exponential explosion of nodes Only feasible for single functions (intraprocedural analysis)
  • 122. Issue 2 alloc(b): 100 len(b): 4 Entry argc: [0,max] others: nil True False argc: [2, max] len(argv): [0, 100] len(b): [0, 100] i = 0 len(b): [0, 101] i = 0 len(b): 4 Full path analysis is even less feasible when we consider exits from complex loops
  • 123. The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; }
  • 124. The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } No matter how accurate we get inside the procedure, we are in a catch-22 (spam vs. ignore)
  • 125. The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } Instead of erroring, we can “summarize” the generic properties.
  • 126. The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } e.g., len(a) <- len(b)
  • 127. The problem with intraprocedural char *magic_function(char *a, char *b) { char *p1 = a; char *p2 = b; while (*p2) *p1++ = *p2++; return a; } Scaling algorithms to an entire program can greatly improve accuracy… and decrease efficiency!
  • 128.
  • 129.
  • 130.
  • 131. Everybody gets this right… for the wrong reasons secureConnect (host, port): s = sslConnect(gethostbyaddr(host), port) cert = get_cert(s) if ! certSignedByTrustedRoot(cert): raise “SSLError” if cert.DN <> host: raise “SSLError” if ! subjAltNameMatches(cert, host): raise “SSLError” if certRevoked(cert): raise “SSLError” return s
  • 132. If you’re not an auditor, it probably isn’t cost effective!
  • 133. Notes on Buying Automated Tools Trials are limited for a reason (as are the EULA’s) Make sure you test them on your own site / code
  • 134. “ The height of mediocrity is still low” Basic Conclusion
  • 135. Accuracy on basic software today is mediocre at best It is really easy to write an application that can’t be automatically scanned It is really hard to write an automated scanner than can effectively analyze software Basic Conclusion
  • 136.  
  • 137. PCI Data Security Standards
  • 138.  
  • 139. 6.6 Ensure that all web-facing applications are protected against known attacks by applying either of the following methods: • Having all custom application code reviewed for common vulnerabilities by an organization that specializes in application security • Installing an application layer firewall in front of web-facing applications.   Note: This method is considered a best practice until June 30, 2008, after which it becomes a requirement.   Full document at https://www.pcisecuritystandards.org/tech/download_the_pci_dss.htm PCI-DSS is now managed by an industry consortium at www.pcisecuritystandards.org
  • 140. …… or go straight to the document here! https://www.pcisecuritystandards.org/pdfs/pci_dss_v1-1.pdf
  • 141.  
  • 142. Introducing the only tool in the world that really works effectively today……
  • 143.  
  • 144. News for people who run tools
  • 145. A fool with a tool … .is still a fool
  • 146. China!
  • 147. China!
  • 148. China!
  • 150.
  • 151.
  • 152.