Files
zeekay 99f2e88361 A tenant's URL is fetched by outbound's rule, and never read as a path
Every address a request names now reaches the network through one client,
github.com/hanzoai/outbound (proxy.Public), which judges the address at
the dial, on the IP the socket connects to, and re-dials and re-judges
every redirect.

What it replaces failed three ways. A message href was checked by
util.Fetchable and then fetched by a different client: the name was
resolved twice, so a rebinding answer passed the check, and a redirect
to 169.254.169.254 was followed unchecked. The check itself was
net.IP's predicates, which admit NAT64 64:ff9b::a9fe:a9fe, 6to4,
Teredo, 198.18/15, 240/4 and the TEST-NETs; proxy/public.go's routable
admitted the same. And /v1/ai/rag/embed's url and /v1/ai/rag/ingest's
files[].url had no check at all: a loopback or metadata URL was
fetched, and a scheme-less string was read off this machine's disk.

A tenant document now goes through txt.GetParsedTextFromAddress (http
and https only, over proxy.Public); txt.GetParsedTextFromUrl is for
addresses this system stored. The Go crawler fetches every page and
robots.txt through proxy.Public, and the browser engine is handed only
addresses outbound.Host finds public.
2026-10-18 22:21:42 -07:00

44 lines
1.8 KiB
Go

// Copyright 2023-2026 Hanzo AI Inc. All Rights Reserved.
// Portions Copyright 2023 The OpenAgent Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package proxy
import (
"time"
"github.com/hanzoai/outbound"
)
// Public is the client for a URL chosen by whoever wrote the request — a document
// a person named, an image in a message, a page to crawl. This process runs
// inside the cluster, where in-namespace service names resolve and
// 169.254.169.254 hands out credentials to anyone who asks, so an unrestricted
// GET on such a URL is a credential read, not a fetch.
//
// It is hanzoai/outbound's client, the one rule every Hanzo service reaches a
// tenant's address by: judged at the dial, on the address the socket connects to
// (so a name that answers public once and private the next time is refused on the
// answer that would have been used), every redirect a new dial judged the same
// way, no proxy, and the IANA special-purpose registries rather than net.IP's
// predicates. A refusal is outbound.ErrRefused.
//
// A test that must reach a loopback server swaps this variable; outbound has no
// switch that turns the rule off.
var Public = outbound.Client(outbound.Options{
Timeout: 60 * time.Second,
Redirects: 5,
Limit: 64 << 20,
})