codeant-ai-for-open-source[bot] commented on code in PR #42930:
URL: https://github.com/apache/superset/pull/42930#discussion_r3742438216


##########
superset/commands/dataset/importers/v1/utils.py:
##########
@@ -581,7 +625,12 @@ def load_data(data_uri: str, dataset: SqlaTable, database: 
Database) -> None:
 
     validate_data_uri(data_uri)
     logger.info("Downloading data from %s", data_uri)
-    opener = request.build_opener(_ValidatingRedirectHandler)
+    handlers: list[type[request.BaseHandler]] = [_ValidatingRedirectHandler]
+    if not app.config["DATASET_IMPORT_ALLOW_INTERNAL_DATA_URLS"]:
+        # Also enforce the policy at the socket layer: re-check the peer of
+        # every connection, including each redirect hop.
+        handlers.extend([_PeerValidatingHTTPHandler, 
_PeerValidatingHTTPSHandler])
+    opener = request.build_opener(*handlers)
     data = opener.open(data_uri)  # pylint: disable=consider-using-with  # 
noqa: S310

Review Comment:
   **Suggestion:** The custom handlers do not disable or account for `urllib`'s 
default `ProxyHandler`, so when an HTTP(S) proxy is configured the connection 
socket is established to the proxy. `_raise_for_unsafe_peer` then validates the 
proxy's public address rather than the destination address, allowing the proxy 
to resolve and fetch an otherwise forbidden internal destination. The peer 
check must either reject proxy use for these imports or validate the 
destination independently through a trusted proxy-aware mechanism. [ssrf]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Dataset imports can use proxies to reach internal destinations.
   - ❌ DNS-rebinding protection is bypassed for proxied HTTP(S) imports.
   - ⚠️ Affected deployments inherit proxy settings from worker environments.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=649bddc06c3044039698b3681362106f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=649bddc06c3044039698b3681362106f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/commands/dataset/importers/v1/utils.py
   **Line:** 628:634
   **Comment:**
        *Ssrf: The custom handlers do not disable or account for `urllib`'s 
default `ProxyHandler`, so when an HTTP(S) proxy is configured the connection 
socket is established to the proxy. `_raise_for_unsafe_peer` then validates the 
proxy's public address rather than the destination address, allowing the proxy 
to resolve and fetch an otherwise forbidden internal destination. The peer 
check must either reject proxy use for these imports or validate the 
destination independently through a trusted proxy-aware mechanism.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42930&comment_hash=820b73d8bc7ad0015257277a6850d346011d2a5145746a148397f15fa452196a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42930&comment_hash=820b73d8bc7ad0015257277a6850d346011d2a5145746a148397f15fa452196a&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to