Per-tenant storage for multi-tenant AI agents: a subdirectory is not a security boundary
If you run a multi-tenant agent product, every customer's agent eventually needs somewhere to keep files: uploaded documents, a cloned repo, intermediate results, a SQLite database it builds up over days. The obvious first design is one shared volume with a directory per tenant. It works in a demo, and it's the wrong isolation boundary once the agent runs code you didn't write. This post walks…
When building a multi-tenant AI agent platform, designing a secure storage solution is critical to prevent unauthorized access to other tenants' data. A common approach is to use a shared volume with a subdirectory per tenant, but this does not provide adequate isolation. Running the sandbox with a credential that covers the entire volume allows the agent to access all directories, even if it only needs access to its own tenant's directory.
Permissions within POSIX file systems are also insufficient to protect tenant data from untrusted code that can run with elevated privileges inside the sandbox.
The author explores several options for achieving true isolation between tenants:
1. Utilizing Amazon EFS with an access point per tenant ensures that clients can only access the root directory and specific POSIX identity assigned to their access point. Proper IAM policies need to be written to restrict access. However, this requires setting up an EFS for each tenant and managing policies for each access point.
2. Using an S3 prefix per tenant with short-lived credentials allows for strong isolation at any scale. Agents would need to download/upload files or run a FUSE client, but most S3 FUSE clients have limitations regarding in-place edits, renames, and SQLite databases.
3. Creating a volume per tenant is the cleanest approach as it provides a clear boundary. Block volumes like EBS can provide this isolation but are limited to a single machine and don't suit the ephemeral nature of agent sandboxes. An EFS file system per tenant is also viable but can quickly reach the quota of 1,000 file systems per region.
4. Using a disk per tenant in Archil is the optimal solution. Each disk is isolated with scoped credentials that cover only that disk, including its branches and checkpoints. Creating a disk is a single API call and mounting it is automated. Agents can mount only their disk, ensuring files survive sandbox restarts and are accessible across different providers' sandboxes.
Storage costs are based on the actual data held, not the number of disks, and managing idle tenants is economical. Deleting a tenant involves revoking tokens and deleting the disk, with the option to transfer data to the tenant's own bucket if present.
The key takeaways are:
- A subdirectory per tenant is not sufficient for security boundaries.
- Strong isolation requires isolated storage per tenant, whether through EFS, S3 prefixes, disks, or a tailored solution like Archil's.
- Proper credential management and expiration are crucial to maintain isolation.
- The choice of isolation mechanism depends on the specific use case, tenant count, and required performance.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to