fix: the working-directory input parameter is accept... in main.js - #620
fix: the working-directory input parameter is accept... in main.js#620anupamme wants to merge 2 commits into
Conversation
Automated security fix generated by OrbisAI Security Signed-off-by: anupamme <mediratta@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new workspace-boundary check can still be bypassed via symlinks/junctions within the workspace and needs additional hardening and regression coverage before it reliably addresses the reported vulnerability.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens the GitHub Action’s handling of the working-directory input to mitigate a path traversal risk when reading go.mod, aligning with the stated goal of fixing a high-severity security issue in src/main.js.
Changes:
- Added path-based normalization and an “inside workspace” check for
working-directorybefore readinggo.mod. - Switched from string concatenation to
path.join()when constructing thego.modpath.
File summaries
| File | Description |
|---|---|
| src/main.js | Resolves and validates working-directory against the workspace before reading go.mod. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if ( | ||
| resolvedDirectory !== workspace && | ||
| !resolvedDirectory.startsWith(workspace + path.sep) | ||
| ) { | ||
| throw new Error('working-directory must resolve to a path inside the workspace') |
| const workspace = path.resolve(process.env.GITHUB_WORKSPACE || process.cwd()) | ||
| const resolvedDirectory = path.resolve(workspace, workingDirectory) | ||
| if ( | ||
| resolvedDirectory !== workspace && | ||
| !resolvedDirectory.startsWith(workspace + path.sep) | ||
| ) { | ||
| throw new Error('working-directory must resolve to a path inside the workspace') | ||
| } | ||
| const content = gomod(path.join(resolvedDirectory, 'go.mod')) |
|
✅ Review Feedback Addressed I've automatically addressed 1 review comment(s): The reviewer flagged that there are no regression tests for the new workspace-boundary validation and that the current Changes made:
Files modified:
The changes have been pushed to this PR branch. Please review! |
Summary
Fix high severity security issue in
src/main.js.Vulnerability
V-001src/main.js:20Description: The working-directory input parameter is accepted from workflow configuration without validation and used directly in file system operations. The gomod() function constructs file paths using string concatenation without sanitizing traversal sequences, allowing access to files outside the intended workspace directory.
Evidence
Exploitation scenario: An attacker with workflow modification access sets working-directory to '../../../etc' causing the action to attempt reading /etc/go.mod.
Scanner confirmation: multi_agent_ai rule
V-001flagged this pattern.Production code: This file is in the production codebase, not test-only code.
Threat Model Context
This is a private Node.js application (not published to npm). Vulnerabilities affect this application's own runtime only.
Changes
src/main.jsBehavior Preservation
The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.
Automated security fix by OrbisAI Security