The vulnerability lies in the ImageMagickHandler class of CodeIgniter4, specifically within the _resize and _text methods. These methods are responsible for processing images using the ImageMagick command-line tool. The core of the vulnerability is the improper construction of shell commands, where user-controlled input (filenames in _resize, and text or options in _text) was directly concatenated into the command string without sufficient sanitization. This allowed for OS command injection.
The analysis of the patch e18120bff1da691e1d15ffc1bf553ae7411762c0 clearly shows the remediation. In both _resize and _text methods, the patch replaces direct string concatenation with the escapeshellarg() function. This function is a standard security measure in PHP to ensure that a string is passed as a single, safe argument to a shell command, effectively neutralizing any malicious shell metacharacters.
Therefore, any application using the ImageMagick handler in CodeIgniter4 before version 4.6.2 is vulnerable. When a user uploads a file with a crafted filename and the resize() method is called, or when the text() method is used with malicious input, the _resize or _text functions would be present in the runtime profile, executing the injected command.