The eval viewer's safeJoin allows a sibling directory sharing the runs prefix
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, nodejs
Research direction
The bug is in safeJoin in packages/hdx-eval/scripts/viewer/server.js (around line 39), which uses a bare startsWith check on the resolved root. Reproduce by creating a sibling runs-other directory and requesting /api/batches/..%2Fruns-other/runs/a/b/c/1 against the run route near line 176. Done when the check compares against the root with a path-separator boundary (or uses path.relative) and the sibling request returns an error instead of the file.
Written by the indexing model from the issue text.
Description
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;
- Dominant language
- TypeScript
- Stars
- 10.1k
- Forks
- 527
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 186
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/ClickStack
-
Metric chart with aggFn increase and a multi-column group-by fails: toString() gets several argumentsPossibly taken @CG-5228 claimed this 26 days ago. Openexternal
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/ClickStack#3477 · 1 comment ·
Maintainers usually reply within 1 day
-
Slack notifications for inline alerts fail when the chart-explorer link passes Slack's 3000-character block limitPossibly taken @Tyagiquamar claimed this 27 days ago. Openalerting bug external
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/ClickStack#3452 ·
Maintainers usually reply within 1 day
-
check-alerts worker: 13 error spans (mongodb.create, NamespaceExists) every minute because mongoose autoCreate is still onMay be free again A pull request for this issue was closed without being merged. Openbug external Needs Feedback
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ClickHouse/ClickStack#3308 · 1 comment ·
Maintainers usually reply within 1 day
-
count_distinct aggFn on metric tiles ignores valueExpression, always counts distinct metric ValuesPossibly taken @Harshul1484 claimed this 54 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ClickHouse/ClickStack#2311 ·
Maintainers usually reply within 1 day
-
enhancement Needs Feedback
Difficulty 5/5 Over a week Newbie friendliness 25/100
ClickHouse/ClickStack#3687 ·
Maintainers usually reply within 1 day
All issues in ClickHouse/ClickStack
Similar issues
-
Add: GTrekkerOpencheck:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: ui Bug Payload OSS
Difficulty 1/5 Under an hour Newbie friendliness 88/100
payloadcms/payload#19839 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
fix(auth): add the email OTP verification step to Pollar loginPossibly taken @akansnoro claimed this today. OpenStellar Wave
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
safetrustcr/dApp-SafeTrust#584 · 10 comments ·
Maintainers usually reply within 1 day
-
The manager preset saves launch definitions without the required file and digest pairPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day