Critical Vulnerability in Git Package: Newline Character Exploit

git Updated 02 Oct 2025

Summary

31/08/2021
N/A
Yes i
High
7.5

ALPINE-CVE-2021-40330: git_connect_git in connect.c in Git before 2.30.1 allows a repository path to contain a newline character, which may result in unexpected cross-protocol requests, as demonstrated by the git://localhost:1234/%0d%0a%0d%0aG... Affects git versions < 2.26.3-r1. Fixed in 2.26.3-r1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Git is a widely used version control system that allows developers to track changes in source code during software development. It is known for its speed, data integrity, and support for distributed, non-linear workflows. However, a vulnerability has been identified in Git versions prior to 2.30.1, where a repository path can contain a newline character, leading to potential cross-protocol requests.

Vulnerability Detail

The vulnerability, identified as CVE-2021-40330, exists in the git_connect_git function within the connect.c file of Git. This flaw allows an attacker to craft a repository path containing newline characters, which can result in unexpected cross-protocol requests. For instance, a malicious user could exploit this by sending a request like 'git://localhost:1234/%0d%0a%0d%0aGET%20/%20HTTP/1.1', potentially leading to unauthorized access or data leakage. The CVSS score for this vulnerability is 7.5, indicating a high severity level.

How To Fix

Minimum fixed version

2.26.3-r1

This is the first release that contains the fix.

sudo apk add --upgrade git

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, ensure that repository paths do not contain newline characters. This can be done by sanitizing input and validating paths before processing them in Git commands.

Conclusion

The vulnerability CVE-2021-40330 in Git poses significant risks due to its ability to exploit newline characters in repository paths. It is crucial for users to update to the patched version to mitigate these risks. Additionally, utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.

See every vulnerability recorded for git →

Share this vulnerability

FAQ

CVE-2021-40330 is a vulnerability in Git that allows a repository path to contain newline characters, potentially leading to cross-protocol requests.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score for this vulnerability is 7.5, indicating a high level of severity.

If an immediate update is not possible, ensure that repository paths are sanitized to avoid newline characters as a temporary measure.

You can visit the official Git website or security advisories for detailed information on vulnerabilities and patches.

Related vulnerabilities

Recent vulnerabilities recorded for git.

How To Fix

Minimum fixed version

2.26.3-r1

This is the first release that contains the fix.

sudo apk add --upgrade git

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback