Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
google-osconfig-privesc — 关于 Google Osconfig 中发现的权限提升漏洞的概念验证 | Kitploit
工具/GitHubGitHub/irsl/google-osconfig-privesc
权限提升漏洞分析漏洞利用后渗透利用渗透测试云安全红队
GitHubirsl/google-osconfig-privesc

google-osconfig-privesc

关于 Google Osconfig 中发现的权限提升漏洞的概念验证

查看仓库
105年前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

Summary

google_osconfig_agent 进程是 GoogleCloudPlatform (https://github.com/GoogleCloudPlatform/osconfig) 工具的一个组件, 默认运行在每个 VM 上。该代理以 root 身份运行,并负责一些用户可控制的服务, 包括 OS config (https://cloud.google.com/compute/docs/os-config-management),这有点像 Google 的基于轮询的期望状态 配置实现。

本仓库托管了一个关于我在该实现中发现的一个权限提升缺陷的演示(该缺陷后来已被 Google 修复)。

Issue

要执行的任务称为 recipe,其中支持的 recipe 类型之一是执行 shell 脚本。 在处理此类 recipe 时,以 root 身份运行并拥有全部能力的代理会临时将文件保存到 /tmp 目录,然后执行它们。 该代理创建的目录可能被劫持,从而替换要执行的脚本, 最终导致本地权限提升。

Steps to reproduce

  1. 准备环境:
root@kitploit:~
        gcloud services enable osconfig.googleapis.com 
        gcloud compute project-info add-metadata --metadata=enable-osconfig=TRUE    
  1. 在 VM 上,以低权限用户(nobody)运行漏洞利用脚本
root@kitploit:~
        # cat /tmp/poc.txt
        cat: /tmp/poc.txt: No such file or directory

        # pip3 install inotify_simple
        # chroot --userspec=nobody:nogroup / /home/radimre83/osconfig-privesc-poc3.py
        Running as 65534
        calling inotify.read()
        ...
  1. 配置 os-config 策略:
root@kitploit:~
        gcloud beta compute os-config guest-policies create test-policy-poc --file="C:\Projects\gcp-app-engine-experiments\compute-engine\osconfig-policy-poc.yaml"
  1. 部署 runscript 时 poc 脚本的输出(可能需要 10-15 分钟):
root@kitploit:~
        Event(wd=1, mask=1073742080, cookie=0, name='recipe-runscript')
        New recipe: recipe-runscript2, rename: /tmp/osconfig_software_recipes.mali1596821311/xxx-recipe-name -> /tmp/osconfig_software_recipes.mali1596821311/recipe-runscript
        New rundir recipe-runscript2, rename: /tmp/osconfig_software_recipes.mali1596821311/recipe-runscript/xxx-rundir -> /tmp/osconfig_software_recipes.mali1596821311/recipe-runscript/run_1596821899000709826
  1. 验证:
root@kitploit:~
        # cat /tmp/poc.txt
        uid=0(root) gid=0(root) groups=0(root),1000(google-sudoers)

OS: 使用默认 Debian 10 镜像的 GCE f1-micro 实例。

The fix

Google 改为使用随机临时目录,而不是可预测的目录。

Remediation

修复版本已于 2020-09-05 发布。你需要升级操作系统软件包。

Attack scenario

这是一个本地权限提升漏洞,因此可能被已经拥有受影响 GCE VM 上代码执行 权限的人利用:

  • 拥有低权限 shell 的人

  • 通过已被入侵的网络服务进行攻击的攻击者

关键点在于接管“基本目录”(/tmp/osconfig_software_recipes)。如果当前会话中尚未处理任何 recipe,则可能实现这一点,这意味着:

  • 到目前为止根本没有执行过任何 recipe(例如,osconfig 功能尚未使用,但在之后某个时间点会使用)

  • VM 已重启,所有 recipe 都存在于数据库(/var/lib/google/osconfig_recipedb)中,但在之后某个时间点会执行一些策略更新

虽然这种特殊组合确实降低了被利用的可能性, 但我认为在此处利用 /tmp 中的工作目录并不安全。(Google 也不这么认为,此问题已经修复。)

Timeline

2020-08-07:发现问题并报告

2020-08-08:Google 对问题进行分类,优先级改为 P1

2020-08-10:Google 确认了问题(“🎉 Nice catch!”),优先级改为 P2,严重级别改为 S2

2020-08-14:关于 VRP 流程的更新

2020-09-05:Google 修复问题

Credits

Imre Rad

Links

https://github.com/GoogleCloudPlatform/osconfig

https://issuetracker.google.com/issues/163147689

https://github.com/GoogleCloudPlatform/osconfig/commit/fa7e4ba5ee85be212ffbac66d96862c792bd270c

https://www.linkedin.com/in/imre-rad-2358749b/

下载工具