Skip to content

Conversation

@tstromberg
Copy link
Member

No description provided.

@kusari-inspector
Copy link

kusari-inspector bot commented Nov 13, 2025

Kusari Inspector

Kusari Analysis Results:

Do not proceed without addressing issues

Caution

Flagged Issues Detected
These changes contain flagged issues that may introduce security risks.

While dependency analysis shows no security concerns with pinned versions, code analysis identified a HIGH impact command injection vulnerability in pkg/safebrowse/safebrowse.go at line 224. The rawURL parameter passed to exec.CommandContext lacks proper validation and sanitization, potentially allowing malicious URLs containing shell metacharacters to execute arbitrary commands. This critical security risk must be addressed before merge by implementing URL validation and sanitization as outlined in the provided mitigation. The detected secret is confirmed as a false positive test data.

Note

View full detailed analysis result for more information on the output and the checks that were run.

Required Code Mitigations

Add URL validation and sanitization before executing the command. Parse and validate the URL to ensure it's properly formatted and doesn't contain shell metacharacters that could be exploited for command injection.

// Validate and parse the URL before execution
parsedURL, err := url.Parse(rawURL)
if err != nil {
    return fmt.Errorf("invalid URL: %w", err)
}
// Ensure the URL scheme is safe (http/https)
if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
    return errors.New("unsupported URL scheme")
}
// Use the cleaned URL string
cleanURL := parsedURL.String()
cmd = exec.CommandContext(ctx, xdgOpen, cleanURL)

@kusari-inspector rerun - Trigger a re-analysis of this PR
@kusari-inspector feedback [your message] - Send feedback to our AI and team
See Kusari's documentation for setup and configuration.
Commit: 6dd7fae, performed at: 2025-11-13T02:58:46Z

Found this helpful? Give it a 👍 or 👎 reaction!

cmd/goose/ui.go Outdated
return errors.New("xdg-open not found")
}
slog.Debug("Executing command", "command", xdgOpenPath, "url", rawURL)
cmd = exec.CommandContext(ctx, xdgOpenPath, rawURL)

Choose a reason for hiding this comment

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

Issue: Add URL validation and sanitization before executing the command. Parse and validate the URL to ensure it's properly formatted and doesn't contain shell metacharacters that could be exploited for command injection.

Recommended Code Changes:

// Validate and parse the URL before execution
parsedURL, err := url.Parse(rawURL)
if err != nil {
    return fmt.Errorf("invalid URL: %w", err)
}
// Ensure the URL scheme is safe (http/https)
if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
    return errors.New("unsupported URL scheme")
}
// Use the cleaned URL string
cleanURL := parsedURL.String()
cmd = exec.CommandContext(ctx, xdgOpenPath, cleanURL)

@kusari-inspector
Copy link

Kusari PR Analysis rerun based on - 6dd7fae performed at: 2025-11-13T02:59:28Z - link to updated analysis

if err != nil {
return err
}
cmd = exec.CommandContext(ctx, xdgOpen, rawURL)

Choose a reason for hiding this comment

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

Issue: Add URL validation and sanitization before executing the command. Parse and validate the URL to ensure it's properly formatted and doesn't contain shell metacharacters that could be exploited for command injection.

Recommended Code Changes:

// Validate and parse the URL before execution
parsedURL, err := url.Parse(rawURL)
if err != nil {
    return fmt.Errorf("invalid URL: %w", err)
}
// Ensure the URL scheme is safe (http/https)
if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
    return errors.New("unsupported URL scheme")
}
// Use the cleaned URL string
cleanURL := parsedURL.String()
cmd = exec.CommandContext(ctx, xdgOpen, cleanURL)

@tstromberg tstromberg merged commit aac3c5c into main Nov 13, 2025
4 of 5 checks passed
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