# Security and Trust

> Learn about the security risks and mitigation strategies for using AI-generated scripts in development environments.

We discuss various security risks and possible mitigations when using GenAIScript. GenAIScript inherits the same security risks as running scripts, and adds some new threats due to the nature of the LLM-generated outputs.

We also recommend reading the [Transparency Note](/genaiscript/reference/transparency-note/) to understand the capabilities and limitations of GenAIScript.

## Don’t trust the scripts

[Section titled “Don’t trust the scripts”](#dont-trust-the-scripts)

Since the GenAIScript files `.genai.mjs` are executable JavaScript files and are in fact using a JavaScript runtime (VSCode or Node). It is important to understand that the script can do anything that JavaScript can do. This includes reading and writing files, making network requests, and executing JavaScript arbitrary code.

Caution

Do not run `.genai.mjs` scripts from untrusted sources.

## Don’t trust the LLM Outputs

[Section titled “Don’t trust the LLM Outputs”](#dont-trust-the-llm-outputs)

A trusted script might use malicious files from the context to generate a malicious output. For example, overriding files in the project with new malicious code.

Caution

Always validate the output of a LLM generation.

* in Visual Studio Code, use the refactoring preview
* in your CI/CD, create a pull request with the changes and review them

## Visual Studio Code Workspace Trust

[Section titled “Visual Studio Code Workspace Trust”](#visual-studio-code-workspace-trust)

The extension is **disabled** when opening a folder in [Restricted Mode](https://code.visualstudio.com/docs/editor/workspace-trust) in Visual Studio Code.

## Visual Studio Code Markdown Preview

[Section titled “Visual Studio Code Markdown Preview”](#visual-studio-code-markdown-preview)

The output of the LLM and the trace use the built-in markdown preview of Visual Studio Code. By default, [VS Code restricts the content displayed in the Markdown preview](https://code.visualstudio.com/Docs/languages/markdown#_markdown-preview-security). This includes disabling script execution and only allowing resources to be loaded over `https`.

## Domain Filtering Limitations

[Section titled “Domain Filtering Limitations”](#domain-filtering-limitations)

GenAIScript provides domain filtering for its built-in APIs (`host.fetchText`, `host.resolveResource`) but this is **not a comprehensive security solution**:

* Domain filtering only applies to GenAIScript’s host APIs
* Global `fetch()`, third-party libraries, and imported packages are **not restricted**
* This is not an egress proxy or firewall replacement

For comprehensive network security, implement proper firewall rules, network policies, or use containers with restricted network access.