Exécution en sandbox sécurisée

VérifiéPrudence

Exécutez des commandes dans des conteneurs isolés pour tester du code non fiable en toute sécurité. Détection automatique du runtime (Python, Node, Rust, Go, Ruby, etc.) avec contrôle granulaire des permissions.

Spar Skills Guide Bot
SecuriteIntermédiaire
02/03/2026
Claude CodeCursorCodex
#sandboxing#isolation#containers#code-execution#agentkernel

Recommandé pour

Synthèse automatique

Cette skill exécute des commandes dans des conteneurs isolés via l'outil agentkernel, afin de protéger la machine hôte lors de l'exécution de code non fiable ou de commandes système risquées.

Points forts

  • Détection automatique du runtime (Python, Node, Rust, Go, Ruby, etc.) à partir de la commande lancée, avec l'image Docker correspondante.
  • Trois profils de sécurité documentés (permissive, moderate, restrictive) permettant de couper le réseau, monter ou non le répertoire courant et passer ou non les variables d'environnement.
  • Prise en charge des sandboxes persistantes (create/start/exec/stop/remove) pour les travaux de plus longue durée.
  • Option --keep pour conserver un sandbox après exécution et faciliter le débogage.

Limites

  • Dépend entièrement de l'outil externe agentkernel, qui doit être installé et dont la syntaxe exacte n'est pas vérifiable ici.
  • Les commandes composées avec && ou || doivent être encapsulées dans sh -c, ce qui ajoute une étape manuelle.
  • Non adapté aux opérations nécessitant des identifiants de l'hôte, des clés SSH ou un accès direct au système de fichiers.
Quand l'utiliser

À utiliser dès qu'il faut exécuter du code généré ou non fiable, des builds ou des tests susceptibles de modifier l'état du système.

Quand l'éviter

À éviter pour de simples lectures/écritures de fichiers, les opérations Git courantes ou tout ce qui requiert les identifiants et clés SSH de la machine hôte.

Analyse de sécurité

Prudence
Score qualité88/100

The skill is designed for legitimate isolation and does not instruct destructive, exfiltrating, or obfuscated actions. However, it relies on powerful container/runtime tooling and documents permissive modes that mount host paths and pass environment variables, so it warrants caution rather than a safe rating.

Points d'attention
  • •No allowed-tools are declared even though the skill instructs the agent to execute shell commands via agentkernel.
  • •The permissive profile mounts the current directory and home directory and passes environment variables, which could expose credentials or secrets if used carelessly.
  • •Compound commands are supported through sh -c, which increases the chance of unintended execution if untrusted input is interpolated.
  • •Persistent sandboxes and --keep may leave running containers or resources behind if cleanup is omitted.
  • •The skill depends on an external agentkernel CLI plus Docker/Podman/Firecracker, so its actual security properties depend on that tool's installation and configuration.
Comment cette analyse est faite

Exemples

Run an untrusted script
Run this downloaded Python script in an isolated sandbox so it can't touch my machine: agentkernel run python3 script.py
Install and test a Node project
Install dependencies and run the test suite inside a sandbox: agentkernel run sh -c 'npm install && npm test'
No-network reproduction
Reproduce this build failure with networking disabled using the restrictive profile: agentkernel run --profile restrictive cargo build

name: sandbox description: Execute commands in isolated sandboxes for security. Use when running untrusted code, system commands, or operations that could affect the host system. Automatically detects the right runtime (Python, Node, Rust, Go, Ruby, etc.) from the command.

Sandbox Skill

Execute commands in secure, isolated containers using agentkernel. This provides hardware-level isolation to protect the host system from potentially dangerous operations.

When to Use This Skill

Use this skill when:

  • Running untrusted or generated code
  • Executing shell commands that could modify system state
  • Testing code in a clean environment
  • Running build/test commands that might have side effects
  • Executing code from external sources
  • Any operation where isolation is beneficial for security

Do NOT use this skill for:

  • Simple file reads/writes (use standard tools)
  • Git operations (use standard tools)
  • Operations that need access to host credentials or SSH keys

Instructions

Basic Usage

Run any command in an isolated sandbox:

agentkernel run <command> [args...]

For compound commands with && or ||, wrap in sh -c:

agentkernel run sh -c 'npm install && npm test'

The runtime is auto-detected from the command:

# Python
agentkernel run python3 script.py
agentkernel run pip install package-name
agentkernel run pytest

# Node.js
agentkernel run node script.js
agentkernel run npm test
agentkernel run npx create-react-app my-app

# Rust
agentkernel run cargo build
agentkernel run cargo test

# Go
agentkernel run go build
agentkernel run go test ./...

# Ruby
agentkernel run ruby script.rb
agentkernel run bundle exec rspec

# And more: PHP, Java, C/C++, Elixir, Lua, Terraform...

Specifying an Image

Override the auto-detected image:

agentkernel run --image ubuntu:24.04 apt-get update
agentkernel run --image postgres:16-alpine psql --version

Security Profiles

Control sandbox permissions with security profiles:

# Default: moderate security (network enabled, no mounts)
agentkernel run npm test

# Restrictive: no network, read-only filesystem, all capabilities dropped
agentkernel run --profile restrictive python3 script.py

# Permissive: network, mounts, environment passthrough
agentkernel run --profile permissive cargo build

# Disable network access specifically
agentkernel run --no-network curl example.com  # Will fail

| Profile | Network | Mount CWD | Mount Home | Pass Env | Read-only | |---------|---------|-----------|------------|----------|-----------| | permissive | Yes | Yes | Yes | Yes | No | | moderate | Yes | No | No | No | No | | restrictive | No | No | No | No | Yes |

Keeping Sandboxes for Debugging

Keep the sandbox after execution:

agentkernel run --keep npm test
# Later: agentkernel sandbox remove run-<id>

Persistent Sandboxes

For longer-running work:

# Create and start
agentkernel sandbox create my-sandbox
agentkernel sandbox start my-sandbox

# Execute commands
agentkernel exec my-sandbox npm test
agentkernel exec my-sandbox python -m pytest

# Clean up
agentkernel sandbox stop my-sandbox
agentkernel sandbox remove my-sandbox

Supported Languages

| Language | Commands | Docker Image | |----------|----------|--------------| | Python | python, python3, pip, poetry, uv, pytest | python:3.12-alpine | | Node.js | node, npm, npx, yarn, pnpm, bun | node:22-alpine | | Rust | cargo, rustc | rust:1.85-alpine | | Go | go, gofmt | golang:1.23-alpine | | Ruby | ruby, bundle, rails, rake | ruby:3.3-alpine | | Java | java, javac, mvn, gradle | eclipse-temurin:21-alpine | | PHP | php, composer | php:8.3-alpine | | C/C++ | gcc, g++, make, cmake | gcc:14-bookworm | | .NET | dotnet | mcr.microsoft.com/dotnet/sdk:8.0 | | Terraform | terraform | hashicorp/terraform:1.10 | | Lua | lua, luajit | nickblah/lua:5.4-alpine | | Shell | bash, sh, zsh | alpine:3.20 |

Security Notes

  • Sandboxes run in isolated containers (Docker or Podman)
  • On Linux with KVM, Firecracker microVMs provide hardware-level isolation
  • Three security profiles: permissive, moderate (default), restrictive
  • Use --profile restrictive for maximum isolation (no network, read-only fs)
  • Use --no-network to disable network access specifically
  • Host filesystem is NOT mounted by default (use permissive profile to enable)
  • Each sandbox gets a clean environment

Agent Compatibility Modes

Agentkernel supports compatibility modes for different AI agents. Each mode configures sandbox behavior optimally for that agent's needs:

# Claude Code compatibility (default for this plugin)
agentkernel run --compatibility-mode claude python3 script.py

# Codex compatibility (stricter isolation)
agentkernel run --compatibility-mode codex python3 script.py

# Gemini compatibility (Docker-style)
agentkernel run --compatibility-mode gemini python3 script.py

Or configure in agentkernel.toml:

[sandbox]
name = "my-project"

[agent]
preferred = "claude"
compatibility_mode = "claude"  # claude, codex, gemini, or native

[security]
profile = "moderate"  # Can override compatibility mode defaults

Compatibility Mode Differences

| Mode | Network Policy | Project Mount | API Access | Isolation | |------|----------------|---------------|------------|-----------| | Native | Allow all | No | None | Moderate | | Claude | Domain allowlist | Yes | Anthropic API | Moderate | | Codex | Domain allowlist | Yes | OpenAI API | Strict | | Gemini | Domain allowlist | Yes | Google API | Moderate |

Claude mode allows: api.anthropic.com, cdn.anthropic.com, common package registries. Codex mode allows: api.openai.com, cdn.openai.com, common package registries. Gemini mode allows: *.googleapis.com, common package registries.

All modes block cloud metadata endpoints (169.254.169.254, metadata.google.internal).

MCP Server Integration

This plugin provides an MCP (Model Context Protocol) server for direct tool integration. When enabled, the following MCP tools are available:

Command Execution

| Tool | Description | |------|-------------| | sandbox_run | Run a command in a temporary sandbox with security profile and compatibility mode | | sandbox_create | Create a persistent sandbox | | sandbox_exec | Execute a command in an existing sandbox | | sandbox_list | List all sandboxes | | sandbox_remove | Remove a sandbox |

File Operations

| Tool | Description | |------|-------------| | sandbox_file_write | Write a file into a running sandbox | | sandbox_file_read | Read a file from a sandbox (supports binary via base64) |

Lifecycle Management

| Tool | Description | |------|-------------| | sandbox_start | Start a stopped sandbox | | sandbox_stop | Stop a running sandbox |

sandbox_run Options

The sandbox_run tool accepts these parameters:

  • command (required): Command to execute (array of strings)
  • profile: Security profile (restrictive, moderate, permissive)
  • compatibility_mode: Agent mode (native, claude, codex, gemini)
  • network: Override network access (boolean)
  • cwd: Working directory inside sandbox
  • env: Environment variables (object)
  • timeout_ms: Command timeout in milliseconds (default: 30000)

Example MCP request:

{
  "method": "tools/call",
  "params": {
    "name": "sandbox_run",
    "arguments": {
      "command": ["python3", "-c", "print('hello')"],
      "compatibility_mode": "claude",
      "timeout_ms": 60000
    }
  }
}

The MCP server starts automatically when the plugin is loaded and provides these tools via JSON-RPC over stdio.

Daemon Mode (Fast Execution)

For high-performance scenarios, agentkernel can run a daemon that maintains a pool of pre-warmed sandboxes:

# Start daemon with pre-warmed pool
agentkernel daemon start

# Check status
agentkernel daemon status  # Shows warm VMs per agent type

# Commands use warm pool automatically (~50ms vs ~500ms cold start)
agentkernel run python3 script.py

# Pre-warm for specific agent types
agentkernel daemon prewarm --mode claude

# Stop daemon
agentkernel daemon stop

The daemon supports per-agent pool configuration for optimal warm starts:

# Example daemon config (future)
[daemon]
min_warm = 3
max_warm = 5

[daemon.agents.claude]
min_warm = 2
runtime = "python"

[daemon.agents.codex]
min_warm = 1
runtime = "python"

Claude Code Permission Configuration

Agentkernel MCP tools are designed to run safely in isolated sandboxes. You can configure Claude Code's approval behavior for these tools in your project's .claude/settings.json:

{
  "permissions": {
    "allow": [
      "mcp__agentkernel__sandbox_run",
      "mcp__agentkernel__sandbox_exec",
      "mcp__agentkernel__sandbox_list",
      "mcp__agentkernel__sandbox_file_read"
    ],
    "ask": [
      "mcp__agentkernel__sandbox_file_write",
      "mcp__agentkernel__sandbox_create"
    ],
    "deny": []
  }
}

Tool Risk Levels

| Tool | Risk Level | Recommendation | |------|------------|----------------| | sandbox_list | Low | Auto-approve (read-only) | | sandbox_file_read | Low | Auto-approve (read from sandbox only) | | sandbox_run | Medium | Auto-approve (sandboxed execution) | | sandbox_exec | Medium | Auto-approve (sandboxed execution) | | sandbox_file_write | Medium | Ask (writes files into sandbox) | | sandbox_create | Medium | Ask (creates persistent resources) | | sandbox_start | Medium | Auto-approve (starts existing sandbox) | | sandbox_stop | Medium | Auto-approve (stops sandbox) | | sandbox_remove | Medium | Ask (removes sandbox) |

All tools run in isolated sandboxes, so even "medium" risk tools cannot affect the host system. The ask recommendations are for visibility, not security.

MCP Server Configuration

Add agentkernel to your Claude Code MCP servers:

// .mcp.json (project-level)
{
  "mcpServers": {
    "agentkernel": {
      "command": "agentkernel",
      "args": ["mcp", "server"],
      "env": {}
    }
  }
}

Or globally in ~/.claude/mcp.json:

{
  "mcpServers": {
    "agentkernel": {
      "command": "agentkernel",
      "args": ["mcp", "server"]
    }
  }
}

Headless/Automation Mode

For CI/CD or automated workflows, use the --allowedTools flag:

claude --allowedTools "mcp__agentkernel__*" "Run tests in sandbox"

Or configure in settings for persistent auto-approval of all agentkernel tools.

Error Handling

If a command fails, the sandbox is automatically cleaned up. Use --keep to preserve it for debugging:

agentkernel run --keep failing-command
# Inspect: docker exec -it agentkernel-run-<id> sh
# Clean up: agentkernel sandbox remove run-<id>

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/secure-sandbox-execution-mm8o533s' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/secure-sandbox-execution-mm8o533s/download' --output '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md.part' && mv '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md.part' '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md' && test -s '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/sandbox' && cp -R '.skill-downloads/secure-sandbox-execution-mm8o533s' '.claude/skills/sandbox'

Cursor
test -f '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md' && test -s '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/sandbox' && cp -R '.skill-downloads/secure-sandbox-execution-mm8o533s' '.cursor/skills/sandbox'

Codex
test -f '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md' && test -s '.skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/sandbox' && cp -R '.skill-downloads/secure-sandbox-execution-mm8o533s' '.agents/skills/sandbox'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/secure-sandbox-execution-mm8o533s'

openskills read 'secure-sandbox-execution-mm8o533s'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/secure-sandbox-execution-mm8o533s/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires