Skip to content
Snippets Groups Projects
Commit 4dfb77ca authored by Peter Rotich's avatar Peter Rotich
Browse files

Arbitrary Method Invocation

This commit addresses possible Arbitrary Method Invocation via AJAX file upload.

To save some memory osTicket uses callback method to fetch the content of a
file on mail fetch. $file['data'] was overloaded as a callback by simply
checking if the content is callable, resulting in method invocation when
content of the uploaded file is a callable.

The address the issue we're not using locally set callback parameter / method.
parent a9834d88
Branches
Tags
No related merge requests found
...@@ -388,12 +388,15 @@ class AttachmentFile extends VerySimpleModel { ...@@ -388,12 +388,15 @@ class AttachmentFile extends VerySimpleModel {
$file['data'] = base64_decode($file['data']); $file['data'] = base64_decode($file['data']);
} }
} }
if (isset($file['data'])) {
if (!isset($file['data']) && isset($file['dataclb'])
&& is_callable($file['dataclb'])) {
// Allow a callback function to delay or avoid reading or // Allow a callback function to delay or avoid reading or
// fetching ihe file contents // fetching ihe file contents
if (is_callable($file['data'])) $file['data'] = $file['dataclb']();
$file['data'] = $file['data'](); }
if (isset($file['data'])) {
list($key, $file['signature']) list($key, $file['signature'])
= self::_getKeyAndHash($file['data']); = self::_getKeyAndHash($file['data']);
if (!$file['key']) if (!$file['key'])
......
...@@ -831,7 +831,7 @@ class MailFetcher { ...@@ -831,7 +831,7 @@ class MailFetcher {
else { else {
// only fetch the body if necessary // only fetch the body if necessary
$self = $this; $self = $this;
$file['data'] = function() use ($self, $mid, $a) { $file['dataclb'] = function() use ($self, $mid, $a) {
return $self->decode(imap_fetchbody($self->mbox, return $self->decode(imap_fetchbody($self->mbox,
$mid, $a['index']), $a['encoding']); $mid, $a['index']), $a['encoding']);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment