Skip to content

fix: path traversal + vulnerable dependency updates#18

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/resolve-security-vulnerabilities
Draft

fix: path traversal + vulnerable dependency updates#18
Copilot wants to merge 3 commits into
mainfrom
copilot/resolve-security-vulnerabilities

Conversation

Copilot AI commented Jun 5, 2026

Copy link
Copy Markdown

Three high/moderate npm vulnerabilities and two path traversal vectors in source handling.

Dependency updates (npm audit fix)

Note: picomatch and postcss are transitive dependencies and cannot be declared in package.json; they are locked to safe versions via package-lock.json.

Path traversal in sync.ts / status.ts

path.join(cacheDir, entry.source) silently normalises .. sequences, so a tampered manifest entry like source: "../../etc/passwd" resolves outside the cache directory — enabling arbitrary file read/write.

Added assertPathWithin(filePath, containingDir, label) and applied it in syncEntry() and determineState():

// src/sync.ts
export function assertPathWithin(filePath: string, containingDir: string, label: string): void {
  const resolved = path.resolve(filePath);
  const base = path.resolve(containingDir);
  if (resolved !== base && !resolved.startsWith(base + path.sep)) {
    throw new Error(`${label} escapes the expected directory boundary.`);
  }
}

Guards cover: non-glob source path, glob base dir, each glob match, and each computed destination file. status.ts returns 'missing' on violation rather than throwing, consistent with its existing error-handling pattern.

Copilot AI added 2 commits June 5, 2026 11:07
…raversal fixes

- Run npm audit fix: update simple-git 3.33.0→3.36.0 (RCE), picomatch 2.3.1→2.3.2 (ReDoS/injection), postcss 8.5.8→8.5.15 (XSS)
- Add assertPathWithin() helper in sync.ts to guard directory boundaries
- Apply path-traversal guards in syncEntry(): validate source path and glob matches stay within cacheDir, validate glob dest files stay within destPath
- Apply same guards in determineState() in status.ts"
Copilot AI self-assigned this Jun 5, 2026
Copilot AI review requested due to automatic review settings June 5, 2026 11:09
Copilot AI removed the request for review from Copilot June 5, 2026 11:09
Copilot AI changed the title fix: resolve security vulnerabilities (dependency updates + path traversal) fix: path traversal + vulnerable dependency updates Jun 5, 2026
Copilot finished work on behalf of madkoo June 5, 2026 11:09
Copilot AI requested a review from madkoo June 5, 2026 11:09
@madkoo

madkoo commented Jun 6, 2026

Copy link
Copy Markdown
Owner

@copilot Should the package.json get updated too with newer versions ?

Raises the declared lower bound to match the secure version installed by
npm audit fix, so fresh installs cannot resolve a vulnerable release.
Copilot AI requested review from Copilot and removed request for Copilot June 6, 2026 09:03

Copilot AI commented Jun 6, 2026

Copy link
Copy Markdown
Author

@copilot Should the package.json get updated too with newer versions ?

Good catch. simple-git is the only direct dependency that was vulnerable — picomatch and postcss are transitive and can't be declared in package.json. Updated the simple-git range from ^3.22.0 to ^3.36.0 in [this commit]($(git -C /tmp/workspace/madkoo/distributed-files rev-parse --short HEAD)) so fresh installs can't resolve a vulnerable release.

Copilot finished work on behalf of madkoo June 6, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants