# Outray CLI 隧道创建竞态漏洞
## 概述
Outray 是一个开源的 ngrok 替代工具。在版本 0.1.5 之前,存在一个 TOCTOU(检查-执行时间)竞争条件漏洞,可被利用以绕过订阅计划中对活跃隧道数量的限制。
## 影响版本
版本 0.1.5 之前的版本(即 < 0.1.5)
## 细节
该漏洞属于 TOCTOU 类型,攻击者可在检查允许的隧道数量与实际创建隧道之间的时间窗口内,通过竞争条件多次请求创建隧道,从而突破订阅计划设定的并发隧道数限制。
## 影响
未经许可提升服务使用权限,导致用户可创建超出其订阅计划允许数量的活跃隧道,可能导致资源滥用和服务不公平使用。
是否为 Web 类漏洞: 未知
判断理由:
| # | POC 描述 | 源链接 | 神龙链接 |
|---|
标题: Outray cli is vulnerable to race conditions in tunnels creation · Advisory · outray-tunnel/outray · GitHub -- 🔗来源链接
标签:x_refsource_CONFIRM
神龙速读:
- **Vulnerability Details**
- **CVE ID**: CVE-2026-22820
- **Severity**: Moderate
- **Affected Package**: Outray (npm)
- **Affected Versions**: 0.1.3
- **Patched Versions**: None
- **Weakness**: CWE-367 (Time-of-check to time-of-use (TOCTOU) race condition)
- **Summary**:
A TOCTOU race condition vulnerability in the `/tunnel/register` endpoint allows a user to exceed the set number of active tunnels in their subscription plan.
- **Description**:
- The `/tunnel/register` endpoint code does not properly handle race conditions.
- The code checks if the tunnel exists in the database and verifies if the limit is exceeded.
- If limits are exceeded, a tunnel limit error is returned.
- However, if the limit is not exceeded, a new tunnel is registered without locking transactions from other requests.
- Parallel requests by the `wshandler` can lead to a race condition, allowing a user to bypass the limit.
- **Proof of Concept (PoC)**:
A bash script is provided that uses `tmux` to run the `outray` binary in the same tmux window, opening 4 tunnels.
- **Impact**:
Exploiting the TOCTOU race condition bypasses the intended limit, consuming server resources without additional billing charges.
- **Credits**:
- **Reporter**: gr33pp
- **Analyst**: SENSEiXENUS
标题: fix(tunnel): add transaction locking to prevent race conditions durin… · outray-tunnel/outray@08c6149 · GitHub -- 🔗来源链接
标签:x_refsource_MISC
神龙速读:
从这个网页截图中可以获取到以下关于漏洞的关键信息:
### 漏洞类型
- **竞态条件(Race Condition)**
- 代码在注册隧道时未使用事务锁定,可能会导致并发请求导致的问题。
### 修复措施
1. **引入事务锁定**
- 通过引入 `drizzle-orm` 的 `sql` 模块来支持事务。
- 使用事务中的 `row-level locking` 来防止并发请求引发的竞态条件。
2. **修改数据库查询**
- 在数据库查询中使用 `row-level locking` 来确保同一事务内的操作一致性。
- 添加 `.for("update")` 到查询中,以保证并发请求不会导致重复注册。
3. **验证隧道限制**
- 移动隧道限制验证,将其放入事务内,确保检查和更新操作在整个事务中保持一致。
4. **错误处理**
- 重构错误处理逻辑,将错误对象放在事务提交后返回,而不是直接在 JSON 响应中返回。
- 防止并发注册的竞态条件,避免多个并发注册可能超出隧道限制。
### 相关文件与更改
- **文件**:`apps/web/src/routes/api/tunnel/register.ts`
- **更改内容**:
- 增加了对数据库事务和行级锁定的支持。
- 修改了隧道订阅和检查逻辑,确保在事务中进行并发请求的处理。
- 更新了隧道限制验证的位置和实现方式,确保一致性。
这次的代码变更主要是为了解决在隧道注册过程中可能发生竞态条件所导致的数据一致性问题,通过使用事务锁定和行级锁定机制,有效避免了并发请求带来的同步问题。
Zaproxy alias impedit expedita quisquam pariatur exercitationem. Nemo rerum eveniet dolores rem quia dignissimos.