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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
**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-08-04 - Fix DoS risk by adding timeouts to HTTP requests
**Vulnerability:** External HTTP requests were made using `http.Get()`, which relies on `http.DefaultClient` and lacks request timeouts, leading to potential DoS or resource exhaustion.
**Learning:** `http.Get()` has no timeout. A malicious or unoptimized external server could hang connections infinitely, causing goroutine or connection leaks.
**Prevention:** Always replace `http.Get()` with a custom `http.Client` that is configured with appropriate timeouts (e.g., `Timeout: 10 * time.Second`).
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