HTTP Public Key Pinning (HPKP) was a security feature that used to tell a web client to associate a specific cryptographic public key with a certain web server to decrease the risk of MITM attacks with forged certificates. To prevent CA compromise this feature is introduced.

UNDERSTANDING HPKP

HEADER :

Public-Key-Pins: pin-sha256=[pin 1]; pin-sha256=[pin 2]; max-age=2592000; report-uri=[uri]; includeSubdomains

Untitled

NOTE : Internet explorer doesnot have HPKP feature on it . To show it in demo a rogue certificate has been uploaded on a site and it is simultaneously opened in IE as well as in chrome. The chrome flags it insecure but IE allows the site wihout any warning. This is the amount of risk we will face on the absence of HPKP because Man-in-the-middle attack can now occur on the rogue certificate issued site and all the user communication will be decrypted & obtained by the attacker. Check the below screenshot for your reference ( LEFT : IE Browser and RIGHT : Chrome Browser ).

Untitled

Untitled

THE PIN-SHA256 KEYWORD

The HPKP hashes are mostly generated using certificate file and the CSR file.So to check whether the HPKP hashes are not modified , you need to run the below commands and compare the output hashes with the HPKP header hashes in browser developer mode as shown below. If the hashes are same then there is not forgery with the certificate but if it is different then you are in big trouble and your site must have already compromised.