mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Document - fix stored xss
https://huntr.dev/bounties/99c4ed09-b66f-474a-bd74-eeccf9339fde/
This commit is contained in:
parent
9d7145c61b
commit
2b8af442cc
@ -4,6 +4,7 @@ namespace App\Libraries;
|
|||||||
|
|
||||||
use HTMLPurifier;
|
use HTMLPurifier;
|
||||||
use HTMLPurifier_Config;
|
use HTMLPurifier_Config;
|
||||||
|
use enshrined\svgSanitize\Sanitizer;
|
||||||
|
|
||||||
class HTMLUtils
|
class HTMLUtils
|
||||||
{
|
{
|
||||||
@ -74,4 +75,15 @@ class HTMLUtils
|
|||||||
|
|
||||||
return env($key, env($field, $default));
|
return env($key, env($field, $default));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function sanitizeSVG($svg)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$sanitizer = new Sanitizer();
|
||||||
|
|
||||||
|
return $sanitizer->sanitize($svg);
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use DB;
|
|||||||
use Form;
|
use Form;
|
||||||
use Intervention\Image\ImageManager;
|
use Intervention\Image\ImageManager;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
use App\Libraries\HTMLUtils;
|
||||||
|
|
||||||
class DocumentRepository extends BaseRepository
|
class DocumentRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
@ -83,6 +84,14 @@ class DocumentRepository extends BaseRepository
|
|||||||
return 'File too large';
|
return 'File too large';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($documentType === 'svg') {
|
||||||
|
$stream = file_get_contents($filePath);
|
||||||
|
if(!($stream = HTMLUtils::sanitizeSVG($stream))) {
|
||||||
|
return 'Unsupported file type';
|
||||||
|
}
|
||||||
|
file_put_contents($filePath, $stream);
|
||||||
|
}
|
||||||
|
|
||||||
// don't allow a document to be linked to both an invoice and an expense
|
// don't allow a document to be linked to both an invoice and an expense
|
||||||
if (array_get($data, 'invoice_id') && array_get($data, 'expense_id')) {
|
if (array_get($data, 'invoice_id') && array_get($data, 'expense_id')) {
|
||||||
unset($data['expense_id']);
|
unset($data['expense_id']);
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
"digitickets/omnipay-realex": "~5.0",
|
"digitickets/omnipay-realex": "~5.0",
|
||||||
"doctrine/dbal": "2.6.x",
|
"doctrine/dbal": "2.6.x",
|
||||||
"dompdf/dompdf": "0.6.2",
|
"dompdf/dompdf": "0.6.2",
|
||||||
|
"enshrined/svg-sanitize": "^0.14.1",
|
||||||
"ezyang/htmlpurifier": "~v4.7",
|
"ezyang/htmlpurifier": "~v4.7",
|
||||||
"fotografde/omnipay-checkoutcom": "~2.0",
|
"fotografde/omnipay-checkoutcom": "~2.0",
|
||||||
"fruitcakestudio/omnipay-sisow": "~2.0",
|
"fruitcakestudio/omnipay-sisow": "~2.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user