The vulnerability is a Time-of-check Time-of-use (TOCTOU) race condition in the Spring Cloud Config Server's Git backend. The JGitEnvironmentRepository class, responsible for managing Git repositories, performed file system operations on a configurable base directory (spring.cloud.config.server.git.basedir) in an insecure manner. The analysis of the patch that fixes this vulnerability reveals that several methods were involved in the vulnerable workflow.
The core of the issue lies in the sequence of operations: checking for the existence of the base directory, deleting its contents, creating it, and then cloning a Git repository into it. An attacker with local access to the server could exploit the time window between these operations to replace the base directory with a symbolic link pointing to a different location on the file system. This could lead to either arbitrary file deletion (if the symlink is placed before the deletion step) or arbitrary file creation/overwrite (if the symlink is placed before the cloning step).
The patch addresses this by introducing more robust file system handling. It avoids following symbolic links when deleting files, and it uses atomic or near-atomic operations to create the base directory, significantly reducing the window for a TOCTOU attack. The identified vulnerable functions are the ones from the pre-patch code that were responsible for these insecure file system operations.