fix: address critical security and code review findings in Phase 3
- Wire ImportOrchestrator into review_api start_import via BackgroundTasks - Sanitize docstrings in generated tool code to prevent code injection - Add Literal["read", "write"] validation for access_type - Add regex validation for agent_group - Validate URL scheme (http/https only) in ImportRequest - Validate LLM output fields (clamp confidence, validate access_type) - Use dataclasses.replace instead of manual reconstruction in importer - Expand SSRF blocked networks (Carrier-Grade NAT, IPv4-mapped IPv6, etc.) - Make _BLOCKED_NETWORKS immutable tuple - Use yaml.safe_dump instead of yaml.dump - Fix _to_snake_case for empty strings and Python keywords
This commit is contained in:
@@ -28,19 +28,25 @@ class SSRFPolicy:
|
||||
timeout_seconds: float = 30.0
|
||||
|
||||
|
||||
_BLOCKED_NETWORKS = [
|
||||
_BLOCKED_NETWORKS = (
|
||||
ipaddress.ip_network("10.0.0.0/8"),
|
||||
ipaddress.ip_network("172.16.0.0/12"),
|
||||
ipaddress.ip_network("192.168.0.0/16"),
|
||||
ipaddress.ip_network("127.0.0.0/8"),
|
||||
ipaddress.ip_network("169.254.0.0/16"),
|
||||
ipaddress.ip_network("0.0.0.0/32"),
|
||||
ipaddress.ip_network("100.64.0.0/10"), # Carrier-Grade NAT
|
||||
ipaddress.ip_network("198.18.0.0/15"), # Benchmarking
|
||||
ipaddress.ip_network("240.0.0.0/4"), # Reserved
|
||||
ipaddress.ip_network("255.255.255.255/32"), # Broadcast
|
||||
# IPv6
|
||||
ipaddress.ip_network("::1/128"),
|
||||
ipaddress.ip_network("fe80::/10"),
|
||||
ipaddress.ip_network("fc00::/7"),
|
||||
ipaddress.ip_network("::/128"),
|
||||
]
|
||||
ipaddress.ip_network("::ffff:0:0/96"), # IPv4-mapped IPv6
|
||||
ipaddress.ip_network("2001:db8::/32"), # Documentation
|
||||
)
|
||||
|
||||
DEFAULT_POLICY = SSRFPolicy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user