import { z } from "zod"; import { type ContainmentVerdict } from "../containment/ContainmentProbe.js"; import type { DialOutcome } from "../egress/TcpProbe.js"; /** * The acceptance run's "other routes" case, as the agent's zone observes it * (ADR 0009). The tool runs these from the zone because only the zone can see * them: whether an origin answers a read sent around the gateway, whether a * verifying provider refuses a write the executor did not sign, which MCP * servers answer a dial, which credentials the zone holds, and whether the * cloud metadata endpoint answers. * * Every finding here is the zone's word. The gateway puts them in the signed * report marked as reported by the zone, and its signature does not vouch for * them: a compromised caller can report whatever it likes. They are read the * way the containment probe's findings are read: * * - `REACHABLE` is proof of a hole. Something off the zone answered. * - `CONTAINED` is consistent with enforcement and never establishes it. A * drop looks like an outage. For an origin it also needs the same read to * have succeeded through the gateway, which rules out the origin being down. * - `INCONCLUSIVE` is anything else: a name that did not resolve, a control * read that failed, a status that says neither yes nor no. * * Nothing here holds or sends a credential of the operator's. The direct read * carries no header the module sets; the provider's write is sent with no * signature, then with a key generated for the one request and discarded. A * finding holds statuses, codes, names and kinds: never a header value, a * body, or any part of a credential's value. */ export type ZoneVerdict = ContainmentVerdict; /** Bounds on what the zone may report, which `zoneFindingsSchema` enforces. */ export declare const ZONE_LIMITS: Readonly<{ /** Origins, providers and MCP servers, each. */ targets: 64; credentials: 512; /** A plan label. */ name: 256; /** A host and port, IPv6 brackets included. */ address: 300; /** An environment variable's name, or a file's. */ credentialName: 1024; }>; /** A dial, as `egress/TcpProbe.ts` makes one. */ export type ZoneDial = (host: string, port: number, timeoutMs: number) => Promise; /** One request the zone sends. */ export interface ZoneRequest { readonly method: string; readonly url: string; readonly headers: Readonly>; readonly body: string | null; readonly timeoutMs: number; /** The most of the response body the probe reads. Zero reads none of it. */ readonly maxBodyBytes: number; } export interface ZoneResponse { readonly status: number; /** At most `maxBodyBytes` of the body, as UTF-8. */ readonly body: string; } /** * The zone's HTTP client. Sockets open only under `src/http` and * `src/egress`, so the client is handed in, as the containment probe is handed * its dial. It must connect to the URL's own host, never through a proxy the * environment names (`HTTP_PROXY`, `HTTPS_PROXY`, `NODE_USE_ENV_PROXY`); follow * no redirect; send no header but the ones given and the ones HTTP framing * needs; and reject with an error whose `code` names the failure, `ETIMEDOUT` * when `timeoutMs` passes, as `node:http` does. */ export type ZoneHttp = (request: ZoneRequest) => Promise; export interface ZoneProbeOptions { readonly dial: ZoneDial; readonly http: ZoneHttp; /** Per dial and per request. */ readonly timeoutMs?: number; readonly clock?: () => Date; } export interface OriginProbeOptions extends ZoneProbeOptions { /** The deployed gateway's base URL. The control read goes there, with the origin read's path and query. */ readonly gateway: string; /** Sent on the control read only, such as a tenant key and the run's tag. Never on the direct read. */ readonly gatewayHeaders?: Readonly>; } export type McpProbeOptions = Omit; export interface MetadataProbeOptions extends ZoneProbeOptions { /** The metadata endpoint, `http://169.254.169.254/` unless a test names another. */ readonly url?: string; } /** A target as the plan names it. */ export interface ZoneTarget { readonly name: string; readonly url: string; } /** * A verifying provider and the one write the plan names at its canary * resource. `body` is the JSON text the write sends, or null for none. */ export interface ProviderTarget extends ZoneTarget { readonly write: { readonly method: string; readonly path: string; readonly body: string | null; }; } /** What one request came back with. */ export interface ZoneExchange { /** The HTTP status, or null when no HTTP answer came back. */ readonly status: number | null; /** `ANSWERED` when a status came back; otherwise why not, as a code. Never a message off the network. */ readonly detail: string; } /** * One origin's read, sent around the gateway and through it. `REACHABLE` * when the direct dial was answered, an RST included, whatever the read then * did; `CONTAINED` only when the direct dial met silence and the control read * answered `2xx`; `INCONCLUSIVE` otherwise. */ export interface OriginFinding { readonly name: string; /** The origin's host and port. No path, query or header. */ readonly address: string; /** The read sent straight to the origin, with no credential and no proxy. */ readonly direct: ZoneExchange; /** The same read through the gateway: the control that tells a drop from an outage. */ readonly control: ZoneExchange; readonly verdict: ZoneVerdict; readonly at: string; } /** One write sent to a provider. */ export interface ProviderAttempt extends ZoneExchange { /** The refusal's `reason_code`, when the body was JSON naming one as a code. The body is not kept. */ readonly reason_code: string | null; } /** The write signed with a key the provider cannot know. */ export interface ProviderSignedAttempt extends ProviderAttempt { /** The `keyid` the signature named: generated for this request, held by nobody afterwards. */ readonly key_id: string; } /** `ACCEPTED` is a failure: a write the executor did not sign landed on the operator's canary. */ export type ProviderProbeVerdict = "REFUSED" | "ACCEPTED" | "INCONCLUSIVE"; /** * A verifying provider's answer to writes it must refuse. `REFUSED` when both * answered `4xx`; `ACCEPTED` when either answered `2xx`; `INCONCLUSIVE` * otherwise. The signed write is not sent once the unattested one was * accepted, since the finding is already a failure and a second write would * only change the canary again: `signed` is then null. */ export interface ProviderFinding { readonly name: string; readonly unattested: ProviderAttempt; readonly signed: ProviderSignedAttempt | null; readonly verdict: ProviderProbeVerdict; readonly at: string; } /** An MCP server's host and port, dialled and nothing more: no MCP message is sent. */ export interface McpFinding { readonly name: string; readonly address: string; readonly verdict: ZoneVerdict; /** Why, as a code. */ readonly detail: string; readonly at: string; } /** * The cloud metadata endpoint, read with a bare `GET /`. `REACHABLE` when the * dial was answered; otherwise the containment probe's verdict for the dial. * There is no gateway path to compare with, so `CONTAINED` here has no * control behind it. */ export interface MetadataFinding { readonly address: string; readonly status: number | null; readonly detail: string; readonly verdict: ZoneVerdict; readonly at: string; } /** What a finding says a credential is. A fixed word, never derived from the value's text. */ export declare const CREDENTIAL_KINDS: readonly ["jwt", "pem-private-key", "url-with-userinfo", "aws-access-key", "aws-secret-key", "aws-session-token", "azure-client-secret", "github-token", "credential-file-path", "secret-like", "service-account-token", "web-identity-token", "aws-credentials", "gcp-credentials", "azure-cli-credentials", "kubeconfig", "docker-config", "netrc", "npmrc"]; export type CredentialKind = (typeof CREDENTIAL_KINDS)[number]; /** * A credential the zone holds, by name and kind. `name` is the environment * variable's name, a well-known file's path (`~/` for the home directory), or * `$VARIABLE` for the file a variable names. `own` marks the run's own * credentials, which are reported like any other. */ export interface CredentialFinding { readonly source: "environment" | "file"; readonly name: string; readonly kind: CredentialKind; readonly own: boolean; } /** Everything the zone reports, as the tool sends it to the gateway when the run closes. */ export interface ZoneFindings { readonly origins: readonly OriginFinding[]; readonly providers: readonly ProviderFinding[]; readonly mcp: readonly McpFinding[]; readonly credentials: readonly CredentialFinding[]; /** Null when the plan did not name the metadata endpoint. */ readonly metadata: MetadataFinding | null; } export declare const METADATA_URL = "http://169.254.169.254/"; /** * Read one origin directly and through the gateway. The direct read is a * `GET` of the plan's read URL with no header the probe sets, after a dial to * its host and port; the control is the same path and query through the * gateway, with the gateway's headers. Both are sent whatever the first one * did, so the report shows the gateway path working beside every verdict. * * It establishes that an origin answered from the zone (`REACHABLE`). It * never establishes that the origin is unreachable: `CONTAINED` says only that * the zone met silence while the gateway's path worked. */ export declare function probeOrigin(origin: ZoneTarget, options: OriginProbeOptions): Promise; /** * Send the plan's write to a verifying provider twice, from the zone: first * with no signature, then signed with a key the provider cannot know. A * provider that holds the boundary refuses both with a `4xx`. * * It establishes how this provider answered these two requests. It does not * establish that the provider refuses a grant replayed or altered after * issuance: the zone holds no grant to try, and those refusals are the * build's to show (the provider conformance vectors). */ export declare function probeProvider(provider: ProviderTarget, options: ZoneProbeOptions): Promise; /** * Dial every MCP server's host and port once, in order. No MCP message is * sent, so a finding says a server answered the zone, never that it would * serve a tool call. */ export declare function probeMcp(servers: readonly ZoneTarget[], options: McpProbeOptions): Promise; /** * Read the cloud metadata endpoint with a bare `GET /`: no header, no token, * no path, and a short timeout. Run only when the plan names it. A metadata * service that answers at all is reported as `REACHABLE`, since the headers * it would need to hand out credentials are the zone's to send. */ export declare function probeMetadata(options: MetadataProbeOptions): Promise; export interface CredentialScanOptions { readonly env: Readonly>; /** The home directory the `~/` paths are read under. */ readonly home: string; /** Whether a path exists. Files are never opened. */ readonly exists?: (path: string) => boolean; /** The run's own credentials, by finding name: an environment variable, a file, or `$VARIABLE`. */ readonly own?: readonly string[]; } /** * List the credentials the zone holds, by name and kind, environment first in * name order, then files in a fixed order. * * An environment variable is reported when its value is shaped like a JWT, a * PEM private key, an AWS access key id or a URL with userinfo, when its name * is one whose meaning is known, when its name reads as a credential's, or * when the caller names it as the run's own. A variable with an empty value is * not. The kind is the value's shape when it has one, then the known name's, * then `secret-like`. * * A file is reported when it exists at a path where a credential is kept: the * Kubernetes service-account token, the AWS, gcloud and Azure CLI stores, * `~/.kube/config`, `~/.docker/config.json`, `~/.netrc`, `~/.npmrc`, and the * files `GOOGLE_APPLICATION_CREDENTIALS` and its kin name. Files are never * opened, so a file that holds no credential is reported too; and a variable * that names a file is reported as `$VARIABLE`, since its value could be the * credential itself rather than a path. * * It establishes what the zone holds at those names. It does not establish * that the zone holds nothing else: a credential under an ordinary name, in an * ordinary file, or in a process's memory is not seen. */ export declare function scanCredentials(options: CredentialScanOptions): CredentialFinding[]; /** * The zone's findings, as the gateway parses them when a run closes. Closed * at every level, bounded in every array and string, and with no field that * can carry a credential's value: a kind is one of `CREDENTIAL_KINDS`, a * detail and a reason are codes. It checks the form of what the zone said, * not its truth. */ export declare const zoneFindingsSchema: z.ZodObject<{ origins: z.ZodArray; detail: z.ZodString; }, z.core.$strict>; control: z.ZodObject<{ status: z.ZodNullable; detail: z.ZodString; }, z.core.$strict>; verdict: z.ZodEnum<{ REACHABLE: "REACHABLE"; CONTAINED: "CONTAINED"; INCONCLUSIVE: "INCONCLUSIVE"; }>; at: z.ZodISODateTime; }, z.core.$strict>>; providers: z.ZodArray; reason_code: z.ZodNullable; detail: z.ZodString; }, z.core.$strict>; signed: z.ZodNullable; reason_code: z.ZodNullable; detail: z.ZodString; }, z.core.$strict>>; verdict: z.ZodEnum<{ REFUSED: "REFUSED"; INCONCLUSIVE: "INCONCLUSIVE"; ACCEPTED: "ACCEPTED"; }>; at: z.ZodISODateTime; }, z.core.$strict>>; mcp: z.ZodArray; detail: z.ZodString; at: z.ZodISODateTime; }, z.core.$strict>>; credentials: z.ZodArray; name: z.ZodString; kind: z.ZodEnum<{ jwt: "jwt"; "pem-private-key": "pem-private-key"; "url-with-userinfo": "url-with-userinfo"; "aws-access-key": "aws-access-key"; "aws-secret-key": "aws-secret-key"; "aws-session-token": "aws-session-token"; "azure-client-secret": "azure-client-secret"; "github-token": "github-token"; "credential-file-path": "credential-file-path"; "secret-like": "secret-like"; "service-account-token": "service-account-token"; "web-identity-token": "web-identity-token"; "aws-credentials": "aws-credentials"; "gcp-credentials": "gcp-credentials"; "azure-cli-credentials": "azure-cli-credentials"; kubeconfig: "kubeconfig"; "docker-config": "docker-config"; netrc: "netrc"; npmrc: "npmrc"; }>; own: z.ZodBoolean; }, z.core.$strict>>; metadata: z.ZodNullable; detail: z.ZodString; verdict: z.ZodEnum<{ REACHABLE: "REACHABLE"; CONTAINED: "CONTAINED"; INCONCLUSIVE: "INCONCLUSIVE"; }>; at: z.ZodISODateTime; }, z.core.$strict>>; }, z.core.$strict>; //# sourceMappingURL=ZoneProbes.d.ts.map