fix: the working-directory input parameter is accept... in main.js - #620
Open
anupamme wants to merge 1 commit into
Open
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.
Comment on lines
+29
to
+33
| if ( | ||
| resolvedDirectory !== workspace && | ||
| !resolvedDirectory.startsWith(workspace + path.sep) | ||
| ) { | ||
| throw new Error('working-directory must resolve to a path inside the workspace') |
Comment on lines
+27
to
+35
| 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')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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