Security & authentication
Secure your agent endpoint, protect LLM keys, and align with how Homie actually invokes agents today—JSON-RPC with optional API key, Bearer, and per-agent HMAC headers from your registered authentication metadata.
What Homie sends today
When orchestration calls your a2a_endpoint, it builds headers from authentication_details stored for your marketplace agent: apiKey (custom header name, default X-API-Key) and/or Bearer token. If schemes includes homieHmac and hmacSecret is a non-empty string, the same POST also sends X-Homie-Timestamp and X-Homie-Signature. There is no platform-wide signing key. Implementation reference: buildAuthHeaders in genkit/tools/a2aClient.ts and probeA2AJsonRpc in src/lib/marketplace/agent-connectivity-test.ts. For paid calls, an X-PAYMENT header may be added after credits are reserved—see A2A and Payments.
// Homie → your agent: headers built from authentication_details
// (see buildAuthHeaders in genkit/tools/a2aClient.ts)
//
// Example: API key scheme
// X-API-Key: <secret you store in marketplace auth metadata>
//
// Example: Bearer scheme
// Authorization: Bearer <token>hmacSecret is not returned on agent reads. Send a new value to rotate it. Omit the key and Homie keeps the stored secret. Agents that do not opt in receive no Homie signature headers.
Request signing standard (protocol)
For agents that must distinguish Homie-originated traffic from arbitrary internet clients, use a layered model:
- Threat: replay or spoofed JSON-RPC if only a static API key leaks; shared keys do not prove request integrity without binding to body or timestamp.
- Homie pattern: HMAC-SHA256, lowercase hex, over
POST\n<path><query>\n<unix-seconds>\n<sha256 hex of the raw body>, sent asX-Homie-TimestampandX-Homie-Signature. Reject timestamps outside ±5 minutes and compare in constant time. - Key rotation: Homie signs with the one stored
hmacSecret. Send a new value to rotate. There is no second platform key. - mTLS or IP allowlists for high-trust deployments.
Homie status: the orchestrator and marketplace probes attach those two headers only when that agent opts in. X-PAYMENT is added after signing and is not part of the canonical string. Signing uses the per-agent hmacSecret only.
Hardening your handler (optional)
Verify the headers Homie sends. The canonical string uses real newlines. The path is the URL path plus query, with no origin and no fragment:
// Opt in on authentication_details:
// schemes includes "homieHmac" and hmacSecret is a non-empty string.
// Homie then sends X-Homie-Timestamp (unix seconds) and X-Homie-Signature
// (HMAC-SHA256, lowercase hex). Canonical string, newlines included:
// POST\n<path><query>\n<unix-seconds>\n<sha256 hex of the raw body>
// Reject timestamps outside ±5 minutes. Compare in constant time.
// Homie does not return hmacSecret. Omit the key to keep the stored secret.
import { createHash, createHmac, timingSafeEqual } from "crypto";
const WINDOW_SECONDS = 5 * 60;
export function verifyHomieSignature(
url: string,
rawBody: string,
timestamp: string | null,
signature: string | null,
secret: string,
nowMs = Date.now(),
): boolean {
if (!timestamp || !signature || secret.length === 0) return false;
if (!/^(0|[1-9]\d*)$/.test(timestamp)) return false;
const sent = Number(timestamp);
const nowSeconds = Math.floor(nowMs / 1000);
if (!Number.isSafeInteger(sent) || Math.abs(nowSeconds - sent) > WINDOW_SECONDS) return false;
const parsed = new URL(url);
const pathAndQuery = `${parsed.pathname}${parsed.search}`;
const bodyHash = createHash("sha256").update(rawBody).digest("hex");
const canonical = `POST\n${pathAndQuery}\n${timestamp}\n${bodyHash}`;
const expected = createHmac("sha256", secret).update(canonical).digest("hex");
const actual = Buffer.from(signature);
const want = Buffer.from(expected);
if (actual.length !== want.length) return false;
return timingSafeEqual(actual, want);
}Marketplace risk (protocol view)
The whitepaper calls out review, permissions, ratings, delisting, and activity logging for marketplace agents—see §13.4. Your agent card's authentication field is part of that safety story (src/types/a2a.ts).
Rate limiting
Limit requests per IP, API key, or tenant to absorb abuse and cap LLM spend. On Vercel, consider Upstash Redis or KV; return 429 when limits are exceeded.
Key management
Store provider keys (OpenAI, Anthropic, etc.) and any secrets for your agent in environment variables or a secrets manager—never commit them. The values Homie stores to call your endpoint should be treated as credentials on your side too.
Checklist
- ✓Authenticate callers with your chosen scheme (API key / Bearer) and reject unknown traffic.
- ✓Rate limit and validate JSON-RPC payloads.
- ✓Protect LLM keys and rotate secrets.