Skip to content

Commit ed27e28

Browse files
committed
Fixed Path Traversal security vulnerability reported by Positive Technologies
1 parent f67b761 commit ed27e28

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

CHANGELOG.TXT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
6.9.0 (2025-04-03)
2+
- Fixed Path Traversal security vulnerability reported by Positive Technologies.
3+
14
6.9.0 (2025-03-30)
25
- Added PHP 8.4 testing.
36
- Removed tcpdf_import.php and tcpdf_parser.php files (for a parser check the tc-lib-pdf-parser project instead).

VERSION

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

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.0",
15+
"version": "6.9.1",
1616
"license": "LGPL-3.0-or-later",
1717
"authors": [
1818
{

include/tcpdf_static.php

Lines changed: 1 addition & 2 deletions
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.0';
58+
private static $tcpdf_version = '6.9.1';
5959

6060
/**
6161
* String alias for total number of pages.
@@ -2652,7 +2652,6 @@ public static function getPageMode($mode='UseNone') {
26522652
return $page_mode;
26532653
}
26542654

2655-
26562655
} // END OF TCPDF_STATIC CLASS
26572656

26582657
//============================================================+

tcpdf.php

Lines changed: 17 additions & 6 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.0
4+
// Version : 6.9.1
55
// Begin : 2002-08-03
6-
// Last Update : 2025-03-30
6+
// Last Update : 2025-04-03
77
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
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.0
107+
* @version 6.9.1
108108
*/
109109

110110
// TCPDF configuration
@@ -128,7 +128,7 @@
128128
* 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>
129129
* @package com.tecnick.tcpdf
130130
* @brief PHP class for generating PDF documents without requiring external extensions.
131-
* @version 6.9.0
131+
* @version 6.9.1
132132
* @author Nicola Asuni - [email protected]
133133
* @IgnoreAnnotation("protected")
134134
* @IgnoreAnnotation("public")
@@ -18868,6 +18868,17 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal
1886818868
unset($dom);
1886918869
}
1887018870

18871+
/**
18872+
* Check if the path is relative.
18873+
* @param string $path path to check
18874+
* @return boolean true if the path is relative
18875+
* @protected
18876+
* @since 6.9.1
18877+
*/
18878+
protected function isRelativePath($path) {
18879+
return (strpos(str_ireplace('%2E', '.', $this->unhtmlentities($path)), '..') !== false);
18880+
}
18881+
1887118882
/**
1887218883
* Process opening tags.
1887318884
* @param array $dom html dom array
@@ -19060,7 +19071,7 @@ protected function openHTMLTagHandler($dom, $key, $cell) {
1906019071
} else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) {
1906119072
$imgsrc = '@'.base64_decode($reg[2]);
1906219073
$type = $reg[1];
19063-
} elseif (strpos($imgsrc, '../') !== false) {
19074+
} elseif ($this->isRelativePath($imgsrc)) {
1906419075
// accessing parent folders is not allowed
1906519076
break;
1906619077
} elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') {
@@ -24467,7 +24478,7 @@ protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array()
2446724478
$img = '@'.base64_decode(substr($img, strlen($m[0])));
2446824479
} else {
2446924480
// fix image path
24470-
if (strpos($img, '../') !== false) {
24481+
if ($this->isRelativePath($img)) {
2447124482
// accessing parent folders is not allowed
2447224483
break;
2447324484
}

0 commit comments

Comments
 (0)