fix(security): validate the Db2 certificate fetch and contain its local-path branch (#14637)
* fix(security): validate the Db2 certificate fetch and contain its local-path branch The IBM Db2 Vector Store and watsonx.data Presto components accept a tenant-controlled certificate location (``ssl_certificate_path`` / ``ssl_ca_file``). Both resolve it through ``db2_security.validate_and_prepare_ssl_certificate``, which had two unguarded branches: - the URL branch downloaded through a raw urllib client with no internal-host policy applied, and followed redirects silently, so a first-hop-only validator would not have helped either; - the local-path branch resolved any absolute/relative path with no containment. Route the download through the existing shared guard ``lfx.utils.ssrf_httpx.ssrf_safe_httpx_get``, which validates the host against the connector SSRF policy, pins the connection to the validated IPs, and re-validates every redirect hop rather than only the first. Reject non-http(s) schemes instead of letting them fall through to the local-path branch, and hold the local path inside the caller's storage scope via ``enforce_local_file_access`` (a no-op unless ``LANGFLOW_RESTRICT_LOCAL_FILE_ACCESS`` is enabled, so the OSS default is unchanged). Cap the buffered response size. No shared code changed -- the fix consumes the existing guards. Both component call sites now pass ``component_file_access_scopes(self)``. Regression coverage in src/bundles/ibm/tests/test_db2_security.py: internal/metadata/RFC1918 targets are refused, an allowed first hop cannot smuggle an internal target via redirect, non-http(s) schemes are rejected, local paths are contained to the caller's scope while in-scope and unrestricted-default reads keep working, and a static check pins the module against regaining a raw urllib network sink. Fixes LE-2247 * chore(bundles): bump lfx-ibm to 0.2.1 for the changed Db2 certificate path Generated by scripts/ci/bundle_release_plan.py update --base-ref origin/release-1.12.0. The release-plan guard requires a version bump whenever releasable bundle source changes, and this PR modifies src/bundles/ibm. * fix(ci): realign the enterprise-hardened profile with the lfx-ibm bump The bundle release-plan guard requires a version bump when releasable bundle source changes, which moved the root pyproject floor to lfx-ibm>=0.2.1. The checked-in release contracts still described >=0.2.0, so test_bundle_profiles went red. Update the reviewed profile and regenerate the lock with manage_bundle_profiles.py compile rather than editing the lock by hand. * fix(security): bound the certificate download and clean up its temp file Two issues on the certificate path. The 1 MiB cap was enforced on an already-buffered body, so an endpoint that passes SSRF validation could still exhaust memory by answering with an unbounded response. ssrf_safe_httpx_get_bounded streams instead and abandons the transfer as soon as the cap is passed, keeping the per-hop redirect revalidation. The watsonx.data Presto component discarded the is_temp flag from validate_and_prepare_ssl_certificate, so an https:// CA file leaked one temporary file per query. _tls_verify now returns ownership and run_query unlinks it in a finally, covering the failure path where leaks accumulate. An operator-supplied local path reports is_temp False and is never removed. Both predate this PR but sit on the certificate path it hardens.
E
Eric Hare committed
186f8923895d91566bb0d58728ce75e70e8d4b6d
Parent: fc3810d
Committed by GitHub <noreply@github.com>
on 8/19/2026, 5:44:01 PM