本文へ移動
cccskills
無料GitHub で公開日本語紹介

agent-security-hardening

AIエージェントが外部情報を読み、ツールやファイルを操作する際の安全対策を整理します。権限、保存先、認証情報の扱いを見直し、実際の動作で検証します。

原文原文の説明を見る

Security hardening guidance for AI agent frameworks that process untrusted content, invoke tools, write workspace files, manage runtime identifiers, or handle credentials. Use when building or reviewing an agent runtime, autonomous worker, tool gateway, memory service, or multi-tenant agent deployment. Do not use for general web application security or offensive testing.

インストール方法を見る

こんなときに便利

  • エージェントの安全対策を見直したいとき
  • 利用者間のデータ分離を確かめたいとき
  • 認証情報の後始末と出力制限の検証
  • 取り消せない操作の権限確認

日本語での紹介

できること

AIエージェントが外部情報を受け取り、ツール実行やファイル操作につなげる部分の安全対策を整理します。モデルの出力、検索結果、記憶、他のエージェントからのメッセージを信頼できない入力として扱い、操作直前の権限確認や値の検証を具体化します。保存先が作業領域を越えないか、接続先が許可されているか、認証情報がログに残らないかも確認します。

こんなときに便利

自律型エージェント、ツールへの接続窓口、記憶を保存するサービスを開発・レビューするときに向いています。複数の利用者や作業領域を扱う環境で、互いのデータにアクセスできないことを確かめたい場合にも使えます。チェック項目だけでなく、対策が働く証拠までまとめます。

使い方の例

  • 「このエージェントのファイル書き込みと外部接続を見直し、必要な検証とテストを整理して」
  • 「削除操作の権限確認と承認が欠けた場合、変更が起きないことを検証して」

注意点

一般的なWebアプリのセキュリティ診断や侵入テストは対象外です。検証には実際の実行入口を使い、実行コマンド、終了状態、拒否した入力、変更が起きなかった証拠を記録します。模擬処理だけのテストでは、OSの権限やネットワーク制御は証明できません。

この紹介文は、公開されている SKILL.md をもとに AI(Claude Haiku)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md10.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Agent Security Hardening

Harden the boundaries where an agent turns untrusted data into filesystem, network, memory, or tool actions. Produce concrete controls and tests for the framework being reviewed; a checklist without enforcement evidence is incomplete.

Important

  • Treat model output, retrieved content, tool output, memory, and cross-agent messages as untrusted input.
  • Default external integrations to read-only and grant each write capability separately.
  • Validate at the action boundary even when an upstream prompt or schema already validated the value.
  • Fail closed before a side effect when identity, destination, ownership, or containment cannot be proven.
  • Before a delete, publish, credential rotation, or other irreversible action, the real tool entry point must authorize the authenticated principal for that exact operation and resource scope, then require explicit confirmation or a valid scoped pre-approval. Missing or invalid evidence blocks the action.
  • Use hard bounds defined by the governing requirement and stricter values verified from deployment configuration. When neither defines a value, mark it as a required decision and test that the implementation rejects an unbounded configuration; do not invent a plausible value.

When to Activate

  • Building an autonomous agent, tool gateway, memory service, or agent-to-agent protocol
  • Reviewing code that maps model output into commands, paths, URLs, credentials, or API mutations
  • Isolating tenants, projects, sessions, or workspaces in a long-running agent process
  • Hardening temporary files, logs, tool responses, or external-content ingestion

Hardening Workflow

1. Map Trust Boundaries

List every boundary as source -> parser -> validator -> side effect. Include direct user input, model output, retrieved documents, memory, environment variables, tool results, and messages from other agents.

For each side effect, record:

  • the identity and scope authorizing it;
  • the exact validator that runs immediately before it;
  • the maximum input and output size;
  • the audit evidence produced;
  • the recovery path if the operation is interrupted.

This step is complete when every write, command, network mutation, and credential use has one named authorization boundary.

2. Validate Identifiers, Environment Values, and URLs

Use an allowlist for identifiers that become filenames, keys, selectors, or command arguments. Agent IDs have the issue-defined hard maximum of 64 characters; deployment configuration may choose a stricter positive limit but cannot raise that boundary:

import re

SAFE_AGENT_ID_CHARS = re.compile(r"^[A-Za-z0-9_][A-Za-z0-9_-]*$")
HARD_MAX_AGENT_ID_LENGTH = 64

def require_agent_id(value: object, *, max_length: int) -> str:
    if (
        isinstance(max_length, bool)
        or not isinstance(max_length, int)
        or not 1 <= max_length <= HARD_MAX_AGENT_ID_LENGTH
    ):
        raise RuntimeError("configured agent ID limit must be between 1 and 64")
    if (
        not isinstance(value, str)
        or len(value) > max_length
        or not SAFE_AGENT_ID_CHARS.fullmatch(value)
    ):
        raise ValueError("invalid agent identifier")
    return value

When an identifier becomes a CLI argument, pass it through an argv API and place it after the command's end-of-options marker where supported. Character validation is not a substitute for argument separation.

Reject missing and whitespace-only environment values before constructing a client:

def require_env(name: str, environ: dict[str, str]) -> str:
    value = environ.get(name)
    if value is None or not value.strip():
        raise RuntimeError(f"{name} is required")
    return value

Parse URLs, allow only schemes required by the deployment, require a host, reject embedded credentials, and block private-network destinations when the URL is attacker-controlled. For every outbound connection and redirect hop, pin the connection to a validated public address or verify the connected peer address at connection time so DNS rebinding cannot cross the boundary. A credential-bearing request must use HTTPS with certificate verification before credentials are attached. Disable automatic cross-origin credential forwarding; when the scheme or origin changes, strip the credentials and reauthorize the new destination or reject the redirect. Re-run destination, connected-address, and transport validation on every hop.

This step is complete when tests reject empty, oversized, malformed, traversal-shaped, credential-bearing, and unauthorized-destination values before any side effect, and prove that DNS rebinding and cross-origin redirects cannot carry credentials to an unapproved peer.

3. Contain Filesystem Access

Reject absolute user-controlled paths and traversal components before joining. Reject Windows-unsafe components on every platform so behavior stays portable: reserved device names (CON, NUL, COM1, LPT1, including with an extension such as nul.txt), names ending in a dot or space (Win32 strips them), and : (drive-relative or NTFS alternate data stream syntax such as report.txt:ads). Resolve both the workspace and candidate path, then prove containment:

import re
from pathlib import Path

WINDOWS_RESERVED_NAME = re.compile(
    r"(CON|PRN|AUX|NUL|COM[1-9¹²³]|LPT[1-9¹²³])(\..*)?",
    re.IGNORECASE,
)

def workspace_path(workspace: Path, requested: str) -> Path:
    # Treat both platform separators consistently before checking components.
    relative = Path(requested.replace("\\", "/"))
    if relative.is_absolute() or ".." in relative.parts:
        raise ValueError("path must be workspace-relative")
    for part in relative.parts:
        if ":" in part or part.endswith((".", " ")) or WINDOWS_RESERVED_NAME.fullmatch(part):
            raise ValueError("path component is not portable")

    root = workspace.resolve(strict=True)
    candidate = (root / relative).resolve(strict=False)
    if not candidate.is_relative_to(root):
        raise ValueError("path escapes workspace")
    return candidate

Containment checks do not eliminate symlink races. For sensitive writes, open relative to a trusted directory handle where the platform supports it, reject symlink targets, create files exclusively, and verify ownership and permissions after opening.

This step is complete when tests cover sibling-prefix paths, nested .., absolute paths, symlink escapes, reserved device names, trailing dots or spaces, alternate data stream syntax, and a valid nested workspace path.

4. Protect Temporary Data and Credentials

  • Create sensitive files with owner-only permissions such as 0o600; create private directories with 0o700.
  • Prefer a user-private runtime directory over a shared temporary directory for credentials or tenant data.
  • Create unpredictable names atomically; do not check-then-create.
  • Remove temporary data in finally, while preserving a redacted error record when cleanup fails.
  • Keep secrets out of command arguments, model context, logs, traces, exception text, and tool responses.
  • Pass secrets through the platform's secret store or scoped environment injection and rotate exposed credentials.
  • Treat zeroization as best effort: mutable byte buffers can be overwritten, but immutable language strings cannot be reliably erased.

This step is complete when file-mode checks, forced-error cleanup tests, and log-capture tests show that secret values never persist outside the approved boundary.

5. Bound and Sanitize Tool Output

Read tool output with a byte limit rather than collecting an unbounded stream. Preserve structured fields, remove disallowed control characters, and append an explicit truncation marker with the original byte count. Keep a content hash when later forensic comparison matters.

Do not silently turn malformed output into an empty success value. Return a typed failure that names the producing tool, boundary, and validation reason without echoing sensitive content.

This step is complete when oversized output, invalid encoding, terminal-control sequences, malformed structured data, and a normal response all have deterministic tests.

Verification Gate

Before calling the framework hardened, verify all of these behaviors through its real entry point:

  1. Untrusted instructions remain data and cannot trigger a tool or write.
  2. An irreversible action without operation-and-resource authorization plus confirmation or scoped pre-approval leaves no side effect.
  3. Cross-tenant and cross-workspace identifiers are rejected at the action boundary.
  4. Traversal and symlink escape attempts leave the filesystem unchanged.
  5. Forced failures leave no credential-bearing temp files or logs.
  6. Oversized or malformed tool output returns an explicit bounded error.

Report the command used, exit status, rejected input, and observed absence of the side effect. Mock-only tests do not prove operating-system permissions, symlink handling, subprocess isolation, or network egress controls.

Common Issues

Validation exists only in the prompt

Prompt instructions are advisory. Move the same invariant into deterministic code immediately before the side effect and test a model response that violates it.

A normalized path still escapes

String prefix checks confuse sibling paths such as /work/app and /work/application. Resolve paths and use component-aware containment, then test symlinks separately.

Redaction happens after logging

Redact before values enter the logger, tracer, exception, or model context. Add a capture test using a sentinel secret and assert the sentinel is absent from every emitted channel.

When NOT to Use

  • Use security-review for ordinary application authentication, authorization, SQL injection, XSS, CSRF, and API security.
  • Use security-scan for repository-wide automated vulnerability scanning.
  • Use infrastructure-specific guidance for host, container, firewall, or cloud hardening.
  • Do not use this skill for penetration testing, exploit development, or unauthorized access.

Related Skills

  • agent-harness-construction
  • security-review
  • security-scan

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

accessibility

無料日本語概要

Web・iOS・Androidの画面を、読み上げやキーボード操作に対応させ、ラベル、配色、操作対象の大きさなどをWCAG 2.2に沿って設計・点検するスキル。

  • アイコンボタンの説明を付けたいとき
  • キーボード操作とモーダルの点検
  • コントラストや操作対象の大きさの確認
affaan-m/ECC27.7万2026年10月12日 更新

agent-architecture-audit

無料日本語概要

AIエージェントの不調を、指示・記憶・ツール実行・画面表示など12の層から調べるスキル。コードやログを根拠に原因を整理し、重要度順の指摘と修正案をまとめます。

  • アプリ内だけで起きる不調を調べたいとき
  • 過去の会話が混ざる原因を調査
  • ツールの未実行や実行の誤報を確認
affaan-m/ECC27.7万2026年10月12日 更新

agent-eval

無料日本語概要

実際の開発課題で複数のコーディングエージェントを比較するスキル。成功率、取得可能なAPI費用、所要時間、繰り返し実行の安定性を測り、選定や更新後の評価に使えます。

  • 実際の開発課題でエージェントを比較
  • 新しいツールやモデルの導入前評価
  • エージェント更新後の性能確認
affaan-m/ECC27.7万2026年10月12日 更新

agent-harness-construction

無料日本語概要

AIエージェントが使うツールの種類や入出力、エラーからの復帰手順を設計・見直します。文脈の情報量も整理し、作業完了率や再試行回数で改善を評価します。

  • エージェントのツールや入力形式の設計
  • ツールの結果と次の行動を明確にしたいとき
  • 安全な再試行と停止条件を定めたいとき
affaan-m/ECC27.7万2026年10月12日 更新

agent-introspection-debugging

無料日本語概要

AIエージェントが失敗や同じ操作を繰り返す原因を、エラーと実行状況から整理します。小さな復旧操作を試し、結果と根拠を引き継げる報告にまとめるスキルです。

  • エージェントの連続失敗を診断したいとき
  • 同じツール操作のループ調査
  • 情報の蓄積による出力劣化の点検
affaan-m/ECC27.7万2026年10月5日 更新

agent-introspection-debugging

無料日本語概要

AIエージェントの失敗や同じ操作の繰り返しを記録し、原因の切り分け、小さな復旧操作、結果の報告まで進める手順を示して、根拠のある再試行につなげるスキル。

  • 同じツール操作を繰り返す原因の調査
  • 会話の肥大化による品質低下の調査
  • ファイルパスや環境の食い違いの確認
affaan-m/ECC27.7万2026年10月12日 更新

affaan-m のスキルをすべて見る

このスキルの問題を報告する