Skip to content

Commit

Permalink
Merge pull request #33 from cryptochangements34/master
Browse files Browse the repository at this point in the history
Sanatize $payment_id cookie
  • Loading branch information
serhack authored Nov 24, 2017
2 parents c29d63f + 79dca7f commit 0768921
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions monero/include/monero_payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

/*
* Main Gateway of Monero using a daemon online
* This code isn't for Dark Net Markets, please report them to Authority!
* Authors: Serhack and cryptochangements34
* Authors: Serhack and cryptochangements
*/


Expand Down Expand Up @@ -315,17 +314,19 @@ private function set_paymentid_cookie()
if (!isset($_COOKIE['payment_id'])) {
$payment_id = bin2hex(openssl_random_pseudo_bytes(8));
setcookie('payment_id', $payment_id, time() + 2700);
} else{
// Please fix this SQLI injection! TODO: Fix me!
$payment_id = $this->protect_payment(sanitize_text_field($_COOKIE['payment_id']));
}
}
else{
$payment_id = $this->sanatize_id($_COOKIE['payment_id']);
}
return $payment_id;
}

public function protect_payment($payment_id){
$payment_id = str_replace("'", "\n", $payment_id);
return $payment_id;
}
public function sanatize_id($payment_id)
{
// Limit payment id to alphanumeric characters
$sanatized_id = preg_replace("/[^a-zA-Z0-9]+/", "", $payment_id);
return $sanatized_id;
}

public function changeto($amount, $currency, $payment_id)
{
Expand Down

0 comments on commit 0768921

Please sign in to comment.