Skip to content

Validate Gateway sidecar mTLS through a mandatory Squid CONNECT proxy #46

Description

@sodre

Could you validate the Gateway in sidecar mode when a Squid HTTP CONNECT proxy is the workload’s only route to an external mTLS site? If this requires a Gateway change, please use this issue to track support and a regression test.

In FINsight, the MCP tool would use a Gateway on loopback in the same Fargate task. The task can reach the internal Broker directly. For external HTTPS it must reach Squid through an internal network load balancer. Squid authorizes the requested hostname and port, then passes the TLS bytes through. The Gateway must verify the origin certificate and perform the desktop-approved client handshake inside that tunnel.

MCP tool → Gateway sidecar → internal NLB → Squid:3128 → protected site:443
                ↕                            CONNECT host:443
              Broker ↔ paired desktop Companion

Our v0.2.1 Fargate run verified two concurrent grants with a shared Gateway and a site in the same task. It did not exercise Squid. In the tagged release the Gateway opens a TCP connection to the pinned destination. We haven’t verified an upstream proxy configuration for that connection. Previous qualification · v0.2.1 origin connection

Requested validation

  1. In a repeatable Compose test, give the Gateway access to the Broker and Squid, and put the protected site on a network reachable only through Squid. Configure Squid to allow CONNECT to the test hostname and port, with TLS interception disabled.
  2. Pair the Companion, approve the identity, and have the workload read a fresh flag through the sidecar. Correlate three observations from that run: Squid logged a successful CONNECT for the hostname and port, the origin saw the approved client certificate, and the workload received the site’s flag.
  3. Deny the destination at Squid, then separately make the proxy unavailable. Both requests should fail without a direct retry reaching the origin. With CONNECT allowed, verify that the Gateway still rejects an origin certificate for the wrong hostname.
  4. Please document how to configure the Gateway’s outbound proxy and where destination DNS resolution and address-policy enforcement occur when Squid resolves the CONNECT hostname. We’d like to repeat the passing configuration on Fargate 1.4.0 with worker_sandbox: "filter" and check the flag in FINsight chat.

Activity

  1. added
    origin:site
    triage:needs-triage
    on Nov 22, 2026
  2. added theissue type on Nov 22, 2026
  3. sodre commented on Nov 22, 2026

    @sodre
    MemberAuthor

    This was generated by AI during triage.

    Triage outcome

    Category: enhancement
    Summary: The Gateway can reach a protected site through an operator's egress proxy, with a regression test and a Compose qualification against a real Squid.

    Why this is for a human: the next step is a spec with its tickets, which the owner starts. The decisions below were made with the owner during triage and are written up as ADR 0003 (proposed, not yet merged).

    Current behavior:
    Confirmed by reading the code at v0.2.1. The Gateway has no setting for a proxy on the leg to the site, and its config refuses unknown fields. The supervisor resolves the site's name itself, checks every DNS answer against the address policy, and opens a direct TCP connection to the pinned address. No proxy environment variable is read for that leg. Where the only route out is a proxy, the Workload's CONNECT returns 502 with Countersign-Error: upstream_failure, possibly only after the 120-second deadline.

    Desired behavior:

    • Egress proxy is the term: the operator's HTTP proxy that the Gateway must go through to reach a protected site.
    • One egress proxy per Gateway, in a top-level egress_proxy URL. The leg is a plain-text HTTP CONNECT with no proxy authentication. An https URL, or one with credentials, is refused at startup.
    • When egress_proxy is set, every destination goes through it unless its rule says "egress": "direct". When it is absent, nothing changes.
    • On a proxied route the Gateway sends CONNECT with the site's canonical name and port and resolves nothing. The egress proxy resolves the name and its ACLs carry the address policy. private_networks, denied_networks and the special-use blocks are not applied to the site's address on that route.
    • A site still needs its destination rule at the Gateway and the Broker, a grant and its leases. The Gateway still verifies the site's certificate against the hostname and the rule's roots before any signature.
    • A rule with private_networks on a proxied route is refused at startup, with an error that names the rule and both fixes. A private site through the egress proxy takes a rule without private_networks. Startup logs which destinations leave address policy to the egress proxy.
    • The egress proxy's own address is a DNS name and port, resolved through system DNS on every connection, exempt from private_networks and the special-use blocks. denied_networks still applies to it.
    • The Gateway never falls back to a direct connection. A refusal, an unreachable proxy and a timeout each return 502. Countersign-Error says proxy_denied when the egress proxy answered with a refusal and proxy_unavailable otherwise. The proxy's response body is not passed to the Workload.

    Key interfaces:

    • Gateway config: new top-level egress_proxy, new per-destination egress.
    • The Countersign-Error response header: two new values, proxy_denied and proxy_unavailable.
    • The Gateway's runtime test (real Gateway processes against a test-only grant authority and mTLS site) gains a test-only CONNECT proxy.
    • The Compose demo and its --verify mode gain a variant with a real Squid.

    Acceptance criteria:

    • The runtime test passes a request through a test-only CONNECT proxy and the site sees the approved client certificate.
    • With the proxy refusing the destination, the Workload gets 502 with proxy_denied, and the site sees no connection.
    • With the proxy unreachable, the Workload gets 502 with proxy_unavailable, and the site sees no connection.
    • With CONNECT allowed, the Gateway rejects a site certificate for the wrong hostname.
    • A config with private_networks on a proxied rule, an https proxy URL, or a proxy URL with credentials does not start, and each error names the cause.
    • The Compose variant puts the site on a network only Squid reaches, with TLS interception off. From one run, --verify correlates Squid's log line for the CONNECT to the hostname and port, the certificate fingerprint the site saw, and the flag the Workload read. It also checks the Squid refusal and the unavailable proxy.
    • The operator guide and the configuration reference say how to set the egress proxy, where name resolution and address policy happen on each route, and show example Squid ACLs, including blocks for metadata, link-local and loopback addresses.
    • ADR 0003 is accepted and the design record's resolution paragraph names both routes.

    Out of scope:

    • Repeating the run on Fargate 1.4.0 with the filter sandbox. FINsight does that from the documented Compose configuration; Countersign's part ends at Compose for now.
    • Proxy authentication and a TLS-wrapped proxy leg.
    • More than one egress proxy, or a proxy URL per rule.
    • Letting the egress proxy alone decide which sites the Gateway admits: An operator can let the egress proxy decide which sites a Gateway admits #48.
    • Running the Squid qualification in a hosted workflow. It is run by hand, as the Compose demo is today.
  4. added
    triage:ready-for-human
    and removed
    triage:needs-triage
    on Nov 22, 2026
  5. sodre commented on Nov 24, 2026

    @sodre
    MemberAuthor

    #55 is merged (d5b15ba). The Gateway can now reach a protected site through an HTTP CONNECT egress proxy. You set it once, as egress_proxy in the Gateway configuration. To repeat the qualification on Fargate:

    • The setup that passed: docs/develop.md, "Qualify the Gateway against a real Squid". Its passing compose_demo.py --squid --verify run is on A maintainer can qualify the Gateway against a real Squid in the Compose demo #52. It uses Squid 6.14, pinned by digest, and the Gateway has no direct route to the site.
    • What to configure, and what Squid's ACLs must block: docs/operate.md, "Reach sites through an egress proxy". If the site is private, add the guide's deny for every address outside the site's prefix. Squid's dst matches when any one of a name's addresses is in its list.
    • When it fails: the 502's Countersign-Error header reads proxy_denied, upstream_failure or proxy_unavailable. The operator guide's troubleshooting table says what each means.

    The Fargate 1.4.0 run was outside #49's scope. It's the step left on this issue.

  6. sodre commented on Nov 25, 2026

    @sodre
    MemberAuthor

    The egress proxy is released in v0.2.2. Test with this Gateway image:

    ghcr.io/zeroae/countersign-gateway:v0.2.2
    ghcr.io/zeroae/countersign-gateway@sha256:0a524306ad0a62ef9dce00af365be1b80ada10a6ba0fb9b787a5ec4113c6787c
    

    The image is built for linux/amd64. Besides #55, which added egress_proxy, v0.2.2 includes:

    The setup, the ACLs and the error values in my last comment still apply.

    Once your Fargate run passes behind your Squid, close this issue. If it fails, post the Countersign-Error value and the Gateway's log lines from that request here.

  7. sodre commented on Nov 25, 2026

    @sodre
    MemberAuthor

    FINsight reporter qualification passed on AWS ECS Fargate 1.4.0, Linux x86-64, with Countersign v0.2.2 and Squid 6.14. On November 25, the installed Companion approved a desktop identity and the FINsight assistant displayed the origin’s fresh flag.

    The FINsight mock MCP tool and Gateway sidecar shared a Fargate task and communicated over loopback. The MCP tool trusted the public CA generated by that sidecar. The Gateway used worker_sandbox: "filter" and egress_proxy pointed to a temporary internal AWS Network Load Balancer on port 3128. Squid and the mTLS origin each ran in a separate Fargate task. The origin allowed port 9444 only from Squid’s security group. FINsight chat, control plane, runner and mock model backend ran in local Docker Compose. The released ARM64 Companion used a disposable PKCS#11 identity on the desktop.

    Check Evidence from the same request
    Published Gateway x86-64 image sha256:e56403fd9129c777590cd4b01b2fd8f61b8ba2e9ca616be9ce190b88439357ab
    Gateway startup Gateway worker sandbox "filter": non-dumpable, Landlock ABI v2, seccomp allow-list
    Direct route A TCP probe from the MCP task to the origin IP and port timed out.
    Desktop approval The Companion showed the FINsight investigation cs-squid-2b865132dca28a and destination flag-d8e577b74d5d6d.test:9444.
    Squid TCP_TUNNEL/200 … CONNECT flag-d8e577b74d5d6d.test:9444
    Origin TLS 1.3 arrived from Squid. The peer certificate SHA-256 was 1487eca81c639cb32e501316726afe1bc5a97646e06e59abff8de4cb878e69aa, matching the identity provisioned on the desktop.
    FINsight chat After COUNTERSIGN-FLAG, the rendered assistant reply and the independently generated site flag both hashed to 693d4d2a1d8cf01c725d4e95027813081639398a534b7144feb7e4883d51e432.

    The Fargate run used the upstream qualification ACL scoped to the demo hostname, port and origin IP. It exercised the successful approval and the blocked direct route. The live FINsight registry-backed ACL was outside this run. The denial and proxy-outage cases have separate upstream Compose evidence. AWS confirmed deletion of the temporary qualification stack.

  8. added a commit that references this issue on Nov 25, 2026
    5988288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    origin:sitetriage:ready-for-human

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions