The vulnerability is a classic directory traversal, caused by improper input sanitization. The ajax/networking/get_wgkey.php script takes user input via the entity POST parameter and uses it in a shell command. The initial implementation used escapeshellcmd(), which is not the correct function to use when sanitizing a single argument for a shell command. This allowed an attacker to inject ../ sequences and write to arbitrary files. The fix, which replaces escapeshellcmd() with escapeshellarg(), correctly treats the entire input as a single, safe argument, thus mitigating the vulnerability. The vulnerable code is not within a specific function but in the main body of the PHP script, which gets executed when the corresponding URL is accessed.