T1098.004: SSH 授权密钥
摘要
攻击者可能修改 SSH <code>authorized_keys</code> 文件以在受害者主机上维持持久化。Linux 发行版、macOS 和 ESXi 虚拟机监控程序通常使用基于密钥的认证来保护 SSH 会话的认证过程,用于远程管理。SSH 中的 <code>authorized_keys</code> 文件指定了可用于登录该文件所配置用户账户的 SSH 密钥。此文件通常位于用户的主目录下 <code><user-home>/.ssh/authorized_keys</code>(或在 ESXi 上为 `/etc/ssh/keys-<username>/authorized_keys`)。(Citation: SSH Authorized Keys)用户可以编辑系统的 SSH 配置文件,将指令 `PubkeyAuthentication` 和 `RSAAuthentication` 修改为值 `yes`,以确保启用公钥和 RSA 认证,并将指令 `PermitRootLogin` 修改为值 `yes`,以启用通过 SSH 的 root 认证。(Citation: Broadcom ESXi SSH)SSH 配置文件通常位于 <code>/etc/ssh/sshd_config</code> 下。 攻击者可能使用脚本或 shell 命令直接修改 SSH <code>authorized_keys</code> 文件,以添加自己的、由攻击者提供的公钥。在云环境中,攻击者可能能够通过命令行界面或 REST API 修改特定虚拟机的 SSH authorized_keys 文件。例如,通过使用 Google Cloud CLI 的 "add-metadata" 命令,攻击者可以向用户账户添加 SSH 密钥。(Citation: Google Cloud Add Metadata)(Citation: Google Cloud Privilege Escalation)类似地,在 Azure 中,攻击者可以通过向 API 发送 PATCH 请求来更新虚拟机的 authorized_keys 文件。(Citation: Azure Update Virtual Machines)这确保拥有相应私钥的攻击者可以作为现有用户通过 SSH 登录。(Citation: Venafi SSH Key Abuse)(Citation: Cybereason Linux Exim Worm)当虚拟机或实例与发起请求的用户具有不同权限时,这也可能导致权限提升。 当 authorized_keys 文件通过云 API 或命令行界面被修改时,如果攻击者向具有更高权限的用户添加密钥,则可能在目标虚拟机上实现权限提升。 SSH 密钥也可以添加到网络设备上的账户,例如使用 `ip ssh pubkey-chain` [Network Device CLI](https://attack.mitre.org/techniques/T1059/008) 命令。(Citation: cisco_ip_ssh_pubkey_ch_cmd)
来源归属
来源:MITRE ATT&CK · 置信度:high
平台
- ESXi
- IaaS
- Linux
- macOS
- Network Devices
战术
持久化
参考来源
- https://attack.mitre.org/techniques/T1098/004
- https://www.venafi.com/blog/growing-abuse-ssh-keys-commodity-malware-campaigns-now-equipped-ssh-capabilities
- https://knowledge.broadcom.com/external/article/313767/allowing-ssh-access-to-vmware-vsphere-es.html
- https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/
- https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/security/d1/sec-d1-cr-book/sec-cr-i3.html#wp1254331478
- https://www.cybereason.com/blog/new-pervasive-worm-exploiting-linux-exim-server-vulnerability
- https://cloud.google.com/sdk/gcloud/reference/compute/instances/add-metadata
- https://docs.microsoft.com/en-us/rest/api/compute/virtual-machines/update
- https://www.ssh.com/ssh/authorized_keys/