I am currently working on getting better code reviews considering I am doing whitebox testing on a regular basis now. This will mostly be a dump of my notes as I research new things and will grow over time.
PHP
in_array
This PHP function is vulnerable to type juggling considering it may use loose comparisons if the function is used incorrectly.
Vulnerable code:
$values = array("naruto","sasuke","rock lee","gaara");
var_dump(in_array(0, $values));
Output:
bool(true)
This is obviously not the case considering 0 is not in the array, so a third parameter should be added to the function so that is uses strict comparisons.
Secure code:
$values = array("naruto","sasuke","rock lee","gaara");
var_dump(in_array(0, $values, true));
Output:
bool(false)
Java
MessageDigest hasher = MessageDigest.getInstance("SHA-256");
Whenever SHA-256
is used by itself without an HMAC
, it is vulnerable to a length extension vulnerability. If you know one hash, you can create new hashes without knowing the secret by adding data to the digest.