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
22 changes: 22 additions & 0 deletions datapizza-ai-tools/filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,25 @@ Agent Response: Successfully deleted directory '/tmp/tmp_XXXXXX/initial_dir'.

Cleaned up temporary directory: /tmp/tmp_XXXXXX (actual path will vary)
```

> ⚠️ **Warning**: Paths are not automatically normalized. Malicious inputs like `../../../../etc/passwd` may bypass `paths_to_include`/`paths_to_exclude` filters, leading to **path traversal vulnerabilities**.

**Best Practices**:
- Normalize paths using `os.path.normpath` before any operation.
- Restrict access to known-safe directories using `paths_to_include`.

**Example: Safe Path Handling in Python**
```python
import os

def safe_path(base_dir, user_path):
# Ensure the user-provided path stays within the base directory.
norm_path = os.path.normpath(os.path.join(base_dir, user_path))
if not norm_path.startswith(base_dir):
raise ValueError("Path traversal attempt detected")
return norm_path

# Usage:
base_dir = "/safe/directory"
safe_user_path = safe_path(base_dir, user_input_path)
```
22 changes: 22 additions & 0 deletions datapizza-ai-tools/web_fetch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,25 @@ The output will vary depending on the live content of the URL. For `https://lore
--- Running agent for: 'Summarize the main points of the article at https://loremipsum.io/' ---
Agent Response: The article on **loremipsum.io** provides a comprehensive overview of "Lorem Ipsum," which is a placeholder text commonly used in the graphic, print, and publishing industries. Here are the main points:
```

> ⚠️ **Warning**: This tool accepts unsanitized URLs. If exposed to untrusted input, it could be exploited for **Server-Side Request Forgery (SSRF)**, such as accessing internal services or cloud metadata endpoints (e.g., `http://169.254.169.254/`).

**Best Practices**:
- Always validate URLs before processing (e.g., allowlist trusted domains).
- Avoid exposing this tool to uncontrolled input in production environments.
- Use `paths_to_include` and `paths_to_exclude` to restrict access to sensitive resources.

**Example: URL Validation in Python**
```python
from urllib.parse import urlparse

def is_safe_url(url, allowed_domains):
# Check if a URL belongs to a list of allowed domains.
parsed = urlparse(url)
return parsed.netloc in allowed_domains

# Usage:
allowed_domains = ["api.trusted-service.com", "public-data.example.org"]
if not is_safe_url(user_input_url, allowed_domains):
raise ValueError("URL not allowed")
```