Skip to content

Potential fix for code scanning alert no. 2: Uncontrolled data used in path expression#6

Merged
webdevdot merged 5 commits into
mainfrom
alert-autofix-2
Apr 14, 2026
Merged

Potential fix for code scanning alert no. 2: Uncontrolled data used in path expression#6
webdevdot merged 5 commits into
mainfrom
alert-autofix-2

Conversation

@webdevdot

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/webdevdot/code-index-mcp/security/code-scanning/2

To fix this safely without changing intended functionality, validate that the requested folderPath resolves to one of the configured project folders before any filesystem operations or indexing start.

Best approach here:

  1. Canonicalize/normalize the user path using path.resolve + fs.realpathSync.
  2. Canonicalize each configured allowed root (config.PROJECT_FOLDERS) similarly.
  3. Enforce that requested canonical path is either exactly an allowed root or a descendant of one (startsWith(allowedRoot + path.sep)).
  4. Use the canonical path for subsequent existsSync, statSync, and Indexer usage.

This should be implemented in api/dashboard.js within triggerIndexing (around lines 319–352), since this is the central sink and keeps enforcement in one place even if additional callers are added later.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…n path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@webdevdot webdevdot marked this pull request as ready for review April 9, 2026 09:18
Comment thread api/dashboard.js Fixed
Comment thread api/dashboard.js Fixed
webdevdot and others added 2 commits April 9, 2026 14:54
…ed in path expression'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ed in path expression'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread api/dashboard.js Fixed
Comment thread api/dashboard.js Fixed
webdevdot and others added 2 commits April 14, 2026 22:58
…ed in path expression'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ed in path expression'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@webdevdot webdevdot merged commit fcb8ee0 into main Apr 14, 2026
3 of 4 checks passed
@webdevdot webdevdot deleted the alert-autofix-2 branch April 14, 2026 17:33
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