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! |
|
I apologize for not responding sooner, @anupamme. I had an initial look back when you opened the PR. You are most likely correct in that the action can access Then is the extra complication worth the effort? |
|
Thanks for taking a look, and I agree with the distinction you're making. The original PR description overstated the security impact. The issue is real in the sense that working-directory can currently resolve outside GITHUB_WORKSPACE and cause the action to read a go.mod elsewhere on the runner, but I agree that this isn't a meaningful security boundary if the workflow itself is already under the attacker's control. The reason I kept the fix is more about the action's expected behavior: working-directory appears to select the project directory being inspected, so allowing it to escape the workspace can make the action inspect an unrelated go.mod on the runner. The current patch also makes that behavior explicit and adds regression coverage, including symlink escapes. I'm happy to reframe this as defensive input validation/correctness rather than a high-severity security fix. If you don't think enforcing the workspace boundary is useful enough to justify the additional complexity, I'm also happy to close the PR. Would you prefer to keep the workspace-boundary validation as a correctness safeguard, or should I close this? |
|
Hi @anupamme After another look I think it would be fine to add your fix. The added complexity is on a fine level, I think. In the current form |
Summary
Validate that
working-directoryresolves to a path insideGITHUB_WORKSPACEbefore readinggo.mod, including symlink-based escapes.Motivation
working-directoryis meant to select the project directory the action inspects. Currently, values like../../etcor a symlink pointing outside the workspace are silently accepted, causing the action to read an unrelatedgo.modelsewhere on the runner. This isn't a meaningful privilege boundary on its own (a workflow author who controlsworking-directoryalready controls the workflow), but it is surprising, unintended behavior relative to what the input is documented to do.Changes
src/main.js: extractedvalidateWorkingDirectory(), which resolvesworking-directoryagainstGITHUB_WORKSPACE, rejects paths that escape it (including viafs.realpathSyncsymlink resolution), and lets a genuinely missing directory fall through to the existinggomod()error.__tests__/main.test.js: added regression tests for path traversal, absolute paths outside the workspace, valid directories, and symlink escapes.Note
This PR originally described the change as a "HIGH severity security" fix (from an automated scanner report). Per discussion below, that framing overstated the impact — this is now presented as a defensive input-validation / correctness improvement, not a critical vulnerability fix.