サンドボックス化された API とは
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
オープンソースの Sandboxed API(SAPI)プロジェクトは、Google の Sandbox2 オープンソース プロジェクトを基盤としており、C/C++ ライブラリのサンドボックス化の負担を軽減することを目的としています。
サンドボックス化された API には、主に次の 3 つのメリットがあります。
Sandbox2 のようにプログラム全体をサンドボックス化したり、プログラムの一部をサンドボックス化するためにソースコードを変更したりする必要はありません。SAPI では、個々の C/C++ ライブラリをサンドボックス化できます。その結果、SAPI を使用すると、メイン プログラムは C/C++ ライブラリのコード実行の脆弱性から分離されます。
Google のモットーは「一度サンドボックス化すれば、どこでも使用できる」です。サンドボックス化された API でサンドボックス化されたライブラリは簡単に再利用できるため、今後のプロジェクトの負担が軽減されます。Sandboxed API の前は、Google で使用できるサンドボックスでは、同じソフトウェア ライブラリを再利用する場合でも、サンドボックス化するプロジェクトの新しいインスタンスごとに実装作業を追加する必要がありました。サンドボックス化されたプロセスに適用される Sandbox2 ポリシーやその他の制限は、毎回再実装する必要があり、コードの信頼できる部分と信頼できない部分間のデータ交換メカニズムは、ゼロから設計する必要がありました。
各 SAPI ライブラリは、厳密に定義されたセキュリティ ポリシーを利用します。これは、セキュリティ ポリシーが使用されるすべてのライブラリの syscall/リソース フットプリント全体をカバーする必要がある一般的なサンドボックス プロジェクトとは対照的です。
SAPI プロジェクトは、Google Sandbox チームのメンバーによって設計、開発、保守されています。また、フィールド テスト済みの Sandbox2 も使用しています。現在、多くの内部プロジェクトで SAPI を使用して本番環境のワークロードを分離しています。
クイック スタート
サンドボックス化された API を使用する手順は次のとおりです。
- 必要な依存関係をインストールします(Debian 10 Buster を実行していることを前提としています)。
$ echo "deb http://storage.googleapis.com/bazel-apt stable jdk1.8" |
sudo tee /etc/apt/sources.list.d/bazel.list
$ wget -qO - https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install -qy build-essential linux-libc-dev bazel python3
python3-pip libclang-7-dev
$ pip3 install clang
- クローンを作成してビルドを実行します。
$ git clone https://github.com/google/sandboxed-api && cd sandboxed-api
$ bazel build …
- 例のいずれかをお試しください。
$ bazel run //sandboxed_api/examples/stringop:main_stringop
利用可能なドキュメント
サンドボックス化された API について詳しくは、こちらをご覧ください。
サンドボックス化された API の説明 - サンドボックス化された API(SAPI)とそのコアコンセプトについて説明します。
スタートガイド - API の独自の SAPI サンドボックス バージョンを作成するのに役立つガイダンスを提供します。
ビルドルール - sapi_library() ビルドルールを使用して SAPI ライブラリをビルドする方法について説明します。
変数 - 単純な型とメモリブロックへのポインタを渡すときに必要な SAPI 型の使用について説明します。
トランザクション - SAPI Transaction モジュールを使用して関数呼び出しをモニタリングする方法について説明します。
用語集
Sandbox2 |
SAPI でサンドボックス レイヤを提供する Google のオープンソース プロジェクト。 |
Sandboxee |
Sandbox2 サンドボックスで実行されるバイナリ。Sandbox2 のドキュメントをご覧ください。SAPI のコンテキストでは、これはサンドボックス化された C/C++ ライブラリです。 |
SAPI |
サンドボックス化された API: サンドボックス化されたライブラリを構築する機能を提供する Google のオープンソース プロジェクト。 |
SAPI ライブラリ |
SAPI によって生成されたライブラリ。サンドボックス ライブラリ、Sandbox2 コード、SAPI ランタイム コードが含まれます。 |
SAPI オブジェクト |
ホストコードに含まれる C++ オブジェクト。元の型ではなく SAPI 型を使用して、サンドボックス ライブラリへのインターフェースを提供します。 |
SAPI のタイプ |
SAPI は、単純な型とメモリブロックへのポインタを渡すときに必要な特殊な型を提供します。 |
SAPI トランザクション |
実行間でサンドボックス化されたライブラリのサンドボックス ステータスを管理するために使用されるモジュール。 |
RPC スタブ |
Sandbox2 でラップされ、SAPI オブジェクトとサンドボックス化されたライブラリ間でデータを渡すために使用されるリモート プロシージャ コール(RPC)通信スタブ。 |
ホストコード |
サンドボックス ライブラリを使用し、SAPI オブジェクトを含むコード。 |
サンドボックス化された API への貢献
投稿をご希望の場合は、CONTRIBUTING.md をお読みになり、pull リクエストをお送りください。バグの報告や機能のリクエストも受け付けています。
デベロッパーと話したり、プロダクトの主な更新について通知を受け取ったりするには、Google グループ sandboxed-api-users に参加することをおすすめします。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[[["\u003cp\u003eSandboxed API (SAPI) enables the sandboxing of individual C/C++ libraries to isolate the main program from vulnerabilities, unlike traditional sandboxing methods that focus on entire programs or require source code changes.\u003c/p\u003e\n"],["\u003cp\u003eWith SAPI, sandboxed libraries can be easily reused, eliminating the need for redundant implementation work in future projects that leverage the same libraries.\u003c/p\u003e\n"],["\u003cp\u003eSAPI employs tightly defined security policies specific to each library, differing from typical sandboxing approaches that require broader policies covering the entire application's resource footprint.\u003c/p\u003e\n"],["\u003cp\u003eThe SAPI project is built on Google's open-source Sandbox2 and is actively used by internal Google projects for workload isolation.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can quickly get started with SAPI by installing dependencies, building the project from the GitHub repository, and exploring the provided examples.\u003c/p\u003e\n"]]],[],null,["The open-source Sandboxed API (**SAPI** ) project builds on top of Google's\n[Sandbox2](/code-sandboxing/sandbox2) open-source project and aims to make\nsandboxing of C/C++ libraries less burdensome.\n\nSandboxed API provides three main benefits:\n\n- Instead of sandboxing entire programs or having to change source code to be\n able to sandbox a part of a program as with Sandbox2, with SAPI you can\n sandbox individual C/C++ libraries. As a result, with SAPI the main program\n is isolated from code execution vulnerabilities in the C/C++ library.\n\n- Our working motto is: **Sandbox once, use anywhere.** Libraries sandboxed\n with Sandboxed API can be easily reused, which removes the burden for future\n projects. Before Sandboxed API, sandboxes available for use at Google\n required additional implementation work with each new instance of a project\n which was intended to be sandboxed, even if it reused the same software\n library. Sandbox2 policies and other restrictions applied to the sandboxed\n process had to be reimplemented each time, and data exchange mechanisms\n between trusted and untrusted parts of the code had to be designed from\n scratch.\n\n- Each SAPI library utilizes a tightly defined security policy, in contrast to\n the typical sandboxed project, where security policies must cover the total\n syscall/resource footprint of all utilized libraries.\n\nThe SAPI project has been designed, developed, and is maintained by members of\nthe Google Sandbox Team. It also uses our field-tested\n[Sandbox2](/code-sandboxing/sandbox2). Currently, many internal projects are\nusing SAPI to isolate their production workloads.\n\nQuick Start\n\nTo get up and running with Sandboxed API, follow these steps:\n\n1. Install the required dependencies (this assumes you are running Debian 10 Buster): \n\n ```bash\n $ echo \"deb http://storage.googleapis.com/bazel-apt stable jdk1.8\" | \n\n sudo tee /etc/apt/sources.list.d/bazel.list\n $ wget -qO - https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -\n $ sudo apt-get update\n $ sudo apt-get install -qy build-essential linux-libc-dev bazel python3 \n\n python3-pip libclang-7-dev\n $ pip3 install clang\n ```\n2. Clone and run the build: \n\n ```bash\n $ git clone https://github.com/google/sandboxed-api && cd sandboxed-api\n $ bazel build …\n ```\n3. Try out one of the [examples](/code-sandboxing/sandboxed-api/examples): \n\n ```bash\n $ bazel run //sandboxed_api/examples/stringop:main_stringop\n ```\n\n| **Note:** For more detailed setup instructions and guidelines, see [Getting Started\n| with SAPI](/code-sandboxing/sandboxed-api).\n\nAvailable Documentation\n\nMore information on Sandboxed API is available here:\n\n- [Sandboxed API Explained](/code-sandboxing/sandboxed-api/explained) ---\n Describes Sandboxed API (SAPI) and its core concepts.\n\n- [Getting Started](/code-sandboxing/sandboxed-api/getting-started) ---\n Provides guidance helping you create your own SAPI sandboxed version of an\n API.\n\n- [Build Rules](/code-sandboxing/sandboxed-api/build-rules) --- Explains\n how to use the sapi_library() build rule to build your SAPI Library.\n\n- [Variables](/code-sandboxing/sandboxed-api/variables) --- Discusses the\n use of SAPI Types which are needed when passing pointers to simple types and\n memory blocks.\n\n- [Transactions](/code-sandboxing/sandboxed-api/transactions) --- Explains\n how to use the SAPI Transaction module to monitor function calls.\n\nGlossary\n\n|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Sandbox2](/code-sandboxing/sandbox2) | Google open-source project which provides the sandboxing layer in SAPI. |\n| Sandboxee | The binary executing in the Sandbox2 sandbox, see the [Sandbox2 documentation](/code-sandboxing/sandbox2/explained#sandboxee). In the context of SAPI, this is the sandboxed C/C++ library. |\n| SAPI | Sandboxed API, Google open-source project which provides the functionality to build Sandboxed Libraries. |\n| SAPI Library | Library generated by SAPI, containing Sandboxed Library, Sandbox2 code, and SAPI runtime code. |\n| [SAPI Object](/code-sandboxing/sandboxed-api/explained#sapi_object_and_rpc_stub) | C++ object, included in the Host Code, providing an interface to the Sandboxed Library using SAPI Types instead of the original ones. |\n| [SAPI Types](/code-sandboxing/sandboxed-api/variables#sapi_types) | SAPI provides special types needed when passing pointers to simple types and memory blocks. |\n| [SAPI Transaction](/code-sandboxing/sandboxed-api/transactions#sapi_transaction) | A module used to manage the sandbox status of the Sandboxed Library between runs. |\n| [RPC Stub](/code-sandboxing/sandboxed-api/explained#sapi_object_and_rpc_stub) | Remote Procedure Call (RPC) communication stub wrapped in Sandbox2 and used to pass data between SAPI Object and Sandboxed Library. |\n| [Host Code](/code-sandboxing/sandboxed-api/explained#host_code) | The code which uses the Sandboxed Library and includes the SAPI Object. |\n\nContributing to Sandboxed API\n\nIf you want to contribute, please read\n[CONTRIBUTING.md](https://github.com/google/sandboxed-api/blob/master/CONTRIBUTING.md)\nand send us pull requests.You can also report bugs or file feature requests.\n\nIf you'd like to talk to the developers or get notified about major product\nupdates, you may want to join our Google Group:\n[sandboxed-api-users](https://groups.google.com/g/sandboxed-api-users)."]]