Chuyển đến nội dung
Skillpedia
Agent280k · #131

agent-security-hardening

Skill này làm gì

Hướng dẫn này chỉ cách bảo mật các hệ thống AI xử lý thông tin không đáng tin cậy. Nó giúp tạo các rào chắn bảo mật để ngăn dữ liệu nguy hiểm gây ra vấn đề.

Khi nào nên dùng

  • ✓Khi xây dựng một hệ thống AI nhận dữ liệu từ bên ngoài.
  • ✓Khi rà soát code biến dữ liệu thành hành động.
  • ✓Khi tách biệt các người dùng hoặc tác vụ khác nhau trong một hệ thống AI.

Liên kết skill

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/agent-security-hardening/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/agent-security-hardening/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để đảm bảo AI không thực thi các lệnh nguy hiểm dựa trên dữ liệu tôi đưa vào?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Hướng dẫn gợi ý xác định nơi dữ liệu không đáng tin cậy đi vào, kiểm tra kỹ mọi thứ trước khi thực hiện hành động, và hạn chế quyền truy cập vào file cũng như các phần khác của hệ thống.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.

…

Câu hỏi thường gặp

Ý nghĩa của “treat model output as untrusted input” là gì?

Nghĩa là mọi thứ AI tạo ra, dù trông có vẻ an toàn, đều phải được kiểm tra trước khi dùng, vì nó có thể chứa điều bất ngờ hoặc nguy hiểm.

Tại sao phải kiểm tra lại dù đã kiểm tra trước đó?

Vì việc kiểm tra ở mỗi bước, đặc biệt trước một hành động có thể gây hệ quả như xóa thứ gì đó, đảm bảo không có gì nguy hiểm lọt qua mà không bị phát hiện.

“Fail closed” là gì?

Đó là quy tắc bảo mật: khi có nghi ngờ, chặn truy cập hoặc hành động. Nếu không thể chứng minh điều gì đó an toàn, tốt hơn là không cho phép nó xảy ra.

Chi tiết

Mô tả gốc của tác giả

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.

repo: affaan-m/ECC

Độ phổ biến

Sao GitHub
280k
Vị trí xếp hạng
#131
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự