Skip to content

Commit 773b944

Browse files
Merge remote-tracking branch 'upstream/main' into main
2 parents 8b25f35 + d0e8dd1 commit 773b944

6 files changed

Lines changed: 67 additions & 26 deletions

File tree

CHANGELOG.TXT

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
6.9.0 (2025-04-03)
2-
- Fixed Path Traversal security vulnerability reported by Positive Technologies.
1+
6.9.3 (2025-04-20)
2+
- New fix for "Deserialization of untrusted data" (check on valid protocols).
3+
- Removed global phar configuration.
4+
5+
6.9.2 (2025-04-18)
6+
- Quick fix for "Deserialization of untrusted data" security vulnerability reported by Positive Technologies.
7+
- Disable phar protocol globally.
8+
9+
6.9.1 (2025-04-03)
10+
- Fixed "Path Traversal" security vulnerability reported by Positive Technologies.
311

412
6.9.0 (2025-03-30)
513
- Added PHP 8.4 testing.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.9.1
1+
6.9.3

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"barcodes"
1313
],
1414
"homepage": "http://www.tcpdf.org/",
15-
"version": "6.9.1-p1",
15+
"version": "6.9.3-p1",
1616
"license": "LGPL-3.0-or-later",
1717
"authors": [
1818
{

include/tcpdf_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TCPDF_STATIC {
5555
* Current TCPDF version.
5656
* @private static
5757
*/
58-
private static $tcpdf_version = '6.9.1-p1';
58+
private static $tcpdf_version = '6.9.3-p1';
5959

6060
/**
6161
* String alias for total number of pages.

tcpdf.php

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
//============================================================+
33
// File name : tcpdf.php
4-
// Version : 6.9.1
4+
// Version : 6.9.3
55
// Begin : 2002-08-03
6-
// Last Update : 2025-04-03
6+
// Last Update : 2025-04-18
77
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
88
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
99
// -------------------------------------------------------------------
@@ -104,7 +104,7 @@
104104
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
105105
* @package com.tecnick.tcpdf
106106
* @author Nicola Asuni
107-
* @version 6.9.1
107+
* @version 6.9.3
108108
*/
109109

110110
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -115,7 +115,7 @@
115115
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
116116
* @package com.tecnick.tcpdf
117117
* @brief PHP class for generating PDF documents without requiring external extensions.
118-
* @version 6.9.1
118+
* @version 6.9.3
119119
* @author Nicola Asuni - info@tecnick.com
120120
* @IgnoreAnnotation("protected")
121121
* @IgnoreAnnotation("public")
@@ -7024,7 +7024,7 @@ public function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='', $
70247024
unset($imgdata);
70257025
$imsize = @getimagesize($file);
70267026
if ($imsize === FALSE) {
7027-
unlink($file);
7027+
$this->_unlink($file);
70287028
$file = $original_file;
70297029
}
70307030
}
@@ -7257,7 +7257,7 @@ public function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='', $
72577257
$tempname = TCPDF_STATIC::getObjFilename('img', $this->file_id);
72587258
$img->writeImage($tempname);
72597259
$info = TCPDF_IMAGES::_parsejpeg($tempname);
7260-
unlink($tempname);
7260+
$this->_unlink($tempname);
72617261
$img->destroy();
72627262
} catch(Exception $e) {
72637263
$info = false;
@@ -7892,16 +7892,17 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
78927892
// remove all temporary files
78937893
if ($handle = @opendir(K_PATH_CACHE)) {
78947894
while ( false !== ( $file_name = readdir( $handle ) ) ) {
7895-
if (strpos($file_name, '__tcpdf_'.$this->file_id.'_') === 0 && @TCPDF_STATIC::file_exists(K_PATH_CACHE . $file_name)) {
7896-
@unlink(K_PATH_CACHE . $file_name);
7895+
if (strpos($file_name, '__tcpdf_'.$this->file_id.'_') === 0) {
7896+
$this->_unlink(K_PATH_CACHE.$file_name);
78977897
}
78987898
}
78997899
closedir($handle);
79007900
}
79017901
if (isset($this->imagekeys)) {
79027902
foreach($this->imagekeys as $file) {
7903-
if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) {
7904-
@unlink($file);
7903+
if ((strpos($file, K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_') === 0)
7904+
&& TCPDF_STATIC::file_exists($file)) {
7905+
$this->_unlink($file);
79057906
}
79067907
}
79077908
}
@@ -18929,10 +18930,22 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal
1892918930
* @protected
1893018931
* @since 6.9.1
1893118932
*/
18932-
protected function isRelativePath($path) {
18933+
protected function isRelativePath($path) {
1893318934
return (strpos(str_ireplace('%2E', '.', $this->unhtmlentities($path)), '..') !== false);
1893418935
}
1893518936

18937+
/**
18938+
* Check if it contains a non-allowed external protocol.
18939+
* @param string $path path to check
18940+
* @return boolean true if the protocol is not allowed.
18941+
* @protected
18942+
* @since 6.9.3
18943+
*/
18944+
protected function hasExtForbiddenProtocol($path) {
18945+
return ((strpos($path, '://') !== false)
18946+
&& (preg_match('|^https?://|', $path) !== 1));
18947+
}
18948+
1893618949
/**
1893718950
* Process opening tags.
1893818951
* @param array $dom html dom array
@@ -19129,11 +19142,13 @@ protected function openHTMLTagHandler($dom, $key, $cell) {
1912919142
// accessing parent folders is not allowed
1913019143
break;
1913119144
} elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') {
19132-
// get image type from a local file path
19133-
$imgsrc = substr($imgsrc, 7);
19134-
$type = TCPDF_IMAGES::getImageFileType($imgsrc);
19135-
} else {
19136-
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')
19145+
// get image type from a local file path
19146+
$imgsrc = substr($imgsrc, 7);
19147+
$type = TCPDF_IMAGES::getImageFileType($imgsrc);
19148+
} elseif ($this->hasExtForbiddenProtocol($imgsrc)) {
19149+
break;
19150+
} else {
19151+
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')
1913719152
AND !@TCPDF_STATIC::file_exists($imgsrc)
1913819153
) {
1913919154
// fix image path
@@ -24534,8 +24549,7 @@ protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array()
2453424549
$img = '@'.base64_decode(substr($img, strlen($m[0])));
2453524550
} else {
2453624551
// fix image path
24537-
if ($this->isRelativePath($img)) {
24538-
// accessing parent folders is not allowed
24552+
if ($this->isRelativePath($img) || $this->hasExtForbiddenProtocol($img)) {
2453924553
break;
2454024554
}
2454124555
if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) {
@@ -24848,6 +24862,20 @@ protected function fileExists($file)
2484824862
return TCPDF_STATIC::file_exists($file);
2484924863
}
2485024864

24865+
/**
24866+
* Wrapper for unlink with disabled protocols.
24867+
* @param string $file
24868+
* @return bool
24869+
*/
24870+
protected function _unlink($file)
24871+
{
24872+
if ((strpos($file, '://') !== false) && ((substr($file, 0, 7) !== 'file://') || (!$this->allowLocalFiles))) {
24873+
// forbidden protocol
24874+
return false;
24875+
}
24876+
return @unlink($file);
24877+
}
24878+
2485124879
} // END OF TCPDF CLASS
2485224880

2485324881
//============================================================+

tcpdf_autoconfig.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// File name : tcpdf_autoconfig.php
44
// Version : 1.1.1
55
// Begin : 2013-05-16
6-
// Last Update : 2014-12-18
6+
// Last Update : 2025-04-18
77
// Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
88
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
99
// -------------------------------------------------------------------
10-
// Copyright (C) 2011-2014 Nicola Asuni - Tecnick.com LTD
10+
// Copyright (C) 2011-2025 Nicola Asuni - Tecnick.com LTD
1111
//
1212
// This file is part of TCPDF software library.
1313
//
@@ -37,9 +37,14 @@
3737
* @file
3838
* Try to automatically configure some TCPDF constants if not defined.
3939
* @package com.tecnick.tcpdf
40-
* @version 1.1.1
40+
* @version 1.2.1
4141
*/
4242

43+
// Disable phar stream wrapper globally.
44+
// if (in_array('phar', stream_get_wrappers(), true)) {
45+
// stream_wrapper_unregister('phar');
46+
// }
47+
4348
// Load main configuration file only if the K_TCPDF_EXTERNAL_CONFIG constant is set to false.
4449
if (!defined('K_TCPDF_EXTERNAL_CONFIG') OR !K_TCPDF_EXTERNAL_CONFIG) {
4550
// define a list of default config files in order of priority

0 commit comments

Comments
 (0)