The vulnerability is a Server-Side Request Forgery (SSRF) in the LangSmith SDK for both Python and JavaScript/TypeScript. The root cause is the improper validation of the baggage HTTP header when creating a distributed tracing context. The RunTree.from_headers (Python) and RunTree.fromHeaders (JS/TS) methods were identified as the vulnerable entry points.
An attacker could send an HTTP request to a service using the vulnerable SDK, including a specially crafted baggage header. This header could specify a langsmith-replicas value containing a malicious api_url. The SDK would parse this header and configure itself to send trace data to the attacker's specified URL.
The patch, identified in commit c8d91099d5546611909b45a04251fba44083025a, rectifies this by introducing an allowlist of safe fields (_HEADER_SAFE_REPLICA_FIELDS) that can be processed from the replica configuration. The code was modified to explicitly filter out sensitive fields like api_url and api_key before they are used, thus preventing the SSRF and data exfiltration. The analysis of the patch files confirms that the logic was changed in python/langsmith/run_trees.py for the Python SDK and js/src/run_trees.ts for the JavaScript SDK.