SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Principles Of Secure Coding



            JPEG Integer Underflow
                Microsoft Security Bulletin MS04-028




 Ashish Malik
 1731110017
Microsoft JPEG Vulnerability

Jpeg's themselves are not the problem however. Problem lies in
the application that reads this information and displays the
pictures on screen.
The exploit triggers an overflow in a common windows
component called the GDI+ Jpeg Decoder.
Vulnerability specifically resides in “gdiplus.dll”.
These attack images are not technically a virus.
Different windows applications frequently distribute their own
versions of GDI+.
Buffer Overflow

Application fails to check the size of input data before copying it
to memory.
Two types of buffer overflows :
Stack Overflow
Heap Overflow


Stack and Heap are memory regions used by a process for storing
various types of data.
Stack Overflow

When a process makes a function call, the address of the next
instruction, known as the return pointer, or RET is pushed onto
stack.
Function call parameters are pushed on after RET.
Execution then jumps to the address of the called function.
Stack Overflow
Stack Overflow
Heap Overflow

Region of memory used by a process for accommodating data of
sizes unknown at compile time.
Created within a process's virtual address space.
OS is responsible for heap management.
                    Malloc() or HeapAlloc()
Standard heap contains an array called Free List, used to track
the locations of free heap blocks.
Heap Overflow
Heap Overflow
Heap Overflow
Heap Overflow
GDI+ Jpeg Vulnerability

Jpeg format defines a no. of headers.
The vulnerability described in MS04-028 lies in how GDI+
handles the comment header.
Each header segment begins with a 2-bytes ID.
Comment header consist of COM marker(0xFFFE)
GDI+ calculates the comment length by 2 from the value of
length field.
GDI+ Jpeg Vulnerability

If length field specifies a comment length of 0 or 1, the GDI+
calculation results in a negative value.
 1 – 2 = -1 ≡ 0xFFFFFFFF ≡ 4GB - 1
It is interpreted as a positive integer in excess of 4 billion.
Unsigned integer of 32 bit is used to store the length of the
comment data.
GDI+ Jpeg Vulnerability

The GDI+ routine for copying the comment data to the heap is :
                      rep mov [edi], [esi]
The ECX register is used as the counter.
GDI+ allows excessively large counter value.
GDI+ handles access violation by requesting additional heap
space to continue with rep mov
HeapAlloc() returns pointers to heap locations, which contains
the JPEG data.
GDI+ Jpeg Vulnerability

The exploit takes advantage of this to overwrite the Unhandled
Exception Filter Pointer.
Exploits may also use some form of win32_reverse shellcode
from of Metasploit Project Shellcode Repository.
Q&A




Thank You

Weitere ähnliche Inhalte

Ähnlich wie Microsoft GDI+ JPEG Integer Underflow Vulnerability

Reconstructing Gapz: Position-Independent Code Analysis Problem
Reconstructing Gapz: Position-Independent Code Analysis ProblemReconstructing Gapz: Position-Independent Code Analysis Problem
Reconstructing Gapz: Position-Independent Code Analysis Problem
Alex Matrosov
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
DefCamp
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
Dmitri Nesteruk
 
Mirage: ML kernels in the cloud (ML Workshop 2010)
Mirage: ML kernels in the cloud (ML Workshop 2010)Mirage: ML kernels in the cloud (ML Workshop 2010)
Mirage: ML kernels in the cloud (ML Workshop 2010)
Anil Madhavapeddy
 

Ähnlich wie Microsoft GDI+ JPEG Integer Underflow Vulnerability (20)

[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
 
Reconstructing Gapz: Position-Independent Code Analysis Problem
Reconstructing Gapz: Position-Independent Code Analysis ProblemReconstructing Gapz: Position-Independent Code Analysis Problem
Reconstructing Gapz: Position-Independent Code Analysis Problem
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
 
Accelerated .NET Memory Dump Analysis training public slides
Accelerated .NET Memory Dump Analysis training public slidesAccelerated .NET Memory Dump Analysis training public slides
Accelerated .NET Memory Dump Analysis training public slides
 
EclipseCon 2011: Deciphering the CDT debugger alphabet soup
EclipseCon 2011: Deciphering the CDT debugger alphabet soupEclipseCon 2011: Deciphering the CDT debugger alphabet soup
EclipseCon 2011: Deciphering the CDT debugger alphabet soup
 
Parallel computation
Parallel computationParallel computation
Parallel computation
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
parallel-computation.pdf
parallel-computation.pdfparallel-computation.pdf
parallel-computation.pdf
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
Data race
Data raceData race
Data race
 
Tutorial 37 API Coding
Tutorial 37 API CodingTutorial 37 API Coding
Tutorial 37 API Coding
 
Static code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsStatic code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applications
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
 
Managed DirectX
Managed DirectXManaged DirectX
Managed DirectX
 
Mirage: ML kernels in the cloud (ML Workshop 2010)
Mirage: ML kernels in the cloud (ML Workshop 2010)Mirage: ML kernels in the cloud (ML Workshop 2010)
Mirage: ML kernels in the cloud (ML Workshop 2010)
 
Csharp dot net
Csharp dot netCsharp dot net
Csharp dot net
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Microsoft GDI+ JPEG Integer Underflow Vulnerability

  • 1. Principles Of Secure Coding JPEG Integer Underflow Microsoft Security Bulletin MS04-028 Ashish Malik 1731110017
  • 2. Microsoft JPEG Vulnerability Jpeg's themselves are not the problem however. Problem lies in the application that reads this information and displays the pictures on screen. The exploit triggers an overflow in a common windows component called the GDI+ Jpeg Decoder. Vulnerability specifically resides in “gdiplus.dll”. These attack images are not technically a virus. Different windows applications frequently distribute their own versions of GDI+.
  • 3. Buffer Overflow Application fails to check the size of input data before copying it to memory. Two types of buffer overflows : Stack Overflow Heap Overflow Stack and Heap are memory regions used by a process for storing various types of data.
  • 4. Stack Overflow When a process makes a function call, the address of the next instruction, known as the return pointer, or RET is pushed onto stack. Function call parameters are pushed on after RET. Execution then jumps to the address of the called function.
  • 7. Heap Overflow Region of memory used by a process for accommodating data of sizes unknown at compile time. Created within a process's virtual address space. OS is responsible for heap management. Malloc() or HeapAlloc() Standard heap contains an array called Free List, used to track the locations of free heap blocks.
  • 12. GDI+ Jpeg Vulnerability Jpeg format defines a no. of headers. The vulnerability described in MS04-028 lies in how GDI+ handles the comment header. Each header segment begins with a 2-bytes ID. Comment header consist of COM marker(0xFFFE) GDI+ calculates the comment length by 2 from the value of length field.
  • 13. GDI+ Jpeg Vulnerability If length field specifies a comment length of 0 or 1, the GDI+ calculation results in a negative value. 1 – 2 = -1 ≡ 0xFFFFFFFF ≡ 4GB - 1 It is interpreted as a positive integer in excess of 4 billion. Unsigned integer of 32 bit is used to store the length of the comment data.
  • 14. GDI+ Jpeg Vulnerability The GDI+ routine for copying the comment data to the heap is : rep mov [edi], [esi] The ECX register is used as the counter. GDI+ allows excessively large counter value. GDI+ handles access violation by requesting additional heap space to continue with rep mov HeapAlloc() returns pointers to heap locations, which contains the JPEG data.
  • 15. GDI+ Jpeg Vulnerability The exploit takes advantage of this to overwrite the Unhandled Exception Filter Pointer. Exploits may also use some form of win32_reverse shellcode from of Metasploit Project Shellcode Repository.