File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1025,12 +1025,23 @@ protected function parseSignedRequest($signed_request) {
10251025 // check sig
10261026 $ expected_sig = hash_hmac ('sha256 ' , $ payload ,
10271027 $ this ->getAppSecret (), $ raw = true );
1028- if ($ sig !== $ expected_sig ) {
1028+
1029+ if (strlen ($ expected_sig ) !== strlen ($ sig )) {
10291030 self ::errorLog ('Bad Signed JSON signature! ' );
10301031 return null ;
10311032 }
10321033
1033- return $ data ;
1034+ $ result = 0 ;
1035+ for ($ i = 0 ; $ i < strlen ($ expected_sig ); $ i ++) {
1036+ $ result |= ord ($ expected_sig [$ i ]) ^ ord ($ sig [$ i ]);
1037+ }
1038+
1039+ if ($ result == 0 ) {
1040+ return $ data ;
1041+ } else {
1042+ self ::errorLog ('Bad Signed JSON signature! ' );
1043+ return null ;
1044+ }
10341045 }
10351046
10361047 /**
You can’t perform that action at this time.
0 commit comments