exploit the possibilities
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:

March 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close