Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get Yii2 cookie validation key if value is known

Tags:

php

cookies

yii2

In my Yii2 application I am using cookies to store a user referral code. The user knows what their referral code is and I was wondering if it is possible to derive the cookie validation key that is used to hash the string. Also, what would be the potential concerns if the cookie validation key was known?

Here is the link to the Yii2 guide portion on cookies if it helps give more context: http://www.yiiframework.com/doc-2.0/guide-runtime-sessions-cookies.html#cookies

like image 205
Michael St Clair Avatar asked Dec 01 '25 09:12

Michael St Clair


1 Answers

By default Yii2 uses SHA-256 to hash those strings. It's pretty mush irreversible. So this is not a security leak.

If somebody had your cookie validation key, they could forge a cookie. That is the real threat, so keep your cookie validation key safe.

like image 84
Beowulfenator Avatar answered Dec 04 '25 01:12

Beowulfenator



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!