The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2021-40330

CVE-2021-40330: Git-scm Git SSRF Vulnerability

CVE-2021-40330 is an SSRF flaw in Git-scm Git that allows newline injection in repository paths, enabling cross-protocol requests. This post covers technical details, affected versions, impact, and mitigation.

Published: February 25, 2026

CVE-2021-40330 Overview

CVE-2021-40330 is a cross-protocol request vulnerability in the git_connect_git function within connect.c in Git versions prior to 2.30.1. The vulnerability allows attackers to inject newline characters into repository paths, potentially enabling unexpected cross-protocol requests. This input validation flaw can be exploited through specially crafted git:// URLs containing URL-encoded newline sequences.

Critical Impact

Attackers can craft malicious git:// URLs that inject arbitrary protocol commands, potentially enabling cross-protocol attacks such as HTTP request injection through the git:// protocol handler.

Affected Products

  • Git-scm Git versions before 2.30.1
  • Debian Linux 10.0

Discovery Timeline

  • 2021-08-31 - CVE CVE-2021-40330 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-40330

Vulnerability Analysis

The vulnerability resides in the git_connect_git() function in connect.c, which failed to validate repository paths for newline characters. When processing git:// URLs, the function would accept paths containing URL-encoded newline sequences (%0d%0a), allowing attackers to inject arbitrary data into the protocol stream.

The attack leverages the git:// protocol's text-based nature. By embedding newline characters followed by HTTP request syntax, an attacker could cause a Git client to send unintended HTTP requests to a target server. For example, a malicious URL like git://localhost:1234/%0d%0a%0d%0aGET%20/%20HTTP/1.1 would result in the Git client sending what appears to be an HTTP GET request after the git protocol preamble.

This type of cross-protocol attack can be particularly dangerous in environments where Git clients operate behind firewalls or in trusted network segments, as it could potentially be used to interact with internal services that would otherwise be inaccessible.

Root Cause

The root cause is improper input validation in the git_connect_git() function. The function did not sanitize or reject newline characters (\n and \r) in the host and repository path parameters before using them in protocol communications. This oversight allowed protocol injection attacks through specially crafted URLs.

Attack Vector

The attack is network-based and requires no authentication or user interaction. An attacker can exploit this vulnerability by:

  1. Crafting a malicious git:// URL containing URL-encoded newline characters
  2. Tricking a user or automated system into cloning or fetching from the malicious URL
  3. The newline injection causes the Git client to send additional protocol commands beyond the intended git protocol request

The patch introduced validation to explicitly reject newline characters in both the target host and repository path:

c
 		target_host = xstrdup(hostandport);
 
 	transport_check_allowed("git");
+	if (strchr(target_host, '\n') || strchr(path, '\n'))
+		die(_("newline is forbidden in git:// hosts and repo paths"));
 
 	/*
 	 * These underlying connection commands die() if they

Source: GitHub Commit Changes

The corresponding test case validates that the client properly refuses malicious URLs:

bash
 	)
 '
 
+test_expect_success 'client refuses to ask for repo with newline' '
+	test_must_fail git clone "$GIT_DAEMON_URL/repo$LF.git" dst 2>stderr &&
+	test_i18ngrep newline.is.forbidden stderr
+'
+
 test_remote_error()
 {
 	do_export=YesPlease

Source: GitHub Commit Changes

Detection Methods for CVE-2021-40330

Indicators of Compromise

  • Git client logs showing connection attempts to unexpected URLs or protocols
  • Network traffic containing git:// URLs with URL-encoded newline sequences (%0d%0a)
  • Unusual HTTP requests originating from Git client processes

Detection Strategies

  • Monitor network traffic for git:// URLs containing encoded newline characters (%0d, %0a, %0d%0a)
  • Implement URL filtering rules to detect and block malicious git:// protocol requests with injection patterns
  • Audit Git client version deployments to identify unpatched installations below version 2.30.1

Monitoring Recommendations

  • Enable verbose logging for Git operations in CI/CD pipelines and developer workstations
  • Configure network intrusion detection systems (IDS) to alert on cross-protocol request patterns
  • Monitor for error messages containing "newline is forbidden" which indicate attempted exploitation against patched systems

How to Mitigate CVE-2021-40330

Immediate Actions Required

  • Upgrade Git to version 2.30.1 or later immediately
  • Audit all Git installations across development environments, CI/CD systems, and servers
  • Review logs for any suspicious git:// URL patterns that may indicate attempted exploitation

Patch Information

The vulnerability was fixed in Git version 2.30.1. The patch adds explicit validation in the git_connect_git() function to reject any repository URLs containing newline characters. The fix is straightforward and introduces a check using strchr() to detect newline characters in both the target host and path parameters, terminating with an error message if detected.

Review the complete patch details at the GitHub Commit Changes or compare versions using the GitHub Version Comparison. Debian users should refer to the Debian LTS Security Announcement.

Workarounds

  • Avoid using git:// protocol URLs from untrusted sources until patching is complete
  • Configure firewalls to restrict outbound connections from Git clients to known-good Git servers only
  • Use HTTPS (https://) or SSH (git@) protocols instead of git:// where possible, as they have different parsing behavior
bash
# Check Git version to verify patch status
git --version

# Update Git on Debian/Ubuntu systems
sudo apt-get update && sudo apt-get upgrade git

# Update Git on RHEL/CentOS systems
sudo yum update git

# Update Git on macOS via Homebrew
brew upgrade git

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeSSRF

  • Vendor/TechGit

  • SeverityHIGH

  • CVSS Score7.5

  • EPSS Probability0.45%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • CWE References
  • NVD-CWE-noinfo
  • Technical References
  • Debian LTS Security Announcement
  • Vendor Resources
  • GitHub Commit Changes

  • GitHub Version Comparison
  • Related CVEs
  • CVE-2026-4496: Git-MCP-Server RCE Vulnerability

  • CVE-2025-66413: Git for Windows NTLM Hash Disclosure Flaw

  • CVE-2024-32004: Git-scm Git RCE Vulnerability

  • CVE-2024-32020: Git Privilege Escalation Vulnerability
Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English