Agent Hardening Skill
Self-contained security tests for OpenClaw agents. All checks use synthetic data — no local files, configs, or memory directories are accessed.
Checks
1. Unicode Control Character Sanitization
Tests whether your agent's environment properly strips invisible unicode characters:
CODEBLOCK0
2. HTML Comment Injection Detection
Tests whether hidden HTML directives are detected in input:
CODEBLOCK1
3. Bidi Override Detection
Tests for bidirectional text override characters that can disguise filenames:
CODEBLOCK2
4. Threat Definitions
Compare your findings against known threat patterns maintained by the community:
https://github.com/x1xhlol/agent-hardening
Notes
- - All tests use hardcoded synthetic samples
- No local files, directories, or configs are accessed
- No data is transmitted externally
- No dependencies required beyond Python 3
Author
ZeroLeaks Security Research — zeroleaks.ai
技能名称: agent-hardening
Agent 加固技能
面向 OpenClaw 代理的独立安全测试。所有检查均使用合成数据——不访问任何本地文件、配置或内存目录。
检查项
1. Unicode 控制字符净化
测试代理环境是否正确过滤不可见 Unicode 字符:
bash
python3 -c
import unicodedata
sanitize = lambda t: .join(c for c in t if unicodedata.category(c) != Cf)
samples = [
(零宽连字, Hello\u200dWorld),
(零宽不连字, Test\u200cData),
(不可见分隔符, Foo\u2063Bar),
(BOM 注入, \ufeffCommand),
]
passed = 0
for name, test in samples:
clean = sanitize(test)
ok = len(clean) < len(test)
passed += ok
print(f {\✅\ if ok else \⚠️\} {name}: {len(test)} → {len(clean)} 字符)
print(f\n结果: {passed}/{len(samples)} 项检查通过)
2. HTML 注释注入检测
测试输入中是否检测到隐藏的 HTML 指令:
bash
python3 -c
import re
samples = [
普通文本 更多文本,
无隐藏指令的干净内容,
数据 结束,
]
pattern = re.compile(r, re.DOTALL)
for s in samples:
matches = pattern.findall(s)
if matches:
print(f⚠️ 发现隐藏指令: {matches[0][:40]}...)
else:
print(f✅ 干净: {s[:50]})
3. 双向文本覆盖检测
测试是否存在可伪装文件名的双向文本覆盖字符:
bash
python3 -c
import unicodedata
bidi_overrides = {\u202a, \u202b, \u202c, \u202d, \u202e, \u2066, \u2067, \u2068, \u2069}
samples = [
(正常文件名, document.pdf),
(双向伪造, document\u202eFDP.txt),
(干净路径, /home/user/notes.md),
]
for name, test in samples:
found = [c for c in test if c in bidi_overrides]
if found:
print(f⚠️ {name}: 检测到双向覆盖 U+{ord(found[0]):04X})
else:
print(f✅ {name}: 干净)
4. 威胁定义
将您的发现与社区维护的已知威胁模式进行对比:
https://github.com/x1xhlol/agent-hardening
备注
- - 所有测试均使用硬编码的合成样本
- 不访问任何本地文件、目录或配置
- 不传输任何外部数据
- 除 Python 3 外无需其他依赖
作者
ZeroLeaks 安全研究 — zeroleaks.ai