Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RCE: Change serialize/unserialize to json encode/decode #12

Merged
merged 1 commit into from Sep 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Fix unserialize/serialize to json decode/encode
  • Loading branch information
stypr committed Sep 15, 2020
commit a75642989132dd25f74a13194b27c0986c3de020
22 changes: 11 additions & 11 deletions cms/app/webapp/inquiry/page.php
Expand Up @@ -128,7 +128,7 @@ function getForm($formId){

//不正な書き換えでない場合のみ
if(md5($value) == $_POST["form_hash"]){
$_POST["data"] = unserialize($value);
$_POST["data"] = json_decode($value, true);
}
}

Expand Down Expand Up @@ -275,8 +275,8 @@ function getForm($formId){
$captcha_url = $this->pageUrl . "?captcha=" . $captcha_filename;
}

$hidden_hash = md5(serialize($_POST["data"]));
$hidden_value = base64_encode(serialize($_POST["data"]));
$hidden_hash = md5(json_encode($_POST["data"]));
$hidden_value = base64_encode(json_encode($_POST["data"]));

$hidden_forms = '<input type="hidden" name="form_hash" value="' . $hidden_hash . '" />';
$hidden_forms.= '<input type="hidden" name="form_value" value="' . $hidden_value . '" />';
Expand Down Expand Up @@ -578,18 +578,18 @@ private function generateCaptchaImage($captcha_value, $captcha_filename){
class SOYInquiry_FormComponent extends HTMLLabel{

private $application;

function execute(){
parent::execute();
$html = $this->application->getForm($this->getAttribute("app:formid"));
$this->setHtml($html);
}
function getApplication() {
return $this->application;
}
function setApplication($application) {
$this->application = $application;
}
}
function getApplication() {
return $this->application;
}
function setApplication($application) {
$this->application = $application;
}
}

$app = new SOYInquiry_PageApplication();
Expand Down