<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av" -->

---
title: How to Run Untrusted LLM-Generated Code in an Isolated...
description: Untrusted LLM-generated code should run in a sandbox with its own kernel, like a microVM or VM, not just a container. This tutorial walks through creating a...
canonical: https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Run Untrusted LLM-Generated Code in an Isolated Environment With MicroVMs | daily.dev
og:description: Untrusted LLM-generated code should run in a sandbox with its own kernel, like a microVM or VM, not just a container. This tutorial walks through creating a...
og:url: https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av
og:image: https://api.daily.dev/og/posts/azWlOg2aV.png
og:image:alt: How to Run Untrusted LLM-Generated Code in an Isolated Environment With MicroVMs
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Run Untrusted LLM-Generated Code in an Isolated Environment With MicroVMs

**[DigitalOcean Community](https://daily.dev/sources/do_community)** · 19 min read · 0 upvotes · 0 comments

## Summary

Untrusted LLM-generated code should run in a sandbox with its own kernel, like a microVM or VM, not just a container. This tutorial walks through creating a DigitalOcean MicroVM, built on Firecracker, and testing its isolation. A MicroVM with public networking reached the internet, while one in a VPC with no NAT gateway timed out after 10 seconds. A command that exhausted memory was killed with exit code 137 but the MicroVM kept running. Compute costs $0.022 per vCPU-hour and $0.0085 per GiB-hour, so a two-vCPU MicroVM running for 3 minutes costs $0.0039. MicroVMs are in public preview, available only in the MKC1 region as of October 29, 2026.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.digitalocean.com/community/tutorials/untrusted-code-in-microvm>

## Questions this post answers

### What's the best way to isolate code generated by an LLM agent before running it?

Run it inside something with its own kernel, such as a microVM or full VM, rather than just a container, since containers share the host kernel and a kernel vulnerability can let code escape. Add guardrails on top: no secrets inside, no outbound network by default, hard CPU/memory/time caps, and a disposable filesystem destroyed after each run.

_Developers sandboxing AI agent code can track these isolation patterns and tool updates on daily.dev._

### How much does running a DigitalOcean MicroVM cost per hour?

Compute is billed per second only while the MicroVM is running, at $0.022 per vCPU-hour and $0.0085 per GiB-hour of memory. That works out to $0.039 per hour for one vCPU with 2 GiB of memory, or $0.078 per hour for two vCPUs with 4 GiB. A two-vCPU MicroVM running for three minutes total accrues $0.0039 in compute charges, so 1,000 such runs cost about $3.90 before storage and transfer.

_Teams budgeting sandboxed agent execution can compare pricing details like this on daily.dev._

### How do I block a DigitalOcean MicroVM from reaching the internet?

Place the MicroVM in a VPC with no NAT gateway, since a MicroVM in a VPC has no internet access unless a NAT gateway is added. In testing, an outbound curl request from a VPC MicroVM without a NAT gateway timed out after 10 seconds with exit code 28, while the same request from a MicroVM with public networking returned HTTP 200.

_Engineers locking down network egress for agent sandboxes can follow configuration details like this on daily.dev._

## Similar posts on daily.dev

- [DigitalOcean MicroVMs: Fast, isolated compute for your AI agent infrastructure](https://daily.dev/posts/digitalocean-microvms-fast-isolated-compute-for-your-ai-agent-infrastructure-9w8lqeluy) · DigitalOcean · 6 upvotes · 0 comments
- [Run isolated sandboxes with full lifecycle control: AWS Lambda introduces MicroVMs](https://daily.dev/posts/run-isolated-sandboxes-with-full-lifecycle-control-aws-lambda-introduces-microvms-ynja57lql) · AWS · 0 upvotes · 0 comments
- [Your Container Is Not a Sandbox](https://daily.dev/posts/your-container-is-not-a-sandbox-dkskd3kl8) · Lobsters · 26 upvotes · 1 comments
- [AWS Launches Lambda MicroVMs for Isolated Agent and User Code Execution](https://daily.dev/posts/aws-launches-lambda-microvms-for-isolated-agent-and-user-code-execution-gmabbyzxq) · InfoQ · 2 upvotes · 0 comments
- [Sandboxing LLM-Generated Code Needs a Different Threat Model](https://daily.dev/posts/sandboxing-llm-generated-code-needs-a-different-threat-model-akea1hupj) · DigitalOcean Community · 0 upvotes · 0 comments

---

Tags: [#digitalocean](https://daily.dev/tags/digitalocean), [#firecracker](https://daily.dev/tags/firecracker)

[View this post on daily.dev](https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Run Untrusted LLM-Generated Code in an Isolated Environment With MicroVMs","url":"https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av"},"datePublished":"2026-10-30T21:43:36.201Z","dateModified":"2026-10-30T21:44:27.874Z","description":"Untrusted LLM-generated code should run in a sandbox with its own kernel, like a microVM or VM, not just a container. This tutorial walks through creating a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3424a8abc681688db0d19733cc508696?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3424a8abc681688db0d19733cc508696?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"DigitalOcean Community","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DigitalOcean Community","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/c1b9d07730e34ea388c39a498a753d6c","url":"https://daily.dev/sources/do_community"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"digitalocean,firecracker","timeRequired":"PT19M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DigitalOcean Community","item":"https://daily.dev/sources/do_community"},{"@type":"ListItem","position":3,"name":"How to Run Untrusted LLM-Generated Code in an Isolated Environment With MicroVMs"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-run-untrusted-llm-generated-code-in-an-isolated-environment-with-microvms-azwlog2av#faq","mainEntity":[{"@type":"Question","name":"What's the best way to isolate code generated by an LLM agent before running it?","acceptedAnswer":{"@type":"Answer","text":"Run it inside something with its own kernel, such as a microVM or full VM, rather than just a container, since containers share the host kernel and a kernel vulnerability can let code escape. Add guardrails on top: no secrets inside, no outbound network by default, hard CPU/memory/time caps, and a disposable filesystem destroyed after each run. Developers sandboxing AI agent code can track these isolation patterns and tool updates on daily.dev."}},{"@type":"Question","name":"How much does running a DigitalOcean MicroVM cost per hour?","acceptedAnswer":{"@type":"Answer","text":"Compute is billed per second only while the MicroVM is running, at $0.022 per vCPU-hour and $0.0085 per GiB-hour of memory. That works out to $0.039 per hour for one vCPU with 2 GiB of memory, or $0.078 per hour for two vCPUs with 4 GiB. A two-vCPU MicroVM running for three minutes total accrues $0.0039 in compute charges, so 1,000 such runs cost about $3.90 before storage and transfer. Teams budgeting sandboxed agent execution can compare pricing details like this on daily.dev."}},{"@type":"Question","name":"How do I block a DigitalOcean MicroVM from reaching the internet?","acceptedAnswer":{"@type":"Answer","text":"Place the MicroVM in a VPC with no NAT gateway, since a MicroVM in a VPC has no internet access unless a NAT gateway is added. In testing, an outbound curl request from a VPC MicroVM without a NAT gateway timed out after 10 seconds with exit code 28, while the same request from a MicroVM with public networking returned HTTP 200. Engineers locking down network egress for agent sandboxes can follow configuration details like this on daily.dev."}}]}
```

