Created attachment 11798 [details] Screenshot of Proof of Concept I noticed a segmentation fault as a result of fuzzing the PHP glob functions. I have provided the string below. No flags to glob were specified. This was tested against the PHP glob function as well as the glob.h glob function in c. This was tested against 2.27 and 2.29. Please let me know if you have any additional questions. This may be a security issue. String input: //*/.*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////./.**
We need more details. The input string alone, with the GLOB_ONLYDIR | GLOB_MARK | GLOB_NOSORT flags argument (as shown in the screenshot—the 8198 argument) does not reproduce this. Thanks.
I'm able to reproduce this in Ubuntu 19.04, glibc 2.29, inside a Docker container, using these steps: docker run --rm -it --privileged ubuntu:19.04 Inside the container: apt update && apt install -y gcc gdb cat >glob.c <<<' #include <glob.h> #include <stddef.h> int main() { glob_t g; glob("//*/.*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////./.**", 8198, NULL, &g); return 0; } ' gcc -o glob glob.c gdb -ex run glob Output is similar to screenshot Nicholas Starke posted: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7ec0984 in __glob (pattern=pattern@entry=0x7fffff7ff300 "//*/.*", '/' <repeats 194 times>..., flags=flags@entry=8198, errfunc=errfunc@entry=0x0, pglob=pglob@entry=0x7fffffffcfd0) at ../posix/glob.c:289
That is most likely a stack overflow.
The tests passed with 'ulimit -s unlimited'. The pattern leads to recursive calls to __glob at glob.c:584.
Right. I suspect it's also related to file system contents whether it's triggered or not.
Thank you to Jonathan Cottrill for the in-depth reproduction steps. This is nearly exactly how I triaged the initial crash. I apologize for not attaching the full proof of concept test harness for reproducing this. That's my mistake. What sort of information do you need at this point? How can I help in your assessment?
(In reply to Nicholas Starke from comment #6) > Thank you to Jonathan Cottrill for the in-depth reproduction steps. This is > nearly exactly how I triaged the initial crash. > > I apologize for not attaching the full proof of concept test harness for > reproducing this. That's my mistake. > > What sort of information do you need at this point? How can I help in your > assessment? My understanding is it works as intended. The pattern triggers a recursive call on glob implementation, where when glob sees 'pattern/' it expands 'pattern' by calling. The valgring massif tool shows a peak usage of 9,606,960 bytes for this testcase and usually, distro sets the default limit of stack to around 8MB. To lower the glob stack usage it would require a complete refactor to save/restore the state in a heap-allocated variable and remove the recursion.
I apologize if this was a total waste of time.
(In reply to Nicholas Starke from comment #8) > I apologize if this was a total waste of time. No worries, if it is ok to you I will close this bug report as not a bug.
Thank you, I am fine with closing this as not a bug.
As per previous comments.