-
Notifications
You must be signed in to change notification settings - Fork 13
fix: removed dangerous character Validation [IDE-1597] #1084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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)
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)
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.
55af4b7 to
843b49c
Compare
| // Validate Windows UNC admin share paths | ||
| if err := validateWindowsUNCAdminShare(pathStr); err != nil { |
There was a problem hiding this comment.
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?
| // 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, | ||
| }, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this removed?
Description
This pull request removes the previous path validation mechanism that specifically checked for and rejected 'dangerous characters' to prevent potential injection attacks.
Checklist
make generate)make lint-fix)