|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-02-08 07:11 UTC] zhihua dot yao at dbappsecurity dot com dot cn
Description:
------------
I do not know where the problem is.
Test script:
---------------
<?php
ini_set('memory_limit',-1);
$str=str_repeat("A",0x7fffffff);
sodium_pad($str,0x7fffffff);
Actual result:
--------------
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x08253de4 in zif_sodium_pad (execute_data=0xb781a0a0,
return_value=0xbfffbbf0)
at /home/hjy/Desktop/php-7.2.2/ext/sodium/libsodium.c:3406
3406 ZSTR_VAL(padded)[j] = unpadded[i];
gdb-peda$ bt
#0 0x08253de4 in zif_sodium_pad (execute_data=0xb781a0a0,
return_value=0xbfffbbf0)
at /home/hjy/Desktop/php-7.2.2/ext/sodium/libsodium.c:3406
#1 0x083f7d04 in ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER ()
at /home/hjy/Desktop/php-7.2.2/Zend/zend_vm_execute.h:573
#2 execute_ex (ex=0x37400010)
at /home/hjy/Desktop/php-7.2.2/Zend/zend_vm_execute.h:59731
#3 0x084002b4 in zend_execute (op_array=op_array@entry=0xb787c000,
return_value=return_value@entry=0x0)
at /home/hjy/Desktop/php-7.2.2/Zend/zend_vm_execute.h:63760
#4 0x08363690 in zend_execute_scripts (type=type@entry=0x8,
retval=retval@entry=0x0, file_count=file_count@entry=0x3)
at /home/hjy/Desktop/php-7.2.2/Zend/zend.c:1496
#5 0x0830344e in php_execute_script (
primary_file=primary_file@entry=0xbfffdee4)
at /home/hjy/Desktop/php-7.2.2/main/main.c:2590
#6 0x084026db in do_cli (argc=argc@entry=0x2,
argv=argv@entry=0x8af8000)
at /home/hjy/Desktop/php-7.2.2/sapi/cli/php_cli.c:1011
#7 0x08071637 in main (argc=0x2, argv=0x8af8000)
at /home/hjy/Desktop/php-7.2.2/sapi/cli/php_cli.c:1404
#8 0xb7c08af3 in __libc_start_main (main=0x8071160 <main>, argc=0x2,
argv=0xbffff194, init=0x840a390 <__libc_csu_init>,
fini=0x840a400 <__libc_csu_fini>, rtld_fini=0xb7fed2d0 <_dl_fini>,
stack_end=0xbffff18c) at libc-start.c:287
#9 0x080716c2 in _start ()
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 02:00:01 2025 UTC |
I'd consider this a security issue. Which is trivial to trigger: ini_set('memory_limit',-1); $a = str_repeat('x', 2147483647); $b = $a . $a;This can be downplayed by pointing out the fact that `ini_set('memory_limit',-1);` is not a thing to allow on untrusted data/scripts. But altering the memory_limit value may not be required to trigger this overflow.