SlideShare a Scribd company logo
WHEN GOOD CODE GOES BAD! A SHOWCASE OF MODERN PROGRAMMING MISHAPS (SensePost 2006)
Introduction Who we are.. (SensePost) Who we are.. (charl && haroon) What this talk is about.. Answer some of those questions you never ask.. Some real world examples (of shocking code) Some real world repercussions Mind the Gap Constraints…
Agenda What is this stack overflow stuff? Then what’s a format string vulnerability? Hmmm.. What’s all this about dangerous Integers? What happens if we fix all the code? Questions..
What’s this Stack Overflow stuff? This is really old news..  (Morris Worm 1988) Is it even still a problem? Super simple explanation: The Stack.. Dangerous functions
Super Simple Explanation.. void foo(int a, int b) { char buf1[8]; char buf2[8]; gets(buf2); } int main(void) { foo(1,2); printf(“All done!”) }
Typical Attack.. void foo(int a, int b) { char buf1[8]; char buf2[8]; gets(buf2); } int main(void) { foo(1,2); printf(“All done!”) }
What’s this Stack Overflow stuff? This is really old news..  (Morris Worm 1988) Is it even still a problem? Super simple explanation: The Stack.. Dangerous functions Who would make such a silly mistake? Everyone… How easy is this to take advantage of? Today? Point & Click ownage!
Then what’s a format string bug? Spot the bug ? “Safe Version” See it yet? void syslog(char *buff) { printf(buff) } void syslog(char *buff) { printf(“%s”, buff) }
Then what’s a format string bug? printf(“%s”, buff); printf(buff);
Then what’s a format string bug? printf(“%s”, buff); buff = “%s”; printf(buff); C:\>  issa_format.exe
What’s a dangerous Integer?
What’s a dangerous Integer? Same size as a pointer Fixed size (32 bits for our purposes) MAXINT + 1 == ? ISO C99   “Causes Undefined Behavior” 0xffffffff + 0x1 == 0  {Integer Wrap Around} Why is this dangerous ?
Ugly Pseudo-Code 1.) get data from user (buffer) 2.) add trailing \0 character 3.) add 1 to length of buffer (for our \0) 4.) If(length > 80) 5.) {  6.) printf(“Sorry your buffer is too long!”;  7.) exit -1 8.) } 9.) else 0.) {  copy(other_buffer, buffer); }
What happens if we fix all the code? The proliferation of “Managed Code” Better and better static code analysis.. Is the end in sight for bug hunters? RealVNC Authentication Bypass ActiveX Control
RealVNC Authentication Bypass Discovered by Steve Wiseman of intelliadmin.com (by mistake)
RealVNC Authentication Bypass “ show us”
What does this mean? Vendors: There are lots of defects that tools can not easily detect.. (There are lots of defects they can!) No vendor is safe just because they have deeper pockets (or “more eyeballs”) ISO’s: Defense in Depth.. End-point-security.. Patch Management ? If it can happen to Microsoft …
Questions ? [email_address] [email_address]

More Related Content

PDF
Penetration testing and social engineering
PDF
Heartbleed Overview
PDF
Corporate Threat Modeling v2
PPT
Its Ok To Get Hacked
PPT
Major global information security trends - a summary
PDF
Setiri : Advances in trojan technology
PPT
Security threats facing SA businessess
PDF
Botconf 2013 - DNS-based Botnet C2 Server Detection
Penetration testing and social engineering
Heartbleed Overview
Corporate Threat Modeling v2
Its Ok To Get Hacked
Major global information security trends - a summary
Setiri : Advances in trojan technology
Security threats facing SA businessess
Botconf 2013 - DNS-based Botnet C2 Server Detection

Similar to When good code goes bad (20)

PPTX
Format String Attack
PDF
Secure Coding Practices for Middleware
PPTX
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
PDF
Safety of 64-bit code
PPT
Buffer Overflows
PPT
Buffer OverFlow
PDF
Fuzzing - Part 1
PPT
6 buffer overflows
PPTX
20101017 program analysis_for_security_livshits_lecture03_security
PDF
Software Security
DOCX
What
PDF
2.Format Strings
PDF
Secure Coding in C/C++
PDF
2 buffer overflows
PDF
StackOverflow
PDF
Format string
PPTX
Stack-Based Buffer Overflows
PDF
Insecure coding in C (and C++)
PDF
printf tricks
PDF
1.Buffer Overflows
Format String Attack
Secure Coding Practices for Middleware
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
Safety of 64-bit code
Buffer Overflows
Buffer OverFlow
Fuzzing - Part 1
6 buffer overflows
20101017 program analysis_for_security_livshits_lecture03_security
Software Security
What
2.Format Strings
Secure Coding in C/C++
2 buffer overflows
StackOverflow
Format string
Stack-Based Buffer Overflows
Insecure coding in C (and C++)
printf tricks
1.Buffer Overflows
Ad

More from SensePost (20)

PDF
objection - runtime mobile exploration
PPTX
Vulnerabilities in TN3270 based Application
PDF
Ruler and Liniaal @ Troopers 17
PDF
Introducing (DET) the Data Exfiltration Toolkit
PPTX
ZaCon 2015 - Zombie Mana Attacks
PPTX
Improvement in Rogue Access Points - SensePost Defcon 22
PPTX
Rat a-tat-tat
PDF
Hacking Z-Wave Home Automation Systems
PPTX
Offence oriented Defence
PPTX
Threats to machine clouds
PPTX
Inside .NET Smart Card Operating System
PDF
SNMP : Simple Network Mediated (Cisco) Pwnage
PPT
Web Application Hacking
PDF
Putting the tea back into cyber terrorism
PPT
Attacks and Defences
PPTX
State of the information security nation
PPS
OK I'm here, so what's in it for me?
PPT
Security in e-commerce
PDF
Getting punched in the face
PDF
The jar of joy
objection - runtime mobile exploration
Vulnerabilities in TN3270 based Application
Ruler and Liniaal @ Troopers 17
Introducing (DET) the Data Exfiltration Toolkit
ZaCon 2015 - Zombie Mana Attacks
Improvement in Rogue Access Points - SensePost Defcon 22
Rat a-tat-tat
Hacking Z-Wave Home Automation Systems
Offence oriented Defence
Threats to machine clouds
Inside .NET Smart Card Operating System
SNMP : Simple Network Mediated (Cisco) Pwnage
Web Application Hacking
Putting the tea back into cyber terrorism
Attacks and Defences
State of the information security nation
OK I'm here, so what's in it for me?
Security in e-commerce
Getting punched in the face
The jar of joy
Ad

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MIND Revenue Release Quarter 2 2025 Press Release
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?

When good code goes bad

  • 1. WHEN GOOD CODE GOES BAD! A SHOWCASE OF MODERN PROGRAMMING MISHAPS (SensePost 2006)
  • 2. Introduction Who we are.. (SensePost) Who we are.. (charl && haroon) What this talk is about.. Answer some of those questions you never ask.. Some real world examples (of shocking code) Some real world repercussions Mind the Gap Constraints…
  • 3. Agenda What is this stack overflow stuff? Then what’s a format string vulnerability? Hmmm.. What’s all this about dangerous Integers? What happens if we fix all the code? Questions..
  • 4. What’s this Stack Overflow stuff? This is really old news.. (Morris Worm 1988) Is it even still a problem? Super simple explanation: The Stack.. Dangerous functions
  • 5. Super Simple Explanation.. void foo(int a, int b) { char buf1[8]; char buf2[8]; gets(buf2); } int main(void) { foo(1,2); printf(“All done!”) }
  • 6. Typical Attack.. void foo(int a, int b) { char buf1[8]; char buf2[8]; gets(buf2); } int main(void) { foo(1,2); printf(“All done!”) }
  • 7. What’s this Stack Overflow stuff? This is really old news.. (Morris Worm 1988) Is it even still a problem? Super simple explanation: The Stack.. Dangerous functions Who would make such a silly mistake? Everyone… How easy is this to take advantage of? Today? Point & Click ownage!
  • 8. Then what’s a format string bug? Spot the bug ? “Safe Version” See it yet? void syslog(char *buff) { printf(buff) } void syslog(char *buff) { printf(“%s”, buff) }
  • 9. Then what’s a format string bug? printf(“%s”, buff); printf(buff);
  • 10. Then what’s a format string bug? printf(“%s”, buff); buff = “%s”; printf(buff); C:\> issa_format.exe
  • 12. What’s a dangerous Integer? Same size as a pointer Fixed size (32 bits for our purposes) MAXINT + 1 == ? ISO C99  “Causes Undefined Behavior” 0xffffffff + 0x1 == 0 {Integer Wrap Around} Why is this dangerous ?
  • 13. Ugly Pseudo-Code 1.) get data from user (buffer) 2.) add trailing \0 character 3.) add 1 to length of buffer (for our \0) 4.) If(length > 80) 5.) { 6.) printf(“Sorry your buffer is too long!”; 7.) exit -1 8.) } 9.) else 0.) { copy(other_buffer, buffer); }
  • 14. What happens if we fix all the code? The proliferation of “Managed Code” Better and better static code analysis.. Is the end in sight for bug hunters? RealVNC Authentication Bypass ActiveX Control
  • 15. RealVNC Authentication Bypass Discovered by Steve Wiseman of intelliadmin.com (by mistake)
  • 17. What does this mean? Vendors: There are lots of defects that tools can not easily detect.. (There are lots of defects they can!) No vendor is safe just because they have deeper pockets (or “more eyeballs”) ISO’s: Defense in Depth.. End-point-security.. Patch Management ? If it can happen to Microsoft …
  • 18. Questions ? [email_address] [email_address]