Skip to content

Commit 05bb9f4

Browse files
committed
Fix h1 report 175626
Deserialization of Untrusted Data --------------------------------- HackerOne user Nicolas Grégoire - Agarri has reported that Revive Adserver was unserializing untrusted data submitted via cookies in the delivery scripts. An attacker could use such vector to either perform generic RCE attacks (e.g. when a vulnerable PHP version is being used) or, potentially, application-specific attacks. CWE-ID: CWE-502 CVSSv3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C CVSSv3 Base Score: 9.8 CVSSv3 Temporal Score: 8.5
1 parent 83a12b2 commit 05bb9f4

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

Diff for: lib/max/Delivery/querystring.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ function MAX_querystringConvertParams()
7171
$n = isset($aGet[$conf['var']['n']]) ? $aGet[$conf['var']['n']] : '';
7272
}
7373
if (!empty($n) && !empty($_COOKIE[$conf['var']['vars']][$n])) {
74-
$aVars = unserialize(stripslashes($_COOKIE[$conf['var']['vars']][$n]));
75-
foreach ($aVars as $name => $value) {
76-
if (!isset($_GET[$name])) {
77-
$aGet[$name] = $value;
74+
$aVars = json_decode($_COOKIE[$conf['var']['vars']][$n], true);
75+
if (is_array($aVars)) {
76+
foreach ($aVars as $name => $value) {
77+
if (!isset($_GET[$name])) {
78+
$aGet[$name] = $value;
79+
}
7880
}
7981
}
8082
}

Diff for: www/delivery_dev/afr.php

+17-13
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,24 @@
3232
$banner = MAX_adSelect($what, $campaignid, $target, $source, $withtext, $charset, $context, true, $ct0, $loc, $referer);
3333

3434
// Send cookie if needed
35-
if (!empty($banner['html']) && !empty($n)) {
36-
// Send bannerid headers
37-
$cookie = array();
38-
$cookie[$conf['var']['adId']] = $banner['bannerid'];
39-
// Send zoneid headers
40-
if ($zoneid != 0) {
41-
$cookie[$conf['var']['zoneId']] = $zoneid;
35+
if (!empty($n)) {
36+
if (!empty($banner['html'])) {
37+
// Send bannerid headers
38+
$cookie = array();
39+
$cookie[$conf['var']['adId']] = $banner['bannerid'];
40+
// Send zoneid headers
41+
if ($zoneid != 0) {
42+
$cookie[$conf['var']['zoneId']] = $zoneid;
43+
}
44+
// Send source headers
45+
if (!empty($source)) {
46+
$cookie[$conf['var']['channel']] = $source;
47+
}
48+
// Set the cookie
49+
MAX_cookieAdd($conf['var']['vars'] . "[$n]", json_encode($cookie, JSON_UNESCAPED_SLASHES));
50+
} else {
51+
MAX_cookieUnset($conf['var']['vars'] . "[$n]");
4252
}
43-
// Send source headers
44-
if (!empty($source)) {
45-
$cookie[$conf['var']['channel']] = $source;
46-
}
47-
// Set the cookie
48-
MAX_cookieAdd($conf['var']['vars'] . "[$n]", serialize($cookie));
4953
}
5054

5155
MAX_cookieFlush();

Diff for: www/delivery_dev/avw.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
MAX_Delivery_log_logAdImpression($row['bannerid'], $zoneid);
8585
}
8686
// Redirect to the banner
87-
MAX_cookieAdd($conf['var']['vars'] . "[$n]", serialize($cookie));
87+
MAX_cookieAdd($conf['var']['vars'] . "[$n]", json_encode($cookie, JSON_UNESCAPED_SLASHES));
8888
MAX_cookieFlush();
8989
if ($row['bannerid'] == '') {
9090
if ($row['default_banner_image_url'] != '') {
@@ -98,7 +98,7 @@
9898
MAX_redirect($creativeURL);
9999
}
100100
} else {
101-
MAX_cookieAdd($conf['var']['vars'] . "[$n]", 'DEFAULT');
101+
MAX_cookieUnset($conf['var']['vars'] . "[$n]");
102102
MAX_cookieFlush();
103103
// Show 1x1 Gif, to ensure not broken image icon is shown.
104104
MAX_commonDisplay1x1();

0 commit comments

Comments
 (0)