Skip to content

fix: the working-directory input parameter is accept... in main.js - #620

Open
anupamme wants to merge 1 commit into
arnested:mainfrom
anupamme:fix-repo-go-version-action-working-directory-path-traversal
Open

fix: the working-directory input parameter is accept... in main.js#620
anupamme wants to merge 1 commit into
arnested:mainfrom
anupamme:fix-repo-go-version-action-working-directory-path-traversal

Conversation

@anupamme

@anupamme anupamme commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Fix high severity security issue in src/main.js.

Vulnerability

Field Value
ID V-001
Severity HIGH
Scanner multi_agent_ai
Rule V-001
File src/main.js:20
Assessment Likely exploitable

Description: 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-001 flagged 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.js

Behavior 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

Automated security fix generated by OrbisAI Security

Signed-off-by: anupamme <mediratta@gmail.com>
@CLAassistant

CLAassistant commented Sep 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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-directory before reading go.mod.
  • Switched from string concatenation to path.join() when constructing the go.mod path.
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 thread src/main.js
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 thread src/main.js
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'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants