The eval viewer's safeJoin allows a sibling directory sharing the runs prefix
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, nodejs
调研方向
错误位于 packages/hdx-eval/scripts/viewer/server.js 中的 safeJoin(约第 39 行),它对解析后的根路径只做了简单的 startsWith 检查。复现方法:创建同级目录 runs-other,然后在第 176 行附近的 run 路由上请求 /api/batches/..%2Fruns-other/runs/a/b/c/1。完成标准是:检查时以路径分隔符为边界与根目录比较(或使用 path.relative),并且对同级目录的请求返回错误,而不是返回文件。
由索引模型根据 Issue 内容生成。
描述
The eval viewer's safeJoin allows a sibling directory sharing the runs prefix
Summary
The eval viewer's safeJoin checks only startsWith(path.resolve(root)). A sibling directory whose name begins with the runs root name passes the check. A crafted request can therefore read a JSON run artifact from outside the configured runs directory.
Location
- Repository:
hyperdxio/hyperdx - File:
packages/hdx-eval/scripts/viewer/server.js - Line: 39 (
safeJoin; the run route is at 176) - Revision:
1773c11942a7
Affected code
function safeJoin(root, ...parts) {
const p = path.resolve(root, ...parts);
if (!p.startsWith(path.resolve(root))) throw new Error('path escapes root');
return p;
}
The prefix check has no path-separator boundary.
Expected behavior
A request may only read files under the configured runs directory. A path resolving to a sibling such as runs-other/... must be rejected.
Actual behavior
Create a sibling runs-other/a/b/c/1.json next to runs, then run the viewer and request:
/api/batches/..%2Fruns-other/runs/a/b/c/1
The server returns the sibling file:
200 {"trajectory":{"secret":"outside"},"grade":null}
The file is outside packages/hdx-eval/runs.
Root cause
path.resolve(root, '../runs-other/...') produces a path that still starts with the root string (.../runs-other starts with .../runs). startsWith therefore accepts it.
Suggested fix
Append a path separator to the root before comparing, or use path.relative and reject results starting with .. or absolute paths:
const base = path.resolve(root);
const p = path.resolve(base, ...parts);
const rel = path.relative(base, p);
if (rel.startsWith('..') || path.isAbsolute(rel)) throw new Error('path escapes root');
return p;
- 主要语言
- TypeScript
- 星标
- 10.1k
- 派生
- 527
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 186
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ClickHouse/ClickStack 的其他 Issue
-
Metric chart with aggFn increase and a multi-column group-by fails: toString() gets several arguments可能已有人在做 @CG-5228 于 26 天前认领。 未关闭external
难度 2/5 1-3 小时 新手友好度 76/100
ClickHouse/ClickStack#3477 · 1 条评论 ·
维护者通常 1 天内回复
-
Slack notifications for inline alerts fail when the chart-explorer link passes Slack's 3000-character block limit可能已有人在做 @Tyagiquamar 于 27 天前认领。 未关闭alerting bug external
难度 2/5 1-3 小时 新手友好度 76/100
ClickHouse/ClickStack#3452 ·
维护者通常 1 天内回复
-
check-alerts worker: 13 error spans (mongodb.create, NamespaceExists) every minute because mongoose autoCreate is still on可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug external Needs Feedback
难度 2/5 1-3 小时 新手友好度 72/100
ClickHouse/ClickStack#3308 · 1 条评论 ·
维护者通常 1 天内回复
-
count_distinct aggFn on metric tiles ignores valueExpression, always counts distinct metric Values可能已有人在做 @Harshul1484 于 54 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
ClickHouse/ClickStack#2311 ·
维护者通常 1 天内回复
-
enhancement Needs Feedback
难度 5/5 一周以上 新手友好度 25/100
ClickHouse/ClickStack#3687 ·
维护者通常 1 天内回复
查看 ClickHouse/ClickStack 的全部 Issue
相似的 Issue
-
Add: GTrekker未关闭check:passed streams:add
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
area: ui Bug Payload OSS
难度 1/5 1 小时以内 新手友好度 88/100
payloadcms/payload#19839 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
fix(auth): add the email OTP verification step to Pollar login可能已有人在做 @akansnoro 今天认领。 未关闭Stellar Wave
难度 2/5 1-3 小时 新手友好度 74/100
safetrustcr/dApp-SafeTrust#584 · 10 条评论 ·
维护者通常 1 天内回复
-
The manager preset saves launch definitions without the required file and digest pair可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复