what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

t1lib.txt

t1lib.txt
Posted Jul 28, 2007
Authored by Hamid Ebadi | Site bugtraq.ir

T1Lib suffers from a buffer overflow vulnerability.

tags | advisory, overflow
SHA-256 | e458426df992d1f944cf9b6219df3579a54b0f39470b76d5edfd2a6896d69c2f

t1lib.txt

Change Mirror Download
T1Lib Buffer Overflow Vulnerability



T1Lib
Vulnerability Description
PHP and T1Lib
Exploitation Possibility
Workaround
Credits




T1Lib

t1lib is a library written in C which implements functions for generating bitmaps from Adobe Type 1 fonts.
It uses most internal parts of the Type 1 rasterizer provided with X11R5 and newer but tries avoid the disadvantages
known from that rasterizer. Although most people would use the rasterizer under X11, having X11 is not necessary at all.
The rasterizer is implemented as a shared or static library to be linked to the programs that want to use Type 1 fonts.
In addition to this library there is a test-program called xglyph which, as the name indicates, requires X11. It can be
used to show most of the features of the library. xglyph can be run out of the box without doing any X11 configuration
like setting resources.


Vulnerability Description

there exists a buffer overflow vulnerability char * intT1_Env_GetCompletePath() of t1lib/t1env.c
which caused by unchecked boundary in strcat(pathbuf, StrippedName);
pathbuf is a global function defined as static char pathbuf[2048]; and so is allocated in Heap memory.
therefore we have a buffer overflow situation by feeding the first argument of intT1_Env_GetCompletePath() which is
char *filename, a big string.




PHP and T1Lib

t1lib is used in many application, perhaps the most popular one is PHP 5.x and 4.x.
when PHP is configured with '--with-t1lib=[PATH]' then t1lib is staticly linked with PHP. the shared object
which contains the vulnerable function is libt1.so.5. then every enabled PHP function which related to t1lib
could be a target, we found imagepsloadfont() which accepts a filename, which then calls the affected t1lib function.


Exploitation Possibility

Linux (slackware 10.2 - kernel 2.4.31 - php 4.4.7) :

with small values (<70000) when trying to derefrence edx in
<strcat+26>: testb [edx], 0xff
we get a segmentation fault due the invalid memory address edx points to. edx is somehow controled by us
and is actually related to the size of string. anyway when increase the size of input we die at
<strcat+272>: mov DWORD PTR [ecx+edx+12],eax
checking the registers we see that eax is directly controled by our input but ecx and edx remain the same with
different size of inputs. so memory overwrite seems to be impossible in this situation too. so does code execution.

Windows (2003 sever - no service pack - php 5.2.2) :

with values about 61800 byts of input and higher we get access violation at:
php_gd2!phpi_get_le_gd+0x7feab : movsd ds:0115dd0c=44444444
trying to read from where edi points to. by changing the size of input it indicates that we have no control over edi
so we access violate whenever we use strings with the sizes over 61800.
this time we try with size of 61000, we have direct control over eax, edi and esi somehow we die at:
php_gd2!phpi_get_le_gd+0x76e85 : mov eax, [eax+esi-0x98]
trying to read from eax+esi-0x98.
so we might pass this instruction and reach code execution. no furthur honey in this case.
when we try with 7814 bytes we die at:
ntdll!RtlDeleteCriticalSection+0xf : mov eax, [ebx+0x10]
controlling eax and ebx with the same value, so if you have some good memory A which A+10 points to somewhere good
and also A itself is some kind of exception handler this could be a way to go. (I know its unlikely :p) but anyway
you can corrupt memory. like somewhere in safe_mode function handling etc etc.


Workaround

Don't use t1lib till a patch or a newer version comes out.
in PHP you can disable functions which use t1lib. or compile again without t1lib support.


Credits

Vulnerability Discovery : Hamid Ebadi ebadi@bugtraq.ir
Vulnetability Research : Kaveh Razavi razavi@bugtraq.ir

all the other people contributing in www.bugtraq.ir ,
Alireza Danesh, Mohammad Mozaffari and others...

ps. no more time to research since yesterday somebody reported a bug in PHP regarding imagepsloadfont()
which we now know it is not a PHP one.
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    0 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close