From 237131c6f02ce1bca8c5a41b25c274ff2c34e751 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 24 Apr 2026 11:29:18 +0200 Subject: Fix a possible null-pointer dereference in cookies encryption --- src/sp_crypt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/sp_crypt.c b/src/sp_crypt.c index 6d48554..9d4e6bb 100644 --- a/src/sp_crypt.c +++ b/src/sp_crypt.c @@ -42,6 +42,11 @@ int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { zend_string *debase64 = php_base64_decode((unsigned char *)(Z_STRVAL_P(pDest)), Z_STRLEN_P(pDest)); + if (!debase64) { + sp_log_drop( "cookie_encryption", "Unable to base64-decode the cookie"); + return ZEND_HASH_APPLY_REMOVE; + } + if (ZSTR_LEN(debase64) < crypto_secretbox_NONCEBYTES) { if (true == simulation) { sp_log_simulation( -- cgit v1.3