27 lines
446 B
Plaintext
27 lines
446 B
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
$data = $_GET["data"];
|
|
$object = unserialize($data);
|
|
// ...
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
$data = $_GET["data"];
|
|
|
|
list($hash, $data) = explode('|', $data, 2);
|
|
$hash_confirm = hash_hmac("sha256", $data, "secret-key");
|
|
|
|
// Confirm that the data integrity is not compromised
|
|
if ($hash === $hash_confirm) {
|
|
$object = unserialize($data);
|
|
// ...
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|