Skip to content

security(connectors): six connectors with user-configured hosts bypass the SSRF guard — needs a deployment-gated private-network opt-in #13625

Closed

Description

@mrveiss

Part of #13623. Found comparing our connector egress against an external implementation of the same problem (docs/research/connector-credential-egress-audit.md).

Not a duplicate of #13204 — that issue is scoped to the four browser execution paths and never mentions connectors or integrations. This is a separate family.

Connectors with a user-configured host reach it over bare aiohttp, with no URL guard

These read a host from stored connector config and string-concatenate it into the request URL:

connector config key concat site
knowledge/connectors/confluence.py:92 base_url :225
knowledge/connectors/jira.py:100 base_url :240
knowledge/connectors/gitlab.py:134 gitlab_url :135
knowledge/connectors/gitlab.py:486 (Gitea) gitea_url :487
knowledge/connectors/nextcloud.py:94 nextcloud_url :113
integrations/base.py:125-149 per-integration builds a bare aiohttp.ClientSession per request

Grepped all of the above for is_public_url|ssrf_guard|pinned_connector: zero hits. The guard exists (autobot_shared/security/ssrf_guard.py) and simply is not wired into this family.

Why it was probably never guarded — and the fix that resolves the conflict

A self-hosted Confluence / GitLab / Nextcloud instance legitimately lives on a private network, so applying is_public_url as-is would break the feature it is meant to protect. That is very likely why nobody added it.

The pattern that resolves this conflict is a deployment-gated opt-in:

  • A deployment flag permits RFC-1918 / private targets while still hard-blocking reserved, loopback, link-local, and cloud-metadata addresses — those stay blocked even with the flag on.
  • The opt-in applies only to the trusted, operator-configured instance host. User-supplied content/download URLs are validated public-only, unconditionally, with a separate non-private-aware fetcher.

Delta we need

autobot_shared/url_safety.py:88-96 collapses private / loopback / link-local / multicast / reserved into a single boolean:

def _ip_is_public(ip) -> bool:
    if ip.is_private or ip.is_loopback or ip.is_link_local or ip.is_multicast or ip.is_reserved or ip.is_unspecified:
        return False

"Private" has to become separable from the rest so it can be selectively permitted while the others stay hard-blocked.

Scope

  1. Split _ip_is_public; add allow_private: bool = False threaded through is_public_url / is_public_url_async / resolve_safe_ip_async.
  2. Add the deployment flag (default off).
  3. Validate the configured base URL once at config-store time (not per request) with the opt-in applied.
  4. Route the six connectors' egress through the guarded fetch.
  5. Add the rule to docs/developer/CLAUDE_RULES.md: all outbound connector/integration HTTP goes through the guarded fetch; the private-network opt-in covers the operator-configured instance host only, never user-supplied URLs. The rule currently lives only in a docstring inside ssrf_guard.py, which is plausibly why six connectors were written against bare aiohttp without anyone noticing.

Acceptance criteria

  • _ip_is_public split; private separable from reserved/loopback/link-local/metadata
  • Deployment flag defaults off; loopback/link-local/metadata blocked in both states
  • All six sites route through the guarded fetch
  • Test: flag off → private base URL rejected; flag on → private base URL accepted, metadata address still rejected
  • Test: the opt-in does not leak into content-URL fetching
  • Rule block landed in CLAUDE_RULES.md

Activity

  1. mrveiss commented on Aug 8, 2026

    @mrveiss
    OwnerAuthor

    Item 4's premise has changed since filing — reporting before implementing

    The issue describes six connectors that "reach it over bare aiohttp" and build "a bare aiohttp.ClientSession per request". That is no longer what the code does. Measured on current Dev_new_gui:

    bare aiohttp.ClientSession( in knowledge/connectors/ + integrations/   ->  1
       (autobot-backend/knowledge/connectors/oauth_flow.py:188)
    

    Confluence, Jira, GitLab, Gitea and Nextcloud now go through the shared client — get_http_client().tracked_request(...) — and import aiohttp only for BasicAuth, ClientTimeout and exception types. So the six sites are one seam, not six.

    The finding itself still stands: autobot_shared/http_client.py contains zero references to is_public_url, pinned_connector or ssrf_guard. The egress is unguarded. Only the shape of the fix changes.

    Why I am not simply guarding the shared client

    tracked_request delegates to HTTPClientManager.request(), which is the single choke point — and that is exactly the problem:

    files using the shared client repo-wide   103
       of which connectors/integrations        22
    

    Guarding request() wholesale would apply connector egress policy to 81 unrelated call sites, including internal service-to-service traffic (NPU workers, SLM nodes) that legitimately targets private addresses. With the flag off by default, that would break internal traffic the moment it merged; with the flag on, it would silently widen egress policy for everything.

    Recommendation

    A guarded entry point that connectors opt into, rather than a blanket change to a shared utility:

    1. Add allow_private: bool | None = None to HTTPClientManager.request(), defaulting to no guarding at all — behaviour identical to today for all 103 callers.
    2. When passed explicitly, resolve and pin the URL through ssrf_guard with that opt-in, per Rule 8.
    3. The 22 connector/integration call sites pass it; nothing else changes.

    That keeps the fix at one seam, leaves 81 callers untouched, and makes "this request is guarded" visible at the call site instead of implicit in a shared default.

    The alternative — guarding request() for everyone and adding escape hatches for internal traffic — inverts the default in a way that fails open for anything that forgets to opt out, which is the failure mode Rule 8 exists to prevent.

    Proceeding on the recommendation unless told otherwise; recording it here rather than deciding it silently, since it deviates from the issue's prescribed scope.

  2. mrveiss commented on Aug 8, 2026

    @mrveiss
    OwnerAuthor

    Item 4 started — the two URL classes, wired distinctly

    base.py now carries the policy decision once, so no call site re-derives it:

    def instance_host_egress() -> bool:   # operator-configured host — opt-in applies
    CONTENT_URL_EGRESS = False            # anything else — public-only, always

    Wired so far, each classified by where the URL actually comes from:

    site URL origin policy
    confluence.py:229 instance base_url instance_host_egress()
    jira.py:244 instance base_url instance_host_egress()
    audio_connector.py:381 arbitrary download target CONTENT_URL_EGRESS

    That last row is the distinction Rule 8 exists for. _download_direct_url(url, ...) takes its URL as a parameter, not from configuration — if it inherited the instance-host exemption, a document could name 169.254.169.254 and turn the connector into an SSRF vector against the operator's own network.

    Verified end-to-end through the shared client rather than by inspection:

    CONTENT_URL_EGRESS   = False
    instance_host_egress = False   (flag default off)
    
    blocked as a content URL: http://169.254.169.254/latest/meta-data/
    blocked as a content URL: https://10.0.0.5/file.mp3
    
    knowledge/connectors/    362 passed
    url_safety + http_client  74 passed
    flake8                     clean
    

    Note on nextcloud.py:165

    file_url = urljoin(self._webdav_base, encoded_path) derives from the instance base, so it is instance-host traffic despite looking like a content download. Classifying it by name rather than by origin would have got it wrong in the safe-looking direction. Remaining sites (nextcloud x3, gitlab, gitea, and the integrations) follow next.

  3. 12 remaining items

  4. added this to the Backlog milestone on Sep 12, 2026
  5. modified the milestones: Backlog, v0.11.0 on Sep 14, 2026
  6. mrveiss commented on Sep 20, 2026

    @mrveiss
    OwnerAuthor

    Session ending (weekly token limit, owner call to drop concurrency). Not started -- no branch checks, no code reading done on this issue yet. Handing off as-is so the next session doesn't assume any progress here.

    Context that may help: this issue was in a batch of 15 open security issues with unlanded branch work, dispatched by autobot-ai-df (queue coordinator) as part of a repo-wide stale-branch audit. Before touching any assigned branch, verify supersession first (compare each touched file's blob at branch tip against origin/main -- several branches in this same batch turned out to be stale pre-merge duplicates of already-merged PRs). Also check autobot-ai-df's trap.json scan (revival hazard: a branch whose removed lines cite an issue number lower than a later fix to the same file) before reviving anything -- this issue may or may not be on it, worth checking fresh.

  7. mrveiss commented on Oct 4, 2026

    @mrveiss
    OwnerAuthor

    Closing — every criterion verified against merged main @ 8bd2d70b04.

    The guard is split so private is separable from hard-blocked. autobot_shared/url_safety.py:138

    def _ip_is_public(ip, *, allow_private: bool = False) -> bool:
        if _ip_is_hard_blocked(ip): return False      # loopback/link-local/metadata, always
        if _ip_is_private(ip):      return allow_private

    Hard-blocked is checked first and unconditionally, so the opt-in cannot reach loopback, link-local or the cloud metadata address in either state. Threaded through is_public_url (:152) and is_public_url_async (:203).

    The deployment flag defaults off. autobot_shared/ssot_config.py:2181 — connector_private_network_egress: bool = Field(default=False, alias="AUTOBOT_CONNECTOR_PRIVATE_NETWORK_EGRESS"). url_safety_test.py:353-354 asserts each hard-blocked kind is refused with the flag both off and on, which is the assertion that makes the split safe rather than merely present.

    All six sites route through the guarded fetch, each passing guard_egress=instance_host_egress() on get_http_client().tracked_request(...): confluence.py:236, jira.py:252, gitlab.py:416 (GitLab) and :782 (Gitea), nextcloud.py:130/:180/:282, integrations/base.py:151.

    Tests cover both directions and the leak. http_client_test.py:289 test_egress_guard_permits_private_only_with_the_opt_in; and knowledge/connectors/egress_policy_test.py:43 test_content_urls_never_use_the_instance_host_opt_in — the one that matters most, since the risk of an instance-host opt-in is that it silently widens content fetching too.

    The rule is recorded where the next author meets it: docs/developer/CLAUDE_RULES.md:368, Rule 8 — every outbound connector/integration request must declare an egress policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions