[SDK] jobs: runJob builds remote Linux guest paths with host node:path, breaking uploads and result collection from Windows
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)
- Broken uploads & result collection from Windows hosts:
- On Windows (
path.sep === '\\'),join('/root/job', 'src/app.py')produces'\\root\\job\\src\\app.py'anddirname(...)produces'\\root\\job\\src'. exec(vm, 'mkdir -p ...')creates literal backslash-named entries on the Linux guest rather than/root/job/src, andwriteRemote/readRemote(sftp.writeFile/sftp.readFile) fail with SFTPNo such file(stage: 'upload'or'collect').
- On Windows (
- Unbounded relative path traversal out of
JOB_DIR:- Caller-supplied keys in
options.files(e.g.'../.ssh/authorized_keys'or'/etc/cron.d/x') andoptions.collectwere passed directly intojoin(JOB_DIR, rel)without verifying that the normalized remote path stays inside/root/job.
- Caller-supplied keys in
- Browser test runner config:
vitest.config.tsincludedtest/**/*.test.tsunconditionally 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
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.