🛡️ 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:
@@ -142,7 +142,7 @@ class TestFileDetailPage:
|
||||
db_session.commit()
|
||||
|
||||
# Test file detail page
|
||||
response = client.get(f"/files/{file_record.id}/process")
|
||||
response = client.get(f"/files/{file_record.id}/detail")
|
||||
assert response.status_code == 200
|
||||
content = response.text
|
||||
assert "test.pdf" in content
|
||||
@@ -150,7 +150,7 @@ class TestFileDetailPage:
|
||||
def test_file_detail_page_with_missing_file(self, client: TestClient, db_session):
|
||||
"""Test file detail page with non-existent file"""
|
||||
# Try to access non-existent file
|
||||
response = client.get("/files/99999/process")
|
||||
response = client.get("/files/99999/detail")
|
||||
assert response.status_code == 200
|
||||
content = response.text
|
||||
assert "not found" in content.lower()
|
||||
@@ -193,7 +193,7 @@ class TestFileDetailPage:
|
||||
db_session.commit()
|
||||
|
||||
# Test file detail page
|
||||
response = client.get(f"/files/{file_record.id}/process")
|
||||
response = client.get(f"/files/{file_record.id}/detail")
|
||||
assert response.status_code == 200
|
||||
content = response.text
|
||||
assert "create_file_record" in content
|
||||
@@ -232,7 +232,7 @@ class TestFileDetailPage:
|
||||
db_session.commit()
|
||||
|
||||
# Test file detail page
|
||||
response = client.get(f"/files/{file_record.id}/process")
|
||||
response = client.get(f"/files/{file_record.id}/detail")
|
||||
assert response.status_code == 200
|
||||
content = response.text
|
||||
# Should show metadata
|
||||
|
||||
Reference in New Issue
Block a user