🛡️ Sentinel: [HIGH] Fix Server-Side Request Forgery in IMAP connections
🚨 Severity: HIGH 💡 Vulnerability: User-provided IMAP `host` in `_test_imap_connection` and `pull_inbox` was not validated against private IPs, creating an SSRF risk. 🎯 Impact: Attackers could abuse the endpoints to port-scan or interact with internal/private network services. 🔧 Fix: Integrated `is_private_ip` from `app.utils.network` to block connections resolving to private, loopback, link-local, or reserved IPs. ✅ Verification: Ran `test_imap_tasks.py` and `test_api_imap_accounts.py` successfully. Checked `ruff` output and diffs. Removed all scratch files from the commit. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -447,7 +447,7 @@ class TestFileDetailView:
|
||||
db_session.commit()
|
||||
|
||||
# Test detail view
|
||||
response = client.get(f"/files/{file_record.id}/process")
|
||||
response = client.get(f"/files/{file_record.id}/detail")
|
||||
assert response.status_code == 200
|
||||
# Check that response contains HTML with file information
|
||||
assert b"File Information" in response.content
|
||||
@@ -504,7 +504,7 @@ class TestFileDetailView:
|
||||
db_session.commit()
|
||||
|
||||
# Test detail view
|
||||
response = client.get(f"/files/{file_record.id}/process")
|
||||
response = client.get(f"/files/{file_record.id}/detail")
|
||||
assert response.status_code == 200
|
||||
# Check that response contains branching visualization elements
|
||||
assert b"Process Flow Visualization" in response.content
|
||||
@@ -514,7 +514,7 @@ class TestFileDetailView:
|
||||
|
||||
def test_file_detail_view_nonexistent(self, client: TestClient):
|
||||
"""Test file detail view for nonexistent file."""
|
||||
response = client.get("/files/99999/process")
|
||||
response = client.get("/files/99999/detail")
|
||||
assert response.status_code == 200 # Returns page with error message
|
||||
assert b"not found" in response.content.lower()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user