ThisCalculator

Everyday

Two Trust Domains: Safer AI Agents Guide

Updated · Standard formula, shown below

This guide explains how connecting two separate trust domains makes governed AI agents safer to use. You’ll learn the architecture pattern, the step-by-step setup, and common pitfalls—so you can deploy agents that act within clear boundaries and are auditable.

What You’ll Need

  • Two distinct environments or platforms (e.g., a cloud tenant and an on-premises cluster, or two separate cloud accounts) that can communicate over a secure network.
  • Identity and access management (IAM) in both domains, with the ability to create service accounts or roles.
  • Policy management tools (e.g., OPA, Cedar, or cloud-native policy services) in at least one domain.
  • Logging and monitoring access in both domains (e.g., CloudTrail, Azure Monitor, or equivalent).
  • Basic understanding of OAuth 2.0, OIDC, or mutual TLS for cross-domain authentication.

Step-by-Step

  1. Define the trust boundary for each domain. Decide what each domain is allowed to do. For example, Domain A holds user data, Domain B runs the AI model. Write down the data flow and the actions each domain can perform.
  2. Set up separate identity providers (IdPs) or separate realms. Each domain should have its own identity source, even if they share a common root of trust. This ensures that a compromise in one domain does not automatically grant access to the other.
  3. Establish a federation relationship. Use OIDC or SAML to federate the two IdPs. Configure the relying party (the domain that calls the other) to accept only tokens from the other domain’s IdP, and validate the issuer and audience.
  4. Create service accounts with least privilege. In each domain, create a service account (or role) that the AI agent will use. Grant only the permissions needed for the agent’s specific tasks—no more. For example, if the agent only reads data, do not give it write permissions.
  5. Implement a policy engine in each domain. Deploy a policy-as-code solution (like OPA) in both domains. Write policies that define what the agent can do, under what conditions (e.g., time of day, data classification), and what it must not do.
  6. Exchange policy information via signed claims. When the agent calls across domains, include a signed policy claim in the token (e.g., a JWT claim that states the agent’s allowed actions). The receiving domain validates this claim against its own policy before executing any action.
  7. Enable mutual TLS or mTLS for service-to-service calls. This ensures that both ends of the communication are authenticated. Use certificates issued by a private CA that both domains trust.
  8. Add a human approval step for high-risk actions. For actions like deleting data or transferring money, require a human in the loop. The agent sends a request, the human approves it in a separate control plane, and only then does the action execute.
  9. Log all cross-domain calls. In both domains, log every request the agent makes, including the token, the action, the result, and the policy decision. Store logs in a tamper-evident location.
  10. Test with a sandbox scenario. Run a test where the agent attempts a forbidden action (e.g., reading a file it shouldn’t). Verify that the policy engine in the receiving domain blocks it and that the log records the denial.
  11. Monitor and audit regularly. Set up alerts for policy violations, unusual access patterns, or failed authentication. Review logs at least monthly to ensure the agent is not drifting from its intended behavior.

Common Mistakes

  • Using the same IAM role across both domains. This defeats the purpose of separate trust domains—if one domain is compromised, the attacker gets the same privileges in the other.
  • Not validating the token issuer. If you accept any JWT, an attacker can forge a token. Always validate issuer, audience, and signature.
  • Overly broad policies. Writing policies that allow “*” on resources is a common error. Be specific: allow only the exact actions and resources the agent needs.
  • Skipping the human approval step. For high-risk actions, automation can be dangerous. Always require a human check.
  • Ignoring log retention. If you don’t store logs, you can’t audit after an incident. Keep logs for at least 90 days.

Tips

  • Start with a read-only agent. Prove the architecture works with a simple data-reader before adding write capabilities.
  • Use short-lived tokens. Set token expiry to a few minutes, so a stolen token is less useful.
  • Automate policy testing. Use CI/CD to test policy changes against a set of expected allow/deny cases.
  • Document the trust model. Write down who trusts what and why. This helps future maintainers and auditors.
  • Consider a service mesh. Tools like Istio or Linkerd can handle mTLS and policy enforcement for you, reducing manual configuration.

Troubleshooting

  • Agent gets 401 Unauthorized. Check the token expiry, issuer, and audience. Also verify the service account exists in the target domain.
  • Policy denies a valid request. Review the policy rules—maybe the condition (e.g., time of day) is not met. Test the policy with a dry-run tool.
  • Logs are incomplete. Ensure logging is enabled on both sides, and that the agent’s service account has permission to write logs. Check if logs are being truncated.
  • mTLS handshake fails. Verify that the CA certificates are trusted on both sides, and that the service’s hostname matches the certificate’s SAN.
  • Human approval never triggers. Ensure the approval system is connected to the same policy engine, and that the agent is configured to pause when a high-risk action is detected.

Frequently Asked Questions

What exactly is a trust domain?

A trust domain is a security boundary where all entities (users, services, devices) are managed by a single administrator and follow a common set of policies. Two trust domains means two separate boundaries, each with its own identity and policy control.

Why not just use one trust domain?

One domain is simpler but creates a single point of failure. If an attacker compromises the domain, they get everything. Two domains force an attacker to break into both, and limit the blast radius of any single breach.

Do I need a separate IdP for each domain?

Not necessarily, but it’s recommended. You can use a single IdP with separate realms or tenants, but that still gives the IdP admin power over both. Separate IdPs (or at least separate admin roles) provide better isolation.

How do I handle cross-domain data sharing?

Use federated tokens that carry claims about the data classification and the allowed purpose. The receiving domain enforces its own policy on those claims, so data is only used as intended.

Can I use this pattern with cloud AI services?

Yes. For example, you can have your on-premises domain call a cloud AI service, with mTLS and OIDC federation. The cloud service validates your token and applies its own policy before running the model.

What if I need to revoke access quickly?

In each domain, you can disable the service account or revoke the token’s refresh token. Also, you can update the policy to deny all actions from that agent immediately. Logs will show the revocation time.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.