Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@
**Vulnerability:** Writing fully buffered in-memory data to temporary disk files solely for parsing.
**Learning:** This increases attack surface, risks disk exhaustion, and violates the principle of least privilege.
**Prevention:** Refactor parsing functions to accept byte slices or `io.Reader` directly to process data in memory.

## 2024-05-30 - Prevent DoS via Missing HTTP Request Timeouts
**Vulnerability:** The application used `http.Get()` for fetching external plugins, which relies on `http.DefaultClient`. This default client has no timeout configured, allowing malicious or unresponsive servers to hang the connection indefinitely, potentially leading to Denial of Service (DoS) through resource exhaustion (e.g., file descriptors, goroutines).
**Learning:** In Go, `http.DefaultClient` should never be used for external or untrusted requests because it lacks timeouts by default.
**Prevention:** Always use a custom `http.Client` with an explicit `Timeout` configured (e.g., `Timeout: 10 * time.Second`) when making HTTP requests to external or untrusted endpoints to ensure connections are eventually closed.
6 changes: 4 additions & 2 deletions internal/plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ func (m *Manager) addScriptPlugin(owner, repo, pluginName string) error {

fmt.Printf("Fetching script from: %s\n", rawURL)

resp, err := http.Get(rawURL)
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get(rawURL)
if err != nil {
return fmt.Errorf("failed to fetch plugin: %w", err)
}
Expand Down Expand Up @@ -468,7 +469,8 @@ func (m *Manager) addFromDirectURL(rawURL string) error {
return fmt.Errorf("unsupported URL scheme: %s", parsedURL.Scheme)
}

resp, err := http.Get(parsedURL.String())
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get(parsedURL.String())
if err != nil {
return fmt.Errorf("failed to fetch plugin: %w", err)
}
Expand Down
Loading