Skip to content

🛡️ Sentinel: [CRITICAL] Fix Path Traversal in Plugin Manager#94

Open
himattm wants to merge 1 commit intomainfrom
sentinel/fix-path-traversal-6654690335110853095
Open

🛡️ Sentinel: [CRITICAL] Fix Path Traversal in Plugin Manager#94
himattm wants to merge 1 commit intomainfrom
sentinel/fix-path-traversal-6654690335110853095

Conversation

@himattm
Copy link
Copy Markdown
Owner

@himattm himattm commented May 9, 2026

🚨 Severity: CRITICAL
💡 Vulnerability: Untrusted plugin names extracted from URLs or downloaded script metadata (@name) were concatenated directly into file system paths using filepath.Join(). This allowed attackers to use directory escapes (e.g., ../../../etc/passwd) to write files outside the expected plugin directory.
🎯 Impact: Arbitrary file overwrite / Path traversal. A malicious URL or script could write or overwrite sensitive files on the user's system, potentially leading to remote code execution or privilege escalation.
🔧 Fix: Sanitized the extracted pluginName and meta.Name by strictly applying filepath.Base(filepath.Clean("/" + name)) before any path construction. This guarantees only the final valid filename component is used, preventing directory escapes.
Verification: Verified by unit tests and ensuring filepath.Join receives sanitized input. Test files with explicit path traversals demonstrated successful containment.


PR created automatically by Jules for task 6654690335110853095 started by @himattm

Untrusted plugin names from parsed URLs or downloaded script metadata
were concatenated directly into file paths using `filepath.Join()`,
allowing attackers to write arbitrary files outside the plugin directory
via directory escapes (e.g. `../`). This explicitly sanitizes input with
`filepath.Base(filepath.Clean("/" + name))` before constructing file paths.

Co-authored-by: himattm <6266621+himattm@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@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 addresses a path traversal vulnerability in the plugin manager by sanitizing plugin names derived from URLs and metadata using filepath.Base and filepath.Clean. Review feedback suggests extracting this duplicated sanitization logic into a centralized helper function to improve maintainability. Additionally, it is recommended to add validation for the resulting names to ensure they are valid identifiers and do not resolve to '.' or '/', which could cause subsequent file operations to fail.

if len(parts) >= 2 {
owner, repo := parts[0], parts[1]
pluginName := strings.TrimPrefix(repo, "prism-plugin-")
pluginName := filepath.Base(filepath.Clean("/" + strings.TrimPrefix(repo, "prism-plugin-")))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The sanitization logic filepath.Base(filepath.Clean("/" + name)) is duplicated here and at lines 438 and 490. To improve maintainability and ensure consistent behavior across the manager, consider extracting this into a helper function. Additionally, this logic can return . or / for certain inputs (e.g., if the input resolves to the root after cleaning). While this prevents path traversal, it can lead to invalid filenames like prism-plugin-/.sh which will cause subsequent file operations to fail. It would be more robust to validate that the resulting name is a valid, non-empty identifier.

if meta.Name == "" {
meta.Name = pluginName
} else {
meta.Name = filepath.Base(filepath.Clean("/" + meta.Name))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This is another instance of the duplicated sanitization logic. As mentioned previously, extracting this to a helper function and adding validation for edge cases (like the name resolving to . or /) would improve the robustness of the plugin manager.

for _, suffix := range []string{"-darwin-arm64", "-darwin-amd64", "-linux-amd64", "-linux-arm64"} {
pluginName = strings.TrimSuffix(pluginName, suffix)
}
pluginName = filepath.Base(filepath.Clean("/" + pluginName))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Third instance of the duplicated sanitization logic. Centralizing this logic would make it easier to apply more thorough validation (e.g., checking for invalid characters or reserved names) consistently across all plugin installation methods.

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.

1 participant