2025-02-11 16:40:50 +05:30
id : disable-ssh-forwarding
info :
name : Disable SSH Forwarding
author : pussycat0x
severity : unknown
description : |
SSH forwarding can enhance security by encrypting traffic (X11, agent, or port forwarding), but it also poses risks if misused. Attackers with access to a compromised system can pivot to other machines, potentially escalating privileges or stealing credentials.
remediation : |
Set X11Forwarding no and AllowTcpForwarding no in /etc/ssh/sshd_config to disable SSH forwarding and restart the SSH service.
reference :
- https://vishalraj82.medium.com/hardening-openssh-security-37f5d634015f
metadata :
verified : true
tags : audit,config,ssh,auth
javascript :
2025-02-17 21:22:51 +05:30
- pre-condition : |
isPortOpen(Host,Port)
code : |
2025-02-11 16:40:50 +05:30
var m = require("nuclei/ssh");
var c = m.SSHClient();
2025-02-17 21:22:51 +05:30
c.Connect(Host,Port,User,Pass);
2025-02-11 16:40:50 +05:30
const sshConfig = c.Run('cat /etc/ssh/sshd_config')
sshConfig
let result = "";
if (sshConfig.includes('AllowTcpForwarding yes') && !sshConfig.includes('#AllowTcpForwarding yes') || sshConfig.includes('X11Forwarding yes')) {
2025-02-24 11:54:19 +05:30
result += "Disable SSH Forwarding;";
}
else {
exit();
2025-02-11 16:40:50 +05:30
}
result
args :
Host : "{{Host}}"
Port : "22"
2025-02-24 12:07:12 +05:30
User : "{{usernames}}"
Pass : "{{passwords}}"
2025-02-24 11:54:19 +05:30
2025-02-11 16:40:50 +05:30
matchers :
- type : dsl
dsl :
- "success == true"
2025-02-24 11:54:19 +05:30
2025-02-11 16:40:50 +05:30
extractors :
- type : dsl
dsl :
2025-02-24 06:41:49 +00:00
- response
# digest: 4a0a00473045022100dc6908d6ef4bdff577247d002afeba2f2a2f0f4c6e8363603e4c60c46e452926022017929a72f04ee161a3700626a49ae427a6cdaaf14383292d3dd6c972d7dcb70f:922c64590222798bb761d5b6d8e72950