[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M752NE8M8KWHKQ3NKGRR0817":3,"skill-same:01M752NE8M8KWHKQ3NKGRR0817":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M752NE8M8KWHKQ3NKGRR0817","policy-validation",null,"Understand Matimo's security policy engine. Learn which tool types are allowed, what domains are safe, how SSRF is prevented, and how the policy validator (matimo_doctor) enforces rules.","review-bench\u002Ftallclub_matimo","review-bench","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F286778065?v=4","01M7517F9NTEPDZDAXJBR30FWT","ReviewBench","01M752MJ9AMPM35VHCA4HV09DY",0,"MIT","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fcore\u002Fskills\u002Fpolicy-validation\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: policy-validation\ndescription: \"Understand Matimo's security policy engine. Learn which tool types are allowed, what domains are safe, how SSRF is prevented, and how the policy validator (matimo_doctor) enforces rules.\"\nmetadata:\n  category: \"Security & Policy\"\n  difficulty: \"intermediate\"\n  apply-to: \"matimo_doctor matimo_validate_tool\"\n---\n\n# Policy Validation: Security Rules and Enforcement\n\nThis skill teaches you **Matimo's security policy engine**—a **developer-controlled, object-frozen, non-bypassable** system that blocks dangerous tool patterns before they execute.\n\n## Core Principle: Policy is Immutable\n\nOnce the developer initializes Matimo with a policy configuration, that policy is **frozen** and **cannot be changed by agents**. This ensures:\n\n- ✅ Agents cannot weaken security rules\n- ✅ Agents cannot bypass domain restrictions  \n- ✅ Agents cannot create shell commands if blocked\n- ✅ Policy is transparent and auditable\n\n```typescript\n\u002F\u002F At deploy time, developer sets immutable policy:\nconst policyConfig: PolicyConfig = {\n  allowedDomains: ['api.github.com', 'api.weatherapi.com'],\n  allowedHttpMethods: ['GET', 'POST'],\n  allowCommandTools: false,\n  allowFunctionTools: false,\n  protectedNamespaces: ['matimo_'],\n  allowedCredentials: ['GITHUB_TOKEN', 'WEATHER_API_KEY']\n};\n\nObject.freeze(policyConfig);  \u002F\u002F ← Now immutable\n\n\u002F\u002F Agent cannot change this, even if it tries\n\u002F\u002F All tools are validated against this frozen policy\n```\n\n## The matimo_doctor Meta-Tool\n\n**matimo_doctor** is the policy validator. It checks tool definitions against:\n1. **Schema validation** — YAML structure is correct\n2. **Policy validation** — Tool complies with security rules\n\n```\nInput:  YAML tool definition (string)\nOutput: { valid: true, ... }  ✅ Safe to use\n    OR: { valid: false, schemaErrors: [...], policyErrors: [...] }  ❌ Blocked\n```\n\n### Example: Valid Tool → Passes Both Checks\n\n```yaml\nname: github_user_lookup\nversion: \"1.0.0\"\ndescription: Look up a GitHub user\nparameters:\n  username:\n    type: string\n    required: true\nexecution:\n  type: http\n  method: GET\n  url: \"https:\u002F\u002Fapi.github.com\u002Fusers\u002F{username}\"\n```\n\n**matimo_doctor result:**\n```json\n{\n  \"valid\": true,\n  \"schemaErrors\": [],\n  \"policyErrors\": []\n}\n```\n\n### Example: Invalid YAML → Schema Error\n\n```yaml\nname: my_tool\n# Missing: version, description, parameters, execution\n```\n\n**matimo_doctor result:**\n```json\n{\n  \"valid\": false,\n  \"schemaErrors\": [\n    {\"field\": \"version\", \"message\": \"Invalid input: expected string, received undefined\"},\n    {\"field\": \"execution\", \"message\": \"Invalid input: expected object, received undefined\"}\n  ],\n  \"policyErrors\": []\n}\n```\n\n### Example: Policy Violation → Policy Error\n\n```yaml\nname: shell_exec\nversion: \"1.0.0\"\nexecution:\n  type: command      # ← Command tools blocked by policy\n  command: bash\n  args: [\"-c\", \"rm -rf \u002F\"]\n```\n\n**matimo_doctor result:**\n```json\n{\n  \"valid\": false,\n  \"schemaErrors\": [],\n  \"policyErrors\": [\n    {\"rule\": \"allowCommandTools\", \"severity\": \"critical\", \"message\": \"Command tools are blocked by policy\"}\n  ]\n}\n```\n\n---\n\n## Policy Rules Reference\n\n### 1. Allowed Domains (HTTP Tools Only)\n\n**What it does:** Restricts HTTP tools to specific domains to prevent abuse.\n\n**Config:**\n```typescript\nallowedDomains: ['api.github.com', 'api.weatherapi.com', 'jsonplaceholder.typicode.com']\n```\n\n**Example: Allowed**\n```yaml\nexecution:\n  type: http\n  url: \"https:\u002F\u002Fapi.github.com\u002Fusers\u002Foctocat\"  ✅ In allowedDomains\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: http\n  url: \"https:\u002F\u002Fbackdoor.attacker.com\u002Fhack\"  ❌ Not in allowedDomains\n\nmatimo_doctor: \"Domain blocked: backdoor.attacker.com not in allowed list\"\n```\n\n---\n\n### 2. Allowed HTTP Methods\n\n**What it does:** Restricts HTTP verbs to prevent unintended data modification.\n\n**Config:**\n```typescript\nallowedHttpMethods: ['GET', 'POST']  \u002F\u002F Common safe methods\n```\n\n**Example: Allowed**\n```yaml\nexecution:\n  type: http\n  method: GET      ✅ In allowedHttpMethods\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: http\n  method: DELETE   ❌ Not in allowedHttpMethods\n\nmatimo_doctor: \"HTTP method DELETE not allowed; must use GET or POST\"\n```\n\n---\n\n### 3. Allow\u002FDisallow Command Tools\n\n**What it does:** Command tools execute shell commands—inherently risky.\n\n**Config:**\n```typescript\nallowCommandTools: false  \u002F\u002F Strongly recommended\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: command\n  command: \"cat \u002Fetc\u002Fpasswd\"  ❌ Commands blocked\n\nmatimo_doctor: \"Command tools are blocked by policy\"\n```\n\n---\n\n### 4. Allow\u002FDisallow Function Tools\n\n**What it does:** Function tools execute arbitrary JavaScript code.\n\n**Config:**\n```typescript\nallowFunctionTools: false  \u002F\u002F Strongly recommended\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: function\n  code: |\n    return require('fs').readFileSync('\u002Fetc\u002Fpasswd');  ❌ Blocked\n\nmatimo_doctor: \"Function tools are blocked by policy\"\n```\n\n---\n\n### 5. Protected Namespaces\n\n**What it does:** Prevents agents from hijacking reserved tool names (matimo_* for built-ins).\n\n**Config:**\n```typescript\nprotectedNamespaces: ['matimo_']\n```\n\n**Example: Allowed**\n```yaml\nname: github_webhook  ✅ Doesn't start with matimo_\n```\n\n**Example: Blocked**\n```yaml\nname: matimo_backdoor  ❌ Tries to hijack reserved namespace\n\nmatimo_doctor: \"Reserved namespace violation: matimo_* is protected for built-in tools\"\n```\n\n---\n\n### 6. Allowed Credentials\n\n**What it does:** Whitelists which environment variables can be used for auth.\n\n**Config:**\n```typescript\nallowedCredentials: ['GITHUB_TOKEN', 'WEATHER_API_KEY']\n```\n\n**Example: Allowed**\n```yaml\nauthentication:\n  type: api_key\n  location: header\n  name: Authorization\n# Uses MATIMO_GITHUB_TOKEN from env  ✅ Whitelisted\n```\n\n**Example: Blocked**\n```yaml\nauthentication:\n  type: api_key\n  location: header\n  name: X-Custom-Secret\n# Uses MATIMO_X_CUSTOM_SECRET from env  ❌ Not whitelisted\n\nmatimo_doctor: \"Credential X_CUSTOM_SECRET not in allowed list\"\n```\n\n---\n\n## Security Patterns Blocked by Policy\n\n### Pattern 1: SSRF (Server-Side Request Forgery)\n\n**Attack:** Probe internal IPs to discover service topology or exploit internal endpoints.\n\n**Blocked ranges:**\n- `169.254.169.254\u002F32` — AWS EC2 metadata service\n- `127.0.0.1\u002F8`, `localhost` — Local machine\n- `10.0.0.0\u002F8`, `172.16.0.0\u002F12`, `192.168.0.0\u002F16` — Private networks\n- `::1`, `fe80::\u002F10` — IPv6 loopback\u002Flink-local\n\n**Example: Attempted Attack**\n```yaml\nname: metadata_probe\nexecution:\n  type: http\n  method: GET\n  url: \"http:\u002F\u002F169.254.169.254\u002Flatest\u002Fmeta-data\u002F\"  ❌ SSRF!\n\nmatimo_doctor: \"SSRF detected: forbidden IP range 169.254.* is not allowed\"\n```\n\n### Pattern 2: Shell Command Execution\n\n**Attack:** Execute arbitrary commands on the host system.\n\n**Example: Attempted Attack**\n```yaml\nname: shell_exec\nexecution:\n  type: command\n  command: bash\n  args: [\"-c\", \"{user_command}\"]  ❌ Dangerous!\n\nmatimo_doctor: \"Command tools are blocked by policy\"\n```\n\n### Pattern 3: Arbitrary Code Execution\n\n**Attack:** Run untrusted JavaScript code with full system access.\n\n**Example: Attempted Attack**\n```yaml\nname: code_executor\nexecution:\n  type: function\n  code: |\n    const fs = require('fs');\n    return fs.readFileSync('\u002Fetc\u002Fpasswd', 'utf8');  ❌ Dangerous!\n\nmatimo_doctor: \"Function tools are blocked by policy\"\n```\n\n### Pattern 4: Namespace Hijacking\n\n**Attack:** Create a tool named `matimo_*` to impersonate a built-in tool.\n\n**Example: Attempted Attack**\n```yaml\nname: matimo_create_tool_backdoor  ❌ Looks like built-in!\n\nmatimo_doctor: \"Reserved namespace violation: matimo_* is protected\"\n```\n\n---\n\n## Using matimo_doctor in Agent Workflows\n\n### Step 1: Validate YAML Before Creating\n\n```\nAgent: \"I'll validate this tool first\"\nAgent: matimo_doctor(yaml_content=\"...\")\nResult: { valid: true } ✅ or { valid: false, errors: [...] } ❌\n```\n\n### Step 2: Understand Errors\n\n```\nIf matimo_doctor returns { valid: false, errors: [...] }:\n\nFor schema errors:\n  - Read field name and message\n  - Fix YAML syntax or missing fields\n  - Re-validate\n\nFor policy errors:\n  - Understand which rule was violated\n  - Redesign tool to comply\n  - Use allowed domains, methods, execution types\n  - Re-validate\n```\n\n### Step 3: Only Create Valid Tools\n\n```\nOnce matimo_doctor returns { valid: true }:\n  Agent: matimo_create_tool(name, yaml_content, target_dir)\n  Result: Tool created on disk, marked as draft\n```\n\n---\n\n## Examples: Learning from Blocked Patterns\n\n### Example 1: Redesign for Policy\n\n**Agent's first attempt (blocked):**\n```yaml\nname: file_system\nexecution:\n  type: command\n  command: cat\n  args: [\"{path}\"]\n# ❌ matimo_doctor: \"Command tools are blocked by policy\"\n```\n\n**Agent learns:** \"I can't use commands; let me use HTTP instead\"\n\n**Agent's redesign (approved):**\n```yaml\nname: file_server_lookup\nexecution:\n  type: http\n  method: GET\n  url: \"https:\u002F\u002Fapi.example.com\u002Ffiles\u002F{file_id}\"\n# ✅ matimo_doctor: { valid: true }\n```\n\n---\n\n### Example 2: Respect Domain Restrictions\n\n**Agent's first attempt (blocked):**\n```yaml\nname: internal_service_caller\nexecution:\n  type: http\n  method: POST\n  url: \"http:\u002F\u002F10.0.0.5:8080\u002Fadmin\"\n# ❌ matimo_doctor: \"SSRF detected: internal IP 10.0.0.5 not allowed\"\n```\n\n**Agent learns:** \"I can't probe internal networks; only public APIs\"\n\n**Agent's redesign (approved):**\n```yaml\nname: public_api_caller\nexecution:\n  type: http\n  method: POST\n  url: \"https:\u002F\u002Fapi.public-service.com\u002Fendpoint\"\n# ✅ matimo_doctor: { valid: true }\n```\n\n---\n\n### Example 3: Avoid Namespace Conflicts\n\n**Agent's first attempt (blocked):**\n```yaml\nname: matimo_my_tool\n# ❌ matimo_doctor: \"Reserved namespace violation: matimo_* is protected\"\n```\n\n**Agent learns:** \"Built-in tools use matimo_*; I need a different name\"\n\n**Agent's redesign (approved):**\n```yaml\nname: my_custom_tool\n# ✅ matimo_doctor: { valid: true }\n```\n\n---\n\n## Policy in Action: Complete Flow\n\n```\nDeveloper deploys Matimo:\n  policyConfig = {\n    allowedDomains: ['api.github.com'],\n    allowCommandTools: false\n  }\n  Object.freeze(policyConfig)\n\nAgent receives goal: \"I need a tool to run bash commands\"\n\nAgent designs: \n  execution: { type: command, command: bash }\n  \nAgent validates:\n  matimo_doctor(yaml) → { valid: false, error: \"Command tools blocked\" }\n\nAgent learns:\n  \"Commands are not allowed; policy is immutable; I must redesign\"\n\nAgent redesigns:\n  execution: { type: http, method: GET, url: \"https:\u002F\u002Fapi.github.com\u002F...\" }\n\nAgent validates:\n  matimo_doctor(yaml) → { valid: true }\n\nAgent creates:\n  matimo_create_tool(...) → Success ✅\n```\n\n---\n\n## Developer Perspective: Setting Policy\n\n```typescript\n\u002F\u002F At initialization time, developer sets immutable policy for their deployment:\n\nconst policyConfig: PolicyConfig = {\n  \u002F\u002F Only these domains can be called\n  allowedDomains: [\n    'api.github.com',\n    'api.slack.com',\n    'jsonplaceholder.typicode.com'  \u002F\u002F Safe test API\n  ],\n  \n  \u002F\u002F Only safe HTTP methods\n  allowedHttpMethods: ['GET', 'POST'],\n  \n  \u002F\u002F Block dangerous execution types\n  allowCommandTools: false,        \u002F\u002F No shell access\n  allowFunctionTools: false,       \u002F\u002F No arbitrary code\n  \n  \u002F\u002F Protect built-in tools\n  protectedNamespaces: ['matimo_'],\n  \n  \u002F\u002F Whitelist auth credentials\n  allowedCredentials: ['GITHUB_TOKEN', 'SLACK_BOT_TOKEN']\n};\n\n\u002F\u002F Freeze it—agents cannot modify\nObject.freeze(policyConfig);\n\nconst matimo = await MatimoInstance.init({\n  policyConfig,  \u002F\u002F ← Immutable policy applied to all tools\n  \u002F\u002F ...\n});\n```\n\n---\n\n## Key Takeaways\n\n1. ✅ **Policy is immutable** — Agents cannot bypass or weaken security rules\n2. ✅ **matimo_doctor enforces policy** — Use it to validate YAML before creating\n3. ✅ **Domains are restricted** — Only allowed APIs can be called\n4. ✅ **Commands and functions are optional** — Developers can block them entirely\n5. ✅ **SSRF is prevented** — Internal IP ranges are blocked by default\n6. ✅ **Namespaces are protected** — `matimo_*` is reserved for built-ins\n7. ✅ **Credentials are whitelisted** — Only approved env vars can be used\n\n---\n\n## References\n\n- **Tool lifecycle**: See `meta-tools-lifecycle` skill\n- **Complete tool creation**: See `tool-creation` skill\n- **Tool discovery**: See `tool-discovery` skill\n\n---\n\n**Last Updated:** March 2026  \n**Status:** Complete  \n**Level:** Intermediate\n","# Policy Validation: Security Rules and Enforcement\n\nThis skill teaches you **Matimo's security policy engine**—a **developer-controlled, object-frozen, non-bypassable** system that blocks dangerous tool patterns before they execute.\n\n## Core Principle: Policy is Immutable\n\nOnce the developer initializes Matimo with a policy configuration, that policy is **frozen** and **cannot be changed by agents**. This ensures:\n\n- ✅ Agents cannot weaken security rules\n- ✅ Agents cannot bypass domain restrictions  \n- ✅ Agents cannot create shell commands if blocked\n- ✅ Policy is transparent and auditable\n\n```typescript\n\u002F\u002F At deploy time, developer sets immutable policy:\nconst policyConfig: PolicyConfig = {\n  allowedDomains: ['api.github.com', 'api.weatherapi.com'],\n  allowedHttpMethods: ['GET', 'POST'],\n  allowCommandTools: false,\n  allowFunctionTools: false,\n  protectedNamespaces: ['matimo_'],\n  allowedCredentials: ['GITHUB_TOKEN', 'WEATHER_API_KEY']\n};\n\nObject.freeze(policyConfig);  \u002F\u002F ← Now immutable\n\n\u002F\u002F Agent cannot change this, even if it tries\n\u002F\u002F All tools are validated against this frozen policy\n```\n\n## The matimo_doctor Meta-Tool\n\n**matimo_doctor** is the policy validator. It checks tool definitions against:\n1. **Schema validation** — YAML structure is correct\n2. **Policy validation** — Tool complies with security rules\n\n```\nInput:  YAML tool definition (string)\nOutput: { valid: true, ... }  ✅ Safe to use\n    OR: { valid: false, schemaErrors: [...], policyErrors: [...] }  ❌ Blocked\n```\n\n### Example: Valid Tool → Passes Both Checks\n\n```yaml\nname: github_user_lookup\nversion: \"1.0.0\"\ndescription: Look up a GitHub user\nparameters:\n  username:\n    type: string\n    required: true\nexecution:\n  type: http\n  method: GET\n  url: \"https:\u002F\u002Fapi.github.com\u002Fusers\u002F{username}\"\n```\n\n**matimo_doctor result:**\n```json\n{\n  \"valid\": true,\n  \"schemaErrors\": [],\n  \"policyErrors\": []\n}\n```\n\n### Example: Invalid YAML → Schema Error\n\n```yaml\nname: my_tool\n# Missing: version, description, parameters, execution\n```\n\n**matimo_doctor result:**\n```json\n{\n  \"valid\": false,\n  \"schemaErrors\": [\n    {\"field\": \"version\", \"message\": \"Invalid input: expected string, received undefined\"},\n    {\"field\": \"execution\", \"message\": \"Invalid input: expected object, received undefined\"}\n  ],\n  \"policyErrors\": []\n}\n```\n\n### Example: Policy Violation → Policy Error\n\n```yaml\nname: shell_exec\nversion: \"1.0.0\"\nexecution:\n  type: command      # ← Command tools blocked by policy\n  command: bash\n  args: [\"-c\", \"rm -rf \u002F\"]\n```\n\n**matimo_doctor result:**\n```json\n{\n  \"valid\": false,\n  \"schemaErrors\": [],\n  \"policyErrors\": [\n    {\"rule\": \"allowCommandTools\", \"severity\": \"critical\", \"message\": \"Command tools are blocked by policy\"}\n  ]\n}\n```\n\n---\n\n## Policy Rules Reference\n\n### 1. Allowed Domains (HTTP Tools Only)\n\n**What it does:** Restricts HTTP tools to specific domains to prevent abuse.\n\n**Config:**\n```typescript\nallowedDomains: ['api.github.com', 'api.weatherapi.com', 'jsonplaceholder.typicode.com']\n```\n\n**Example: Allowed**\n```yaml\nexecution:\n  type: http\n  url: \"https:\u002F\u002Fapi.github.com\u002Fusers\u002Foctocat\"  ✅ In allowedDomains\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: http\n  url: \"https:\u002F\u002Fbackdoor.attacker.com\u002Fhack\"  ❌ Not in allowedDomains\n\nmatimo_doctor: \"Domain blocked: backdoor.attacker.com not in allowed list\"\n```\n\n---\n\n### 2. Allowed HTTP Methods\n\n**What it does:** Restricts HTTP verbs to prevent unintended data modification.\n\n**Config:**\n```typescript\nallowedHttpMethods: ['GET', 'POST']  \u002F\u002F Common safe methods\n```\n\n**Example: Allowed**\n```yaml\nexecution:\n  type: http\n  method: GET      ✅ In allowedHttpMethods\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: http\n  method: DELETE   ❌ Not in allowedHttpMethods\n\nmatimo_doctor: \"HTTP method DELETE not allowed; must use GET or POST\"\n```\n\n---\n\n### 3. Allow\u002FDisallow Command Tools\n\n**What it does:** Command tools execute shell commands—inherently risky.\n\n**Config:**\n```typescript\nallowCommandTools: false  \u002F\u002F Strongly recommended\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: command\n  command: \"cat \u002Fetc\u002Fpasswd\"  ❌ Commands blocked\n\nmatimo_doctor: \"Command tools are blocked by policy\"\n```\n\n---\n\n### 4. Allow\u002FDisallow Function Tools\n\n**What it does:** Function tools execute arbitrary JavaScript code.\n\n**Config:**\n```typescript\nallowFunctionTools: false  \u002F\u002F Strongly recommended\n```\n\n**Example: Blocked**\n```yaml\nexecution:\n  type: function\n  code: |\n    return require('fs').readFileSync('\u002Fetc\u002Fpasswd');  ❌ Blocked\n\nmatimo_doctor: \"Function tools are blocked by policy\"\n```\n\n---\n\n### 5. Protected Namespaces\n\n**What it does:** Prevents agents from hijacking reserved tool names (matimo_* for built-ins).\n\n**Config:**\n```typescript\nprotectedNamespaces: ['matimo_']\n```\n\n**Example: Allowed**\n```yaml\nname: github_webhook  ✅ Doesn't start with matimo_\n```\n\n**Example: Blocked**\n```yaml\nname: matimo_backdoor  ❌ Tries to hijack reserved namespace\n\nmatimo_doctor: \"Reserved namespace violation: matimo_* is protected for built-in tools\"\n```\n\n---\n\n### 6. Allowed Credentials\n\n**What it does:** Whitelists which environment variables can be used for auth.\n\n**Config:**\n```typescript\nallowedCredentials: ['GITHUB_TOKEN', 'WEATHER_API_KEY']\n```\n\n**Example: Allowed**\n```yaml\nauthentication:\n  type: api_key\n  location: header\n  name: Authorization\n# Uses MATIMO_GITHUB_TOKEN from env  ✅ Whitelisted\n```\n\n**Example: Blocked**\n```yaml\nauthentication:\n  type: api_key\n  location: header\n  name: X-Custom-Secret\n# Uses MATIMO_X_CUSTOM_SECRET from env  ❌ Not whitelisted\n\nmatimo_doctor: \"Credential X_CUSTOM_SECRET not in allowed list\"\n```\n\n---\n\n## Security Patterns Blocked by Policy\n\n### Pattern 1: SSRF (Server-Side Request Forgery)\n\n**Attack:** Probe internal IPs to discover service topology or exploit internal endpoints.\n\n**Blocked ranges:**\n- `169.254.169.254\u002F32` — AWS EC2 metadata service\n- `127.0.0.1\u002F8`, `localhost` — Local machine\n- `10.0.0.0\u002F8`, `172.16.0.0\u002F12`, `192.168.0.0\u002F16` — Private networks\n- `::1`, `fe80::\u002F10` — IPv6 loopback\u002Flink-local\n\n**Example: Attempted Attack**\n```yaml\nname: metadata_probe\nexecution:\n  type: http\n  method: GET\n  url: \"http:\u002F\u002F169.254.169.254\u002Flatest\u002Fmeta-data\u002F\"  ❌ SSRF!\n\nmatimo_doctor: \"SSRF detected: forbidden IP range 169.254.* is not allowed\"\n```\n\n### Pattern 2: Shell Command Execution\n\n**Attack:** Execute arbitrary commands on the host system.\n\n**Example: Attempted Attack**\n```yaml\nname: shell_exec\nexecution:\n  type: command\n  command: bash\n  args: [\"-c\", \"{user_command}\"]  ❌ Dangerous!\n\nmatimo_doctor: \"Command tools are blocked by policy\"\n```\n\n### Pattern 3: Arbitrary Code Execution\n\n**Attack:** Run untrusted JavaScript code with full system access.\n\n**Example: Attempted Attack**\n```yaml\nname: code_executor\nexecution:\n  type: function\n  code: |\n    const fs = require('fs');\n    return fs.readFileSync('\u002Fetc\u002Fpasswd', 'utf8');  ❌ Dangerous!\n\nmatimo_doctor: \"Function tools are blocked by policy\"\n```\n\n### Pattern 4: Namespace Hijacking\n\n**Attack:** Create a tool named `matimo_*` to impersonate a built-in tool.\n\n**Example: Attempted Attack**\n```yaml\nname: matimo_create_tool_backdoor  ❌ Looks like built-in!\n\nmatimo_doctor: \"Reserved namespace violation: matimo_* is protected\"\n```\n\n---\n\n## Using matimo_doctor in Agent Workflows\n\n### Step 1: Validate YAML Before Creating\n\n```\nAgent: \"I'll validate this tool first\"\nAgent: matimo_doctor(yaml_content=\"...\")\nResult: { valid: true } ✅ or { valid: false, errors: [...] } ❌\n```\n\n### Step 2: Understand Errors\n\n```\nIf matimo_doctor returns { valid: false, errors: [...] }:\n\nFor schema errors:\n  - Read field name and message\n  - Fix YAML syntax or missing fields\n  - Re-validate\n\nFor policy errors:\n  - Understand which rule was violated\n  - Redesign tool to comply\n  - Use allowed domains, methods, execution types\n  - Re-validate\n```\n\n### Step 3: Only Create Valid Tools\n\n```\nOnce matimo_doctor returns { valid: true }:\n  Agent: matimo_create_tool(name, yaml_content, target_dir)\n  Result: Tool created on disk, marked as draft\n```\n\n---\n\n## Examples: Learning from Blocked Patterns\n\n### Example 1: Redesign for Policy\n\n**Agent's first attempt (blocked):**\n```yaml\nname: file_system\nexecution:\n  type: command\n  command: cat\n  args: [\"{path}\"]\n# ❌ matimo_doctor: \"Command tools are blocked by policy\"\n```\n\n**Agent learns:** \"I can't use commands; let me use HTTP instead\"\n\n**Agent's redesign (approved):**\n```yaml\nname: file_server_lookup\nexecution:\n  type: http\n  method: GET\n  url: \"https:\u002F\u002Fapi.example.com\u002Ffiles\u002F{file_id}\"\n# ✅ matimo_doctor: { valid: true }\n```\n\n---\n\n### Example 2: Respect Domain Restrictions\n\n**Agent's first attempt (blocked):**\n```yaml\nname: internal_service_caller\nexecution:\n  type: http\n  method: POST\n  url: \"http:\u002F\u002F10.0.0.5:8080\u002Fadmin\"\n# ❌ matimo_doctor: \"SSRF detected: internal IP 10.0.0.5 not allowed\"\n```\n\n**Agent learns:** \"I can't probe internal networks; only public APIs\"\n\n**Agent's redesign (approved):**\n```yaml\nname: public_api_caller\nexecution:\n  type: http\n  method: POST\n  url: \"https:\u002F\u002Fapi.public-service.com\u002Fendpoint\"\n# ✅ matimo_doctor: { valid: true }\n```\n\n---\n\n### Example 3: Avoid Namespace Conflicts\n\n**Agent's first attempt (blocked):**\n```yaml\nname: matimo_my_tool\n# ❌ matimo_doctor: \"Reserved namespace violation: matimo_* is protected\"\n```\n\n**Agent learns:** \"Built-in tools use matimo_*; I need a different name\"\n\n**Agent's redesign (approved):**\n```yaml\nname: my_custom_tool\n# ✅ matimo_doctor: { valid: true }\n```\n\n---\n\n## Policy in Action: Complete Flow\n\n```\nDeveloper deploys Matimo:\n  policyConfig = {\n    allowedDomains: ['api.github.com'],\n    allowCommandTools: false\n  }\n  Object.freeze(policyConfig)\n\nAgent receives goal: \"I need a tool to run bash commands\"\n\nAgent designs: \n  execution: { type: command, command: bash }\n  \nAgent validates:\n  matimo_doctor(yaml) → { valid: false, error: \"Command tools blocked\" }\n\nAgent learns:\n  \"Commands are not allowed; policy is immutable; I must redesign\"\n\nAgent redesigns:\n  execution: { type: http, method: GET, url: \"https:\u002F\u002Fapi.github.com\u002F...\" }\n\nAgent validates:\n  matimo_doctor(yaml) → { valid: true }\n\nAgent creates:\n  matimo_create_tool(...) → Success ✅\n```\n\n---\n\n## Developer Perspective: Setting Policy\n\n```typescript\n\u002F\u002F At initialization time, developer sets immutable policy for their deployment:\n\nconst policyConfig: PolicyConfig = {\n  \u002F\u002F Only these domains can be called\n  allowedDomains: [\n    'api.github.com',\n    'api.slack.com',\n    'jsonplaceholder.typicode.com'  \u002F\u002F Safe test API\n  ],\n  \n  \u002F\u002F Only safe HTTP methods\n  allowedHttpMethods: ['GET', 'POST'],\n  \n  \u002F\u002F Block dangerous execution types\n  allowCommandTools: false,        \u002F\u002F No shell access\n  allowFunctionTools: false,       \u002F\u002F No arbitrary code\n  \n  \u002F\u002F Protect built-in tools\n  protectedNamespaces: ['matimo_'],\n  \n  \u002F\u002F Whitelist auth credentials\n  allowedCredentials: ['GITHUB_TOKEN', 'SLACK_BOT_TOKEN']\n};\n\n\u002F\u002F Freeze it—agents cannot modify\nObject.freeze(policyConfig);\n\nconst matimo = await MatimoInstance.init({\n  policyConfig,  \u002F\u002F ← Immutable policy applied to all tools\n  \u002F\u002F ...\n});\n```\n\n---\n\n## Key Takeaways\n\n1. ✅ **Policy is immutable** — Agents cannot bypass or weaken security rules\n2. ✅ **matimo_doctor enforces policy** — Use it to validate YAML before creating\n3. ✅ **Domains are restricted** — Only allowed APIs can be called\n4. ✅ **Commands and functions are optional** — Developers can block them entirely\n5. ✅ **SSRF is prevented** — Internal IP ranges are blocked by default\n6. ✅ **Namespaces are protected** — `matimo_*` is reserved for built-ins\n7. ✅ **Credentials are whitelisted** — Only approved env vars can be used\n\n---\n\n## References\n\n- **Tool lifecycle**: See `meta-tools-lifecycle` skill\n- **Complete tool creation**: See `tool-creation` skill\n- **Tool discovery**: See `tool-discovery` skill\n\n---\n\n**Last Updated:** March 2026  \n**Status:** Complete  \n**Level:** Intermediate\n",{"name":5,"metadata":24,"description":7},{"apply-to":25,"category":26,"difficulty":27},"matimo_doctor matimo_validate_tool","Security & Policy","intermediate","main","3ace42f8c811a205651ca8cf53bc2608abffc266","typescript\u002Fpackages\u002Fcore\u002Fskills\u002Fpolicy-validation",1,"https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo","https:\u002F\u002Fgithub.com\u002Freview-bench","https:\u002F\u002Freview-bench.ai","An open benchmark for AI code review.","2026-10-27 08:01:51",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add review-bench\u002Ftallclub_matimo --skill policy-validation",{"tool":43,"command":44},"bunx","bunx skills add review-bench\u002Ftallclub_matimo --skill policy-validation",{"tool":46,"command":47},"pnpm","pnpm dlx skills add review-bench\u002Ftallclub_matimo --skill policy-validation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fcore\u002Fskills\u002Fpolicy-validation\u002FSKILL.md",true,[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M752QFT5TGZZ68013YTNW8J3","twilio","Complete guide to all Twilio tools — text, media, delivery tracking, E.164 formatting, and message management.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Ftwilio\u002Fskills\u002Ftwilio\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M752QAKQFZKM84MN9R5334VX","slack","Complete guide to all Slack tools — messaging, channels, users, search, files, reactions, and threads.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fslack\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M752Q60H6SQAHAH9BB2MZQN6","postgres","Complete guide to all PostgreSQL tools — parameterized queries, schema navigation, data retrieval, and safe database interaction patterns.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fpostgres\u002Fskills\u002Fpostgres\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M752Q2700VY1QWPACWX8AVFQ","notion","Complete guide to all Notion tools — databases, pages, blocks, queries, and content management.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fnotion\u002Fskills\u002Fnotion\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M752PZ82SCVF6H1GPKQ54JWR","mailchimp","Complete guide to all Mailchimp tools — campaigns, audiences, lists, templates, segments, and email marketing.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fmailchimp\u002Fskills\u002Fmailchimp\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M752PQW4F1SP8DXQMFMYKDBK","hubspot","Complete guide to all HubSpot CRM tools — contacts, companies, deals, tickets, products, line items, pipelines, and entity management.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Ftallclub_matimo\u002Fblob\u002Fmain\u002Ftypescript\u002Fpackages\u002Fhubspot\u002Fskills\u002Fhubspot\u002FSKILL.md",[],[]]