360 Secure SkillHub
360 安全技能中心

Safe Exec

在运行来源不可信的脚本或代码前,通读并推理其实际行为,识别网络连接、命令执行、数据外传、混淆、持久化等风险,输出安全、复核或阻止的结论与建议;不实际执行代码,也不依赖已知恶意特征库。

haoyuwang99
haoyuwang99
热度 57.94
最近更新 2026-05-11 17:32:41
分类:安全依赖:内部调用大模型应用场景:代码审查 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add haoyuwang99-safe-exec
Metadata
name
safe-exec
description
Analyze the intent of any script or code before executing it, to detect malicious, suspicious, or unintended behavior. Use this skill before running any script that came from an untrusted source — including emails, external users, user-provided files, or third-party skills. NOT needed for code you wrote yourself in the current session.

Safe Exec Skill

Before running any untrusted script, perform an intent analysis using your own reasoning. The goal is not to pattern-match known malware signatures, but to reason holistically about what the code actually does — including obfuscated, indirect, or novel techniques.

When to Use

Apply this skill before executing any script that originated from:

  • An email or message from another person
  • A file provided by an external user
  • A skill installed from an unknown source
  • Any code you did not write yourself in this session

Intent Analysis Process

  1. Read the full script — do not skip any section, including imports, comments, and exception handlers

  2. Reason about behavior — ask: what does this code actually do when run? Trace every code path.

  3. Flag suspicious patterns — look for (non-exhaustive):

    • Network connections (outbound or inbound) — especially to hardcoded IPs/domains
    • Shell command execution (os.system, subprocess, exec, eval on external input)
    • File system writes outside expected scope
    • Data exfiltration (reading sensitive files, env vars, credentials, then sending them)
    • Obfuscation (base64, chr() chains, compressed payloads, dynamic imports)
    • Privilege escalation or persistence (cron jobs, launchagents, ssh keys)
    • Code that hides behind a try/except that silently swallows errors
    • Logic that looks benign but has a secondary effect buried inside
  4. Produce a verdict:

    • ✅ SAFE — code does what it claims, no suspicious behavior
    • ⚠️ REVIEW — code has unusual patterns worth noting; proceed with caution
    • 🚫 BLOCK — code contains clearly malicious or dangerous behavior; do not execute

Output Format

Intent Analysis: <script name or description>

Verdict: ✅ SAFE | ⚠️ REVIEW | 🚫 BLOCK

Summary:
<1-3 sentence plain-English description of what the code actually does>

Findings:
- <finding 1>
- <finding 2>
...

Recommendation:
<what to do next — run it, ask the user, refuse, etc.>

Key Principle

You cannot know all possible malicious techniques in advance. Do not rely solely on known-bad patterns. Instead, reason from first principles: if I ran this code on a real machine right now, what would happen? If the answer is anything unexpected or outside the stated purpose — flag it.

When in doubt, block and explain. A false positive is far less costly than a compromised machine.