The vulnerability exists because the current_head field of the GitRepository model was writable through the REST API. This was due to the GitRepositorySerializer not marking the field as read-only. An attacker with permissions to add or change a GitRepository could send a crafted request to set current_head to a malicious value. This could lead to a denial of service if the value is a non-existent commit, or it could cause the repository to check out an older or different commit than intended, leading to a misleading state. The lack of validation in the GitRepository.clean method and the GitRepo.checkout method exacerbated this issue, as it allowed malformed or malicious values to be processed. The patch addresses these issues by making current_head read-only in the serializer and adding validation in the model and git utility functions.