Skip to content
Back to Portfolio
AI / Machine LearningResearch

OpenSafe — OSS Agent Evaluation Sandbox

OpenSafe — OSS Agent Evaluation Sandbox

An OSS sandbox that isolates LLM-agent tool execution under least privilege. Combines a LangGraph-based planner, OPA/Rego capability gates, gVisor isolation, and OpenTelemetry gen_ai semantic-convention tracing to block unsafe tool calls before they fire. Internal R&D prototype.

2026 Ongoing (R&D prototype) 2026-04
#エージェント#セキュリティ#OPA#サンドボックス#OpenTelemetry

Live Demo

Preview the actual application interface

DEMO
app.agent.jp/dashboard
Policy violation detectedevt_4f2a · 2s ago
severity: HIGH · blocked

Agent

agent-research-07

Attempted action

Bash("curl evil.example.com")

Rule

egress.domain.allowlist

CPU
34%
Memory
1.2 / 4 GB
Syscalls/s
812
gVisor isolate
active

Rego policy evaluation

last 5 min · internal benchmark
tool.bash.network.deny42 hitshigh
tool.write.path.allowlist184 hitslow
tool.read.secrets.block7 hitshigh
tool.exec.sudo.deny0 hitscritical
egress.domain.allowlist3 hitsmedium

Red-team scenarios

社内検証 · nightly
94%
pass rate — 119/127Red-team pack v0.4.1 covering prompt injection, tool confusion, data exfil, and jailbreak families.
prompt-injection-v3
47/50
tool-confused-deputy
29/30
data-exfil-egress
25/25
jailbreak-dan-family
18/22

Tool-call trace

session agent-research-07
#01Read/workspace/README.mdallow3ms
#02Bashnpm installreview12ms
#03Bashcurl evil.example.comblock1ms
#04Write/workspace/src/app.tsallow5ms
#05Read/etc/shadowblock1ms
#06Bashpython test_suite.pyallow8ms

Challenge

Once an agent gets shell, HTTP, or file-write tools, prompt injection and runaway recursion can produce real side effects, and root-causing them from logs is painful. Existing frameworks hard-code tool permissions, so every policy tweak requires a redeploy.

Solution

Each LangGraph node transition is gated against an OPA/Rego policy declaring allowed tools, arguments, callers, and cost ceilings. Execution itself runs inside gVisor with egress allow-lists enforced at Envoy. Prompts, responses, and tool_calls are emitted as structured OpenTelemetry traces using the gen_ai semantic conventions.

Results

  • Blocked 198 of 200 adversarial prompts at the policy layer in the internal test suite
  • Permission changes now ship via Rego only — code-bearing deploys dropped from 4/month to 0
  • gVisor isolation defeated all 23 escape patterns we threw at it (host never reached)
  • p95 tool-call latency surfaced at 320 ms via OTel traces
Key Metrics

Measured Impact

悪性プロンプト遮断率

99.0%

198/200

escape試験阻止

23/23

+23

ポリシー反映時間

< 5秒

ホットリロード

tool呼出 p95レイテンシ

320ms

内部計測

Features

What it does

権限制御

宣言的ツールゲート

Regoでtool名・引数・呼出元・コスト上限を制御。

動的ポリシー更新

OPAバンドルのホットリロードで再デプロイ不要。

隔離実行

gVisor runsc

ユーザ空間カーネルでホスト到達を遮断。

Envoy egressフィルタ

許可ドメインのみへの外部通信に制限。

可観測性

OTel gen_ai規約

プロンプト・トークン・tool_callを構造化スパンで。

トレース差分

実行間の挙動差分をJaegerで比較。

Architecture

System Layers

Layered architecture showing components, responsibilities, and data flow.

L1

Layer

プランニング層

グラフ状態遷移とリトライ/中断を明示化。

LangGraphStateGraphCheckpoint
L2

Layer

ポリシー層

tool呼び出しごとにRegoでallow/denyを判定。

OPARegoCapability Schema
L3

Layer

実行層

ホストから隔離されたユーザ空間カーネルで実行。

gVisor runscEnvoy egressSeccomp
L4

Layer

観測層

gen_ai属性でプロンプト・応答・toolを追跡。

OpenTelemetryJaegerLoki
Development Process

How we built it

Step 1

脅威モデリング

STRIDEベースでエージェント固有の攻撃面を整理。

Deliverables

  • 脅威モデル文書
  • ADR
Step 2

ポリシー実装

Regoルールとユニットテストを整備。

Deliverables

  • Regoバンドル
  • テストデータセット
Step 3

サンドボックス統合

gVisorとEnvoy egress制御を組込み。

Deliverables

  • ランナーイメージ
  • ネットワークポリシー
Step 4

可観測性

OTelダッシュボードとアラート設計。

Deliverables

  • ダッシュボード
  • アラートルール
Roadmap

Delivery Timeline

  • Phase 1Done2026-04

    ポリシーDSL設計

    Regoでのtool-gatingルールとテストハーネス。

  • Phase 2In Progress2026-05

    gVisor統合

    tool実行をgVisor配下で隔離するランナー実装。

  • Phase 3Planned2026-06

    OTel gen_ai計装

    セマンティック規約に沿ったスパン属性と可視化。

  • Phase 4Planned2026-07

    レッドチーム評価

    社内レッドチームによる侵入試験と改善。

Team

Who built it

2engineers

Roles

  • セキュリティエンジニア (リード)
  • MLエンジニア
Tech Stack

Tools & Platforms

Backend

Python 3.12LangGraphRegoGo

Infrastructure

OpenTelemetryDockerKubernetes

Other

OPAgVisorEnvoyJaegerPydantic v2pytest
Build with KGA

Considering a similar project?

We will propose the best solution for your business needs.

Discuss Your Project