-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for GitLab/Gitea #12
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
Conversation
Kusari Analysis Results:Caution Flagged Issues Detected While the dependency addition (gopkg.in/[email protected]) is safe with no vulnerabilities and poses no risk, a HIGH impact code injection vulnerability was identified in pkg/prx/auth/auth.go at line 227. The runCommand function executes commands with dynamic parameters without validation or allowlisting, creating potential for arbitrary code execution. Although the likelihood is assessed as LOW, the severity of code injection warrants blocking this PR until addressed. Action required: Implement command allowlisting as provided in the mitigation guidance to validate command names before execution and prevent potential command injection through argument manipulation. Note View full detailed analysis result for more information on the output and the checks that were run. Required Code MitigationsThe runCommand function accepts arbitrary command names and arguments without validation. Implement an allowlist of permitted commands to prevent code injection. Example approach: Create a map of allowed commands and validate the 'name' parameter against it before execution. Additionally, consider using a more restrictive function signature that limits which commands can be executed, or validate/sanitize the args parameter to prevent command injection through argument manipulation.
Found this helpful? Give it a 👍 or 👎 reaction! |
| ctx, cancel := context.WithTimeout(ctx, r.timeout) | ||
| defer cancel() | ||
|
|
||
| cmd := exec.CommandContext(ctx, name, args...) |
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.
Issue: The runCommand function accepts arbitrary command names and arguments without validation. Implement an allowlist of permitted commands to prevent code injection. Example approach: Create a map of allowed commands and validate the 'name' parameter against it before execution. Additionally, consider using a more restrictive function signature that limits which commands can be executed, or validate/sanitize the args parameter to prevent command injection through argument manipulation.
Recommended Code Changes:
// Add before runCommand:
var allowedCommands = map[string]bool{
"git": true,
"gh": true,
// add other legitimate commands
}
func (r *Resolver) runCommand(ctx context.Context, name string, args ...string) (string, error) {
if !allowedCommands[name] {
return "", fmt.Errorf("command not allowed: %s", name)
}
ctx, cancel := context.WithTimeout(ctx, r.timeout)
defer cancel()
cmd := exec.CommandContext(ctx, name, args...)
output, err := cmd.Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(output)), nil
}
|
Kusari PR Analysis rerun based on - b9dfd36 performed at: 2026-01-15T22:07:27Z - link to updated analysis |
No description provided.