Skip to content

Conversation

@acke
Copy link
Contributor

@acke acke commented Dec 10, 2025

Description

This pull request removes the previous path validation mechanism that specifically checked for and rejected 'dangerous characters' to prevent potential injection attacks.

Checklist

  • Tests added and all succeed
  • Regenerated mocks, etc. (make generate)
  • Linted (make lint-fix)
  • README.md updated, if user-facing
  • License file updated, if new 3rd-party dependency is introduced

@acke acke requested review from a team as code owners December 10, 2025 09:21
@snyk-io
Copy link

snyk-io bot commented Dec 10, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @acke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request removes the previous path validation mechanism that specifically checked for and rejected 'dangerous characters' to prevent potential injection attacks. The change streamlines path handling by eliminating these checks, allowing a broader range of characters in paths to be processed without triggering validation errors. This aligns with the fix nature of the PR, suggesting the previous validation might have been overly restrictive or incorrectly applied.

Highlights

  • Removal of Dangerous Character Validation: The logic responsible for identifying and rejecting paths containing 'dangerous characters' (such as semicolons, ampersands, backticks, dollar signs, and quotes) has been completely removed from the ValidatePath and PathKey functions. This means paths with these characters will no longer trigger validation errors based on this specific check.
  • Deletion of Related Code and Tests: The global dangerousChars variable and the validateDangerousCharacters helper function, along with all associated test cases in path_test.go that specifically checked for these characters, have been removed. This includes tests for various command injection scenarios and Windows UNC admin share paths.
  • Updated PathKey Behavior: The PathKey function now processes paths containing characters like semicolons, normalizing them rather than returning an empty string due to a validation error.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request removes validation against dangerous characters in paths across several utility functions. This change has significant security implications, as it could expose the application to command injection vulnerabilities if the paths are ever used in shell commands. The removal of this validation from ValidatePath and PathKey is particularly concerning. While this might be an intentional fix for a specific issue, the lack of description in the PR makes it impossible to assess the trade-offs. I have added critical security-related comments highlighting the risks. This change should not be merged without a clear explanation of why this security check is no longer needed and an audit of all call sites to ensure paths are handled safely.

I am having trouble creating individual review comments. Click here to see my feedback.

internal/util/path.go (41-44)

security-critical critical

Removing the validation for dangerous characters (validateDangerousCharacters) introduces a significant security risk. These characters (e.g., ;, &, |, \``) are often used in command injection attacks. If any path validated by this function is later used in a shell command or any context where it's interpreted by a shell, it could lead to arbitrary code execution. Was this removal intentional? If so, the rationale should be clearly documented, and all call sites must be audited to ensure they don't pass these paths to unsafe functions. Given the function's name ValidatePath` and its previous purpose, callers might have a false sense of security.

internal/util/path.go (106-108)

security-critical critical

Similar to ValidatePath, removing the dangerous character check from PathKey is a security concern. This function now normalizes and returns paths containing characters that could be used for command injection. The corresponding test case TestPathKey was updated to reflect this, allowing a path like /Users/foo; rm -rf /. If the output of PathKey is ever used to construct a shell command, this could be exploited. It's crucial to ensure that all usages of the returned path key are safe.

@acke acke force-pushed the fix/remove_path_validation branch from 55af4b7 to 843b49c Compare December 10, 2025 09:33
@acke acke changed the title fix: removed path validation [IDE-1597] fix: removed dangerous character Validation [IDE-1597] Dec 10, 2025
Comment on lines +38 to +39
// Validate Windows UNC admin share paths
if err := validateWindowsUNCAdminShare(pathStr); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wondering, why is this now added? Wasn't it about removing the dangerousChar check that was breaking scanning in some directories?

Comment on lines -183 to -200
// Add Windows UNC admin share test cases (only for lenient, as they don't exist on non-Windows)
testCases = append(testCases,
testCase{
name: "Windows UNC admin share C$",
input: "\\\\localhost\\C$\\Users\\test",
expectError: false,
},
testCase{
name: "Windows UNC admin share D$",
input: "\\\\server\\D$\\path\\to\\file",
expectError: false,
},
testCase{
name: "Windows UNC admin share with forward slashes",
input: "//localhost/C$/Users/test",
expectError: false,
},
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this removed?

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.

3 participants