The vulnerability is a command injection in gitoxide's submodule handling. An attacker can craft a malicious .gitmodules file with a command in the update field (e.g., update = !/path/to/malicious/script). When a user runs a submodule update operation, this command would be executed. The vulnerability lies in the insufficient validation of the origin of the update configuration.
The provided patch addresses this by introducing a new, more robust abstraction for handling .gitmodules files. The analysis of the patch identified two key functions:
-
gix_submodule::config::Update::try_from: This function is responsible for parsing the raw string value of the update field. It identifies values starting with ! as commands and wraps them in the Update::Command enum variant. This is the first step in processing the malicious input.
-
gix_submodule::File::update: This function retrieves the parsed Update value and, crucially, performs a security check. It verifies that if the value is a Update::Command, it must not originate from the .gitmodules file itself. It does this by checking if the configuration section comes from a 'foreign' source (like the user's local .git/config), which is considered a trusted override. If the command is in .gitmodules, it returns a CommandForbiddenInModulesConfiguration error, preventing the command from being executed.
By identifying these two functions, we can pinpoint the exact locations in the code that process the malicious input and where the security mitigation is applied. During an exploit attempt on a vulnerable version, a function similar in purpose to gix_submodule::File::update would be present in the stack trace, but it would lack the correct validation logic.