SSH Unrestricted Access from Non-Whitelisted IPs

漏洞信息

漏洞名称: SSH Unrestricted Access from Non-Whitelisted IPs

漏洞类型: 未授权访问

漏洞等级: 中危

漏洞描述: 受影响的产品是SSH(Secure Shell),一种广泛使用的网络协议,用于安全地访问远程计算机。SSH在企业和个人环境中都非常常见,用于远程服务器管理、文件传输等。该漏洞的具体表现为SSH服务未限制访问IP,允许任何来源的IP地址连接,这大大增加了未授权访问和暴力破解攻击的风险。漏洞的技术根源在于SSH服务的配置文件中未正确设置ListenAddress参数,或者该参数被注释掉,导致服务监听所有网络接口上的连接请求。这种配置问题使得攻击者可以从任何IP地址尝试连接SSH服务,进行未授权访问或暴力破解攻击,从而可能获取系统权限,导致数据泄露或服务中断。由于SSH服务通常运行在高权限账户下,一旦被攻破,攻击者可以完全控制系统,造成严重的安全后果。修复建议包括在/etc/ssh/sshd_config配置文件中设置ListenAddress参数,仅允许来自信任IP地址的连接,并重启SSH服务以应用更改。

产品名称: SSH

来源: https://github.com/projectdiscovery/nuclei-templates/blob/804d1df949d5fbbfdee11564a2df65b6836a8d60/javascript%2Faudit%2Fssh%2Fssh-unrestricted-nonwhitelist.yaml

类型: projectdiscovery/nuclei-templates:github issues

POC详情

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

id: ssh-unrestricted-nonwhitelist

info:
name: Unrestricted SSH Access from Non-Whitelisted IPs
author: pussycat0x
severity: unknown
description: |
SSH access is not restricted to specific IP addresses, allowing connections from any source. This increases the risk of unauthorized access and brute-force attacks.
remediation: |
Restrict SSH to specific IPs in /etc/ssh/sshd_config by setting ListenAddress <trusted-IP> and restarting the SSH service.
reference:
- https://vishalraj82.medium.com/hardening-openssh-security-37f5d634015f
- https://www.cyberciti.biz/tips/howto-openssh-sshd-listen-multiple-ip-address.html
metadata:
verified: true
tags: audit,config,ssh,auth

javascript:
- pre-condition: |
isPortOpen(Host,Port);
code: |
var m = require("nuclei/ssh");
var c = m.SSHClient();
c.Connect(Host,Port,User,Pass);
const sshConfig = c.Run('cat /etc/ssh/sshd_config')
sshConfig
let result = "";
if (sshConfig.includes('#ListenAddress') && !sshConfig.includes('ListenAddress ')){
result += "SSH access restriction not enforced";
}
else{
exit();
}
result

args:
Host: "{{Host}}"
Port: "22"
User: "{{usernames}}"
Pass: "{{passwords}}"

matchers:
- type: dsl
dsl:
- "success == true"

extractors:
- type: dsl
dsl:
- response
# digest: 4b0a00483046022100e083bd557c319077edc862d63ff616e5f3b16c97993aa815fc99275c3d0b8681022100b655fa349c18a03be6a56866c42c56cdc6829c22ebf02f09b2d625e2b7119452:922c64590222798bb761d5b6d8e72950


SSH Unrestricted Access from Non-Whitelisted IPs
http://example.com/2025/07/27/github_3821627101/
作者
lianccc
发布于
2025年7月27日
许可协议