{"id":97206,"date":"2025-03-10T07:00:00","date_gmt":"2025-03-10T14:00:00","guid":{"rendered":""},"modified":"2025-04-21T08:09:19","modified_gmt":"2025-04-21T15:09:19","slug":"build-a-hyperlight-c-guest-to-securely-execute-javascript","status":"publish","type":"post","link":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/","title":{"rendered":"Build a Hyperlight C guest to securely execute JavaScript"},"content":{"rendered":"\n<p><a href=\"https:\/\/aka.ms\/hyperlight-dev\">Hyperlight<\/a> is an open-source project for safely executing untrusted code inside hardware-protected micro-virtual machines (micro-VMs) with extremely small size and low latency. (Earlier articles have <a href=\"https:\/\/aka.ms\/hyperlight-announcement\">introduced Hyperlight<\/a> and showed <a href=\"https:\/\/aka.ms\/hl-kubecon-demo-post\">a Rust-based example of how it can be used effectively<\/a>.) As opposed to general purpose virtual machine managers (VMMs), Hyperlight does not boot any operating system inside the hardware-protected guest and does not initialize any devices, which is how the cold start time of Hyperlight can be well less than 2ms.<\/p>\n\n\n\n<p>This performance benefit, however, doesn\u2019t come for free. You need to create a \u201cguest\u201d application that runs inside a micro-VM and a host application that uses the Hyperlight library to execute the guest application in a hypervisor (without an operating system).<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-text-align-center wp-element-button\" href=\"https:\/\/aka.ms\/hyperlight-dev\">Join the Hyperlight community<\/a><\/div>\n<\/div>\n\n\n\n<p>This article will show you how to do all this and have fun with some JavaScript. We\u2019ll write the guest program using the QuickJS JavaScript engine in C using the Hyperlight-guest C API, we\u2019ll write the host CLI application using Rust, and then you can pass any JavaScript file to the program for execution safely inside a micro-VM. If you\u2019re just interested in running the final code, you can find it <a href=\"https:\/\/aka.ms\/hyperlight-quickjs\">here<\/a>. That repository uses <a href=\"https:\/\/github.com\/casey\/just\"><code>just<\/code><\/a> commands to make building and running easier, but this article spells out the underlying commands explicitly to be clear.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setup\">Setup<\/h2>\n\n\n\n<p>To successfully follow this post, please ensure you have the following prerequisites:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An x86_64 machine running either Linux or Windows with Windows Subsystem for Linux (WSL).<ul><li>Hyperlight requires the KVM Linux kernel module.<\/li><\/ul>\n<ul class=\"wp-block-list\">\n<li>If operating on a virtual machine, nested virtualization must be activated.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Rust installed with version 1.80 or higher.<\/li>\n\n\n\n<li>Clang (versions 14 and 18 have been tested).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"building-the-application\">Building the application<\/h2>\n\n\n\n<p>You can clone and build the entire application from the repository. However, let\u2019s walk through what happens.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-the-hyperlight-guest\">Creating the Hyperlight guest<\/h2>\n\n\n\n<p>To execute JavaScript inside a Hyperlight micro-VM, we\u2019ll use the QuickJS JavaScript engine. Let\u2019s begin by writing a simple guest function which takes in arbitrary JavaScript code as a string, executes the given code using QuickJS, and then returns the result as a string. Create a new folder called <code>hyperlight-demo<\/code>. This folder will contain all the code for this demo, including both the guest and host. For the rest of this blog, we\u2019ll assume all commands you run from this point forward are executed from within this <code>hyperlight-demo<\/code> directory. Inside <code>hyperlight-demo<\/code>, create a new folder called <code>guest<\/code>, and in <code>guest<\/code>, create a file called <code>main.c<\/code> and <a href=\"https:\/\/github.com\/ludfjig\/hyperlight-samples\/blob\/main\/guest\/main.c\">copy or put this linked code<\/a> in it. This function creates a new QuickJS Runtime and Context, evaluates the given string as JavaScript, and then returns the result as a string.<\/p>\n\n\n\n<p>Next, we\u2019ll need to hook this up to Hyperlight by registering the guest function using the Hyperlight-guest C-API. By registering the function, we allow it to be called later from outside the micro-VM. We\u2019ll name the guest function <code>EvalScript<\/code>, specify that it takes a single string as a parameter, and that it also returns a string back to the host. Add the <a href=\"https:\/\/github.com\/ludfjig\/hyperlight-samples\/blob\/main\/guest\/main.c#L37-L41\">following code<\/a> below the <code>guest_function<\/code> definition in <code>main.c<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nHYPERLIGHT_WRAP_FUNCTION(guest_function, String, 1, String);\n\nvoid hyperlight_main(void) {\n    HYPERLIGHT_REGISTER_FUNCTION(\"EvalScript\", guest_function);\n}\n<\/pre><\/div>\n\n\n<p>Finally, the Hyperlight guest C-API requires that you define a function called <code>c_guest_dispatch_function<\/code>, to handle dynamic guest function calls that have not been registered. Since we don&#8217;t care about these kinds of function calls, we can simply return null. Add the <a href=\"https:\/\/github.com\/ludfjig\/hyperlight-samples\/blob\/main\/guest\/main.c#L45-L47\">following<\/a> to your main.c:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nhl_Vec *c_guest_dispatch_function(const hl_FunctionCall *function_call) \t{\n    return NULL;\n}\n<\/pre><\/div>\n\n\n<p>Finally, we want compile this to an Executable and Linkable Format (ELF) binary using the clang compiler. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"things-to-be-careful-about\">Things to be careful about <\/h3>\n\n\n\n<p>First, when compiling a C guest for Hyperlight you must use Hyperlight\u2019s version of libc, which is a modified version of musl. To get this, first download the <code>include.tar.gz<\/code> artifact from Hyperlight\u2019s <a href=\"https:\/\/github.com\/hyperlight-dev\/hyperlight\/releases\">release page<\/a> on GitHub using the following command (using <strong>wget<\/strong>, <strong>curl<\/strong>, or another fetching tool):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nwget https:\/\/github.com\/hyperlight-dev\/hyperlight\/releases\/download\/v0.2.0\/include.tar.gz -P guest\/include\n<\/pre><\/div>\n\n\n<p>This includes all the libc headers that Hyperlight supports, as well as <code>hyperlight_guest.h<\/code>, which provides the various function definitions required for communicating between the host from the guest. It\u2019s important you don\u2019t use your system\u2019s own libc headers. Extract the tarball using <code>tar -xvf guest\/include\/include.tar.gz -C guest\/include\/<\/code>. You should now see three new folders inside your <code>guest\/include<\/code> folder.<\/p>\n\n\n\n<p>Second, we\u2019ll download <code>hyperlight-guest-c-api-linux.tar.gz<\/code>, also from Hyperlight\u2019s <a href=\"https:\/\/github.com\/hyperlight-dev\/hyperlight\/releases\">release page<\/a> on GitHub.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nwget https:\/\/github.com\/hyperlight-dev\/hyperlight\/releases\/download\/v0.2.0\/hyperlight-guest-c-api-linux.tar.gz -P guest\/libs\n<\/pre><\/div>\n\n\n<p>It contains <code>libhyperlight_guest.a<\/code>, which is a statically compiled library that includes both a modified version of libc, as well as specific Hyperlight functions for communicating with the host. Extract the tarball using the following command<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\ntar -xvf guest\/libs\/hyperlight-guest-c-api-linux.tar.gz -C guest\/libs\/ \n<\/pre><\/div>\n\n\n<p>Third, we need a copy of QuickJS. We can download it directly from the author\u2019s website using the following command, <code>wget https:\/\/bellard.org\/quickjs\/quickjs-2024-01-13.tar.xz<\/code>, followed by <code>tar -xvf quickjs-2024-01-13.tar.xz<\/code>to extract it.<\/p>\n\n\n\n<p>At this point, your folder structure should look like this when you run <code>tree -d<\/code>:<\/p>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2025\/03\/treed.webp\" alt=\"A view of a directory tree using the tree -d command \" class=\"wp-image-97224 webp-format\" srcset=\"\" data-orig-src=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2025\/03\/treed.webp\"><\/figure>\n\n\n\n<p>Finally, let\u2019s compile everything using clang. Run the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclang -I guest\/include\/include -I guest\/include\/musl\/include -I guest\/include\/musl\/arch\/x86_64\/ -I guest\/include\/printf -I guest\/include -I quickjs-2024-01-13 guest\/main.c quickjs-2024-01-13\/quickjs.c quickjs-2024-01-13\/libregexp.c quickjs-2024-01-13\/libunicode.c quickjs-2024-01-13\/cutils.c quickjs-2024-01-13\/libbf.c -O3 -DHYPERLIGHT -DCONFIG_VERSION=\\\"2024-01-13\\\" -D_GNU_SOURCE -DCONFIG_BIGNUM -nostdinc -nostdlib -fpie -D putchar=_putchar -Wno-macro-redefined -Wno-ignored-attributes -Wno-implicit-const-int-float-conversion --target=x86_64-unknown-elf -e entrypoint -l hyperlight_guest_capi -L guest\/libs\/release -o quickjs-guest\n<\/pre><\/div>\n\n\n<p>Now that\u2019s some fun, right there.<\/p>\n\n\n\n<p>A quick explanation is in order to describe some of the options here. Importantly, we use <code>-nostdinc<\/code> to not include the standard system #include directories, and the <code>-nostdlib<\/code> linker option to not link any unwanted libraries. The <code>-I<\/code> flags tell clang where to look for header files. We use the <code>--target=x86_64-unknown-elf<\/code> to build an OS-independent ELF file, since we are running in a freestanding environment without OS. We use <code>-fpie<\/code> to make the code relocatable, which is a requirement for Hyperlight. We use <code>-e entrypoint<\/code> to tell the linker to look for an entrypoint called \u201centrypoint\u201d. We silence some warnings and set some necessary defines.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-to-do-if-the-command-doesn-t-work\">What to do if the command doesn&#8217;t work<\/h3>\n\n\n\n<p>We get a bunch of errors related to missing files and calls to undeclared library functions. The errors are saying that QuickJS uses parts of libc that Hyperlight doesn\u2019t yet support. For example, Hyperlight micro-VMs have no concepts of a filesystem, and as such, we have stripped our version of libc of all functions that take in file descriptors. Another current limitation of Hyperlight is that it is single-threaded, and thus we must get rid of some pthread usage in QuickJS. Luckily, QuickJS doesn\u2019t require much from the environment, and we have a <a href=\"https:\/\/github.com\/ludfjig\/hyperlight-samples\/blob\/c33a451672720e1aa78d593efe98a3e2e1cdcd0c\/quickjs_hyperlight.patch\">small QuickJS patch available<\/a> to fix up these errors. Apply the patch using the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\ncurl -sL https:\/\/raw.githubusercontent.com\/ludfjig\/hyperlight-samples\/c33a451672720e1aa78d593efe98a3e2e1cdcd0c\/quickjs_hyperlight.patch | patch -p1 -d quickjs-2024-01-13\/\n<\/pre><\/div>\n\n\n<p>Use the same clang command given above to compile the guest again, but this time there should be no errors, and if everything worked correctly, you should see a new file called quickjs-guest, ready to be used by our Hyperlight host API. Note, however, that this is not a regular ELF file that can be run outside Hyperlight. For example, it has no regular main function. Hyperlight, however, knows how to execute it inside a micro-VM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"writing-the-hyperlight-host-application\">Writing the Hyperlight host application<\/h2>\n\n\n\n<p>Now that the guest is finished, we\u2019ll need to create a program that runs on the host and uses Hyperlight to load our <code>quickjs-guest<\/code> binary into a micro-VM. From the <code>hyperlight-demo<\/code> directory, run <code>cargo new --bin host<\/code> to create a new rust binary application in a new host directory. Add a dependency on the <code>hyperlight-host<\/code> crate by running <code>cargo add hyperlight-host@0.2.0 --manifest-path host\/Cargo.toml<\/code>. Now let\u2019s create a simple CLI that reads stdin into a string. We then use the Hyperlight-host API to create a sandbox, load our binary, call our guest function \u201c<code>EvalScript<\/code>\u201d and pass in the string, receive, and then print out the result of our evaluating our JavaScript code. The entire CLI \u201cmain.rs\u201d file should match <a href=\"https:\/\/github.com\/ludfjig\/hyperlight-samples\/blob\/main\/host\/src\/main.rs\">this code linked here<\/a>.<\/p>\n\n\n\n<p>Finally, compile and run the code, while passing in some JavaScript to be evaluated on stdin:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\necho \"1+1\" | cargo run --manifest-path=host\/Cargo.toml\n<\/pre><\/div>\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" alt=\"The number 2 being printed after running the command echo \"1+1\" | cargo run --manifest-path=host\/Cargo.toml\" src=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2025\/03\/2.webp\" alt='The number 2 being printed after running the command echo \"1+1\" | cargo run --manifest-path=host\/Cargo.toml' class=\"wp-image-97225 webp-format\" srcset=\"\" data-orig-alt=\"The number 2 being printed after running the command echo \"1+1\" | cargo run --manifest-path=host\/Cargo.toml\" src=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2025\/03\/2.webp\"><\/figure>\n\n\n\n<p>The first time you run it, it can take a while to compile everything, but subsequent runs should be must faster. What is cool is every time we run this, we create a totally new hardware-protected micro-VM, execute code inside, then tear it down again.<\/p>\n\n\n\n<p>Let\u2019s try something more complicated like calculating 1,000,000 digits of pi. This is a code sample taken from QuickJS\u2019s website, and it uses the BigFloat QuickJS extension. Create a new folder called \u201csamples\u201d and copy <a href=\"https:\/\/github.com\/ludfjig\/hyperlight-samples\/blob\/main\/samples\/pi_bigfloat.js\">this file<\/a> into a new file called \u201cpi_bigfloat.js\u201d in the \u201csamples\u201d directory.<\/p>\n\n\n\n<p>Run it using <code>cargo run --manifest-path=host\/Cargo.toml &lt; samples\/pi_bigfloat.js<\/code>, and it should output the first one million digits of pi.<\/p>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2025\/03\/pi-3.webp\" alt=\"The first few digits of pi being printed after running the command cargo run.\" class=\"wp-image-97245 webp-format\" srcset=\"\" data-orig-src=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2025\/03\/pi-3.webp\"><\/figure>\n\n\n\n<p>And that\u2019s it. In this tutorial, we used Hyperlight to create a Rust CLI application that runs JavaScript inside a secure micro-VM. To do this, we created a guest ELF binary written in C that uses QuickJS to execute JavaScript. We then wrote a host-side application that uses Hyperlight to create a new micro-VM. The host application then loads the guest binary into the micro-VM and lets the VM execute it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"a-note-on-kvm\">A note on KVM<\/h2>\n\n\n\n<p>Q: I get \u201cError: NoHypervisorFound\u201d&nbsp;when running the host application<\/p>\n\n\n\n<p>A: You might not have access to the <code>\/dev\/kvm<\/code> device. First make sure it exists by running <code>ls -l \/dev\/kvm<\/code>. If it does exist, it might be a permission issue if your current user does not have access to it. For more information, you can check out <a href=\"https:\/\/help.ubuntu.com\/community\/KVM\/Installation\">KVM\/Installation &#8211; Community Help Wiki<\/a>. It may also require ensuring that <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/wsl\/wsl-config#main-wsl-settings\">nested virtualization is enabled in WSL<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"get-involved\">Get involved<\/h2>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/azure.microsoft.com\/en-us\/solutions\/open-source\/?msockid=0f29fd8c9c2668ca1142e9e19dbf6990\">Learn more about Open source on Azure <\/a><\/div>\n<\/div>\n\n\n\n<p>Hyperlight is an actively evolving open-source project and welcomes new contributions! To get started, view code samples, see our community, and <a href=\"https:\/\/aka.ms\/hyperlight-dev\">learn more on GitHub<\/a>. Recently, Hyperlight has applied to join the <a href=\"https:\/\/github.com\/cncf\/sandbox\/issues\/312\">Cloud Native Computing Foundation<\/a> (CNCF) Sandbox.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library.<\/p>\n","protected":false},"author":6236,"featured_media":95462,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"msxcm_post_with_no_image":false,"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","footnotes":""},"post_tag":[],"content-type":[346],"topic":[2238,2247],"programming-languages":[2260],"coauthors":[2597],"class_list":["post-97206","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","content-type-news","topic-ai-machine-learning","topic-programming-languages","programming-languages-javascript","review-flag-1593580428-734","review-flag-1593580419-521","review-flag-1-1593580432-963","review-flag-2-1593580437-411","review-flag-free-1593619513-693","review-flag-new-1593580248-669","review-flag-vm-1593580807-312"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Build a Hyperlight C guest to securely execute JavaScript | Microsoft Open Source Blog<\/title>\n<meta name=\"description\" content=\"This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library and have fun with some JavaScript. Learn more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Build a Hyperlight C guest to securely execute JavaScript | Microsoft Open Source Blog\" \/>\n<meta property=\"og:description\" content=\"This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library and have fun with some JavaScript. Learn more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Open Source Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-10T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-21T15:09:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1170\" \/>\n\t<meta property=\"og:image:height\" content=\"640\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ludvig Liljenberg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@OpenAtMicrosoft\" \/>\n<meta name=\"twitter:site\" content=\"@OpenAtMicrosoft\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ludvig Liljenberg\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 min read\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\"},\"author\":[{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/author\/ludvig-liljenberg\/\",\"@type\":\"Person\",\"@name\":\"Ludvig Liljenberg\"}],\"headline\":\"Build a Hyperlight C guest to securely execute JavaScript\",\"datePublished\":\"2025-03-10T14:00:00+00:00\",\"dateModified\":\"2025-04-21T15:09:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\"},\"wordCount\":1521,\"publisher\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\",\"url\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\",\"name\":\"Build a Hyperlight C guest to securely execute JavaScript | Microsoft Open Source Blog\",\"isPartOf\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp\",\"datePublished\":\"2025-03-10T14:00:00+00:00\",\"dateModified\":\"2025-04-21T15:09:19+00:00\",\"description\":\"This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library and have fun with some JavaScript. Learn more.\",\"breadcrumb\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage\",\"url\":\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp\",\"contentUrl\":\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp\",\"width\":1170,\"height\":640},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/opensource.microsoft.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build a Hyperlight C guest to securely execute JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#website\",\"url\":\"https:\/\/opensource.microsoft.com\/blog\/\",\"name\":\"Microsoft Open Source Blog\",\"description\":\"Open dialogue about openness at Microsoft \u2013 open source, standards, interoperability\",\"publisher\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/opensource.microsoft.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#organization\",\"name\":\"Microsoft Open Source Blog\",\"url\":\"https:\/\/opensource.microsoft.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png\",\"contentUrl\":\"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png\",\"width\":259,\"height\":194,\"caption\":\"Microsoft Open Source Blog\"},\"image\":{\"@id\":\"https:\/\/opensource.microsoft.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/OpenAtMicrosoft\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Build a Hyperlight C guest to securely execute JavaScript | Microsoft Open Source Blog","description":"This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library and have fun with some JavaScript. Learn more.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Build a Hyperlight C guest to securely execute JavaScript | Microsoft Open Source Blog","og_description":"This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library and have fun with some JavaScript. Learn more.","og_url":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/","og_site_name":"Microsoft Open Source Blog","article_published_time":"2025-03-10T14:00:00+00:00","article_modified_time":"2025-04-21T15:09:19+00:00","og_image":[{"width":1170,"height":640,"url":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.png","type":"image\/png"}],"author":"Ludvig Liljenberg","twitter_card":"summary_large_image","twitter_creator":"@OpenAtMicrosoft","twitter_site":"@OpenAtMicrosoft","twitter_misc":{"Written by":"Ludvig Liljenberg","Est. reading time":"7 min read"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#article","isPartOf":{"@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/"},"author":[{"@id":"https:\/\/opensource.microsoft.com\/blog\/author\/ludvig-liljenberg\/","@type":"Person","@name":"Ludvig Liljenberg"}],"headline":"Build a Hyperlight C guest to securely execute JavaScript","datePublished":"2025-03-10T14:00:00+00:00","dateModified":"2025-04-21T15:09:19+00:00","mainEntityOfPage":{"@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/"},"wordCount":1521,"publisher":{"@id":"https:\/\/opensource.microsoft.com\/blog\/#organization"},"image":{"@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/","url":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/","name":"Build a Hyperlight C guest to securely execute JavaScript | Microsoft Open Source Blog","isPartOf":{"@id":"https:\/\/opensource.microsoft.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage"},"image":{"@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp","datePublished":"2025-03-10T14:00:00+00:00","dateModified":"2025-04-21T15:09:19+00:00","description":"This article will show you how to create a \u201cguest\u201d application that uses the Hyperlight library and have fun with some JavaScript. Learn more.","breadcrumb":{"@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#primaryimage","url":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp","contentUrl":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2024\/06\/1920-Panel8-FeatureHeader-Modernize.webp","width":1170,"height":640},{"@type":"BreadcrumbList","@id":"https:\/\/opensource.microsoft.com\/blog\/2025\/03\/10\/build-a-hyperlight-c-guest-to-securely-execute-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/opensource.microsoft.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Build a Hyperlight C guest to securely execute JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/opensource.microsoft.com\/blog\/#website","url":"https:\/\/opensource.microsoft.com\/blog\/","name":"Microsoft Open Source Blog","description":"Open dialogue about openness at Microsoft \u2013 open source, standards, interoperability","publisher":{"@id":"https:\/\/opensource.microsoft.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/opensource.microsoft.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/opensource.microsoft.com\/blog\/#organization","name":"Microsoft Open Source Blog","url":"https:\/\/opensource.microsoft.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/opensource.microsoft.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png","contentUrl":"https:\/\/opensource.microsoft.com\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png","width":259,"height":194,"caption":"Microsoft Open Source Blog"},"image":{"@id":"https:\/\/opensource.microsoft.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/OpenAtMicrosoft"]}]}},"msxcm_display_generated_audio":false,"msxcm_animated_featured_image":null,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Open Source Blog","distributor_original_site_url":"https:\/\/opensource.microsoft.com\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/posts\/97206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/users\/6236"}],"replies":[{"embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/comments?post=97206"}],"version-history":[{"count":35,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/posts\/97206\/revisions"}],"predecessor-version":[{"id":97379,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/posts\/97206\/revisions\/97379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/media\/95462"}],"wp:attachment":[{"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/media?parent=97206"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/post_tag?post=97206"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/content-type?post=97206"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/topic?post=97206"},{"taxonomy":"programming-languages","embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/programming-languages?post=97206"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/opensource.microsoft.com\/blog\/wp-json\/wp\/v2\/coauthors?post=97206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}