Bounty
XE-13240 · Bounty

[SDK] jobs: runJob builds remote Linux guest paths with host node:path, breaking uploads and result collection from Windows

Closed · duplicate — xe#369 filed 2026-11-11 10:12 UTC by Khanhtnq

Report

Summary

@xeprotocol/sdk/jobs (src/jobs/index.ts in xeprotocol/sdk) runs jobs on a Linux VM where JOB_DIR is '/root/job', but runJob constructs remote SFTP and mkdir -p paths using host node:path (join, dirname) instead of node:path/posix.

Impact (sdk-docs-web, Medium)

  1. Broken uploads & result collection from Windows hosts:
    • On Windows (path.sep === '\\'), join('/root/job', 'src/app.py') produces '\\root\\job\\src\\app.py' and dirname(...) produces '\\root\\job\\src'.
    • exec(vm, 'mkdir -p ...') creates literal backslash-named entries on the Linux guest rather than /root/job/src, and writeRemote / readRemote (sftp.writeFile / sftp.readFile) fail with SFTP No such file (stage: 'upload' or 'collect').
  2. Unbounded relative path traversal out of JOB_DIR:
    • Caller-supplied keys in options.files (e.g. '../.ssh/authorized_keys' or '/etc/cron.d/x') and options.collect were passed directly into join(JOB_DIR, rel) without verifying that the normalized remote path stays inside /root/job.
  3. Browser test runner config:
    • vitest.config.ts included test/**/*.test.ts unconditionally even when invoked with --browser, where Node-only @xeprotocol/sdk/jobs (ssh2 + node:fs/promises) cannot load.

Rule

Every remote path resolved from options.files, options.collect, or listRemote for the Linux guest is normalized with node:path/posix and confined within /root/job (while host saveTo writes continue to use host node:path).

Reproduction

On Windows (or simulating backslash inputs / parent segments in unit tests), call runJob with nested files: { 'sub/input.txt': 'hello' } and collect: 'out'. Observe mkdir -p and SFTP writeFile/readFile receive backslash-separated paths instead of /root/job/sub/input.txt and /root/job/out/....

Proposed Fix

Ready-to-merge patch + unit/browser regression suite submitted in https://github.com/xeprotocol/sdk/pull/15.

Thread

Joseph Denneteam2026-11-20 00:05 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13240 and says what differs; it is read like any other.