The vulnerability lies in how the thor library handles file merging when a file collision occurs. The Thor::Shell::Basic.merge function was responsible for invoking an external merge tool to resolve conflicts. The analysis of the patch 536b79036a0efb765c1899233412e7b1ca94abfa clearly shows the vulnerability and its fix.
The vulnerable code used Ruby's string interpolation to build a command string for the system call: system %(#{merge_tool} \"#{temp.path}\" \"#{destination}\"). The destination argument, which is a filename, could be controlled by a user of the thor library. If a filename containing shell metacharacters was passed, it would be executed by the shell, leading to a command injection vulnerability.
The fix replaces the single-argument system call with a multi-argument call: system(merge_tool, temp.path, destination). When system is called with multiple arguments, the arguments are passed directly to the new process and are not interpreted by the shell, thus mitigating the command injection vulnerability.
The vulnerable function Thor::Shell::Basic.merge would appear in a runtime profile if an application using thor triggered a file collision that required a merge, and a malicious filename was provided as the destination.