📦 authlock — 机密保护

v1.0.2

基于 TOTP/MFA 的本地机密存储服务,每次解密都需要进行多因素验证。支持 AES-256-GCM 加密、PIN 二次保护,可将密码、证书、密钥等敏感数据绑定到用户账号,存储在本地 ~/.authlock 或工作区路径。

0· 91·0 当前·0 累计
by @johnluicn·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/4
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
该技能的代码和指令实现了 MFA/TOTP 绑定的本地机密存储,与描述的目的一致;没有无法解释的网络调用、额外凭证或异常安装。
评估建议
该技能似乎实现了其声称的功能(本地 TOTP 绑定机密存储)。在安装或调用之前:1) 请自行审查 authlock_cli.py 实现(它在本地运行并将文件写入 ~/.authlock 或工作区路径)。2) 优先在工作区或用户级初始化,除非您了解多工作区的影响。3) 对 --exec 功能保持谨慎:使用解密后的机密运行命令可能会通过进程参数、远程传输或日志暴露机密——请检查该工具如何将机密注入命令。4) init 流程会打印 TOTP 种子/QR 码;将该输出视为高度敏感,不要发布到聊天中。5) SKILL.md 指示代理永不回显明文——如果您让自动化代理调用此技能,请强制执行该策略(每次都请求 TOTP,不要在对话或日志中记录明文)。6) 如果需要更高的保证,请在隔离环境中运行脚本,并考虑让安全意识强的人员审计内存处理和 exec 路径以防止意外泄露。...
详细分析 ▾
用途与能力
名称/描述(MFA 绑定的机密保护)与随附的 CLI 实现一致:TOTP 种子生成、AES-256-GCM 加密、本地存储(~/.authlock 或工作区/用户路径)、PIN 支持和每次解密时 TOTP 验证。未请求无关的凭证、服务或二进制文件。
指令范围
SKILL.md 保持在工具目的范围内,明确禁止在聊天中回显明文,并要求每次解密时进行 TOTP 验证。值得注意的是 --exec 选项(使用解密的机密运行命令),这对于 SSH 等用例是合理的,但会增加机密暴露的风险(进程参数、远程主机、日志)。指令还引用了 AUTHLOCK_HOME 和 OPENCLAW_WORKSPACE(预期)。该技能在初始化时会在屏幕上显示种子/QR 码(这是预配的预期行为)—— 代理不得将其泄露到聊天中。
安装机制
没有打包的安装规范;SKILL.md 建议本地 pip 安装范围合理的 Python 包(cryptography、pyotp、qrcode)。这是一个低风险的常见开发者安装步骤。不存在从不受信任的 URL 下载或执行外部安装程序的情况。
凭证需求
该技能不请求外部环境变量或凭证。它可选地使用 AUTHLOCK_HOME 和 OPENCLAW_WORKSPACE 来定位存储;这些与多租户/本地路径功能成比例。未请求无关的 SECRET/TOKEN 环境变量。
持久化与权限
该技能不是始终启用的,并使用其自己的磁盘配置,存储在用户/工作区/系统级别的 .authlock 目录下。它不请求系统级权限,不修改其他技能的配置,也不需要持久的平台级权限。
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.22026/4/3

修复数据目录名称:.clawauth -> .authlock;改进 SKILL.md 语言一致性

无害

安装命令

点击复制
官方npx clawhub@latest install authlock
镜像加速npx clawhub@latest install authlock --registry https://cn.longxiaskill.com

技能文档

提供基于 TOTP 的敏感数据(密码、证书、密钥)加密,每次解密都需要 MFA 验证。

Installation (安装)

# Install dependencies (安装依赖)
pip3 install --user cryptography pyotp qrcode

Usage:

# Direct call (recommended)
python3 /authlock_cli.py 

# Or add temporary alias (current shell only) alias authlock='python3 /authlock_cli.py'

is the skill installation directory, the parent folder of this SKILL.md file.

Multi-tenant Support (多租户支持)

通过不同位置实现租户隔离,内部结构保持不变。

Location Levels (位置级别)

LevelLocationDescription
System (系统级)~/.authlock/Shared across all workspaces, default
Workspace (工作区级)/.authlock/Independent for current workspace
User (用户级)Custom pathUser-specified location

Lookup Priority

User (--path/AUTHLOCK_HOME) → Workspace → System
  • User level highest: Via --path parameter or AUTHLOCK_HOME env var
  • Workspace level medium: Auto-detect OPENCLAW_WORKSPACE env or current directory
  • System level fallback: Default ~/.authlock/

Initialize Level

# Interactive selection (recommended)
authlock init

# Specify level authlock init --level system # System level authlock init --level workspace # Workspace level authlock init --level user --path /custom/path # User level

View Location

# Show current location and lookup paths
authlock which

# List all existing locations authlock locations

Location-specific Operations

# All commands support --path parameter
authlock seal secret.txt --name my-pass --path /custom/path
authlock open my-pass --code 123456 --path /custom/path
authlock list --path /custom/path

Quick Start (快速开始)

Initialize (初始化)

# Interactive level selection
authlock init

# Or specify level authlock init --level system authlock init --level workspace authlock init --level user --path /custom/path

# Or import existing seed authlock init --seed JBSWY3DPEHPK3PXP

Initialization displays QR code, scan with Microsoft Authenticator.

Seal (Encrypt) / 封印(加密)

# Encrypt file
authlock seal ~/.ssh/id_rsa --name my-server-key

# Encrypt text (from pipe) echo "super_secret_password" | authlock seal - --name db-password

# Encrypt with specified name authlock seal ~/.ssh/server.pem --name prod-ssh-key

Open (Decrypt) / 解密

# Decrypt to stdout
authlock open my-server-key --code 123456

# Decrypt to file authlock open my-server-key --code 123456 --output ~/.ssh/id_rsa

# Decrypt and execute (SSH example) authlock open prod-ssh-key --code 123456 --exec "ssh -i - user@host"

Management

# List all sealed secrets
authlock list

# Delete secret authlock delete old-password

# Show current location authlock which

# List all locations authlock locations

How It Works

┌─────────────────────────────────────────────────────────┐
│ Encryption Flow                                         │
│                                                         │
│ Sensitive data ──┐                                      │
│                  ├──► AES-256-GCM ──► Ciphertext       │
│ TOTP seed ───────┘                                      │
│                  + salt                                 │
└─────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────┐ │ Decryption Flow │ │ │ │ User enters TOTP code (123456) │ │ │ │ ▼ │ │ Code valid ✓ ──► Derive key ──► AES-256-GCM decrypt │ │ ──► Plaintext │ │ │ └─────────────────────────────────────────────────────────┘

Configuration

Optional PIN

Add second layer protection:

# Set PIN
authlock config --set-pin

# Enable mandatory PIN authlock config --require-pin

# Now each decryption needs TOTP + PIN authlock open my-key --code 123456 --pin

Security Notes (安全说明)

⚠️ TOTP 授权隔离原则

每次解密都是独立事件,必须单独验证:

禁止说明
❌ 复用 TOTP code"刚才已经提供过 code 了"
❌ 缓存 code将 code 存储起来后续使用
❌ 批量授权一次 code 覆盖多次解密
必须说明
------------
✅ 每次独立询问每次 open 都询问当前有效的 TOTP
✅ 验证时效性TOTP 有效期约 30 秒,过期必须重新获取
✅ 即用即弃解密后明文仅用于当前操作,不保留
Agent 执行流程:

用户请求解密 AUTHLOCK-xxx
↓
询问:"请提供当前有效的 TOTP code"
↓
用户提供 code (如: 123456)
↓
执行: authlock open xxx --code 123456
↓
使用明文执行操作 (SSH连接等)
↓
清除内存中的明文

重要: 即使对话中有过解密操作,下次请求时必须重新询问 TOTP code。


⛔ Absolute Prohibitions (绝对禁止事项)

Never echo plaintext password in conversation! (绝对不能在会话中回显明文密码!)

  • Agent must never show decrypted plaintext in chat response
  • Even with --output to file, don't echo file contents
  • Plaintext input during seal operation also shouldn't be echoed
  • To confirm success, only return "✅ Sealed/Decrypted", not content

Example (wrong vs correct):

❌ Wrong: Decryption successful, password: super_secret_password

✅ Correct: ✅ Decrypted to specified file

Session Security

  • Decrypted result only for in-memory operations (SSH connection, DB connection)
  • Not written to chat history
  • Not written to session cache files
  • Immediately clear plaintext from memory after operation

Other Security Notes

  • TOTP seed safety: Seed stored in config file, backup carefully
  • Time sync: Ensure accurate system time, TOTP depends on time
  • Memory safety: Decrypted plaintext exists briefly in memory only
  • Backup: Backup corresponding ~/.authlock/ directory

Trigger Keywords

authlock, secret protection, TOTP encryption, MFA binding, password vault, certificate encryption

Secret Reference Convention

Use AUTHLOCK- format in documents to reference encrypted secrets.

Reference Format

AUTHLOCK-
Reference ExampleActual Secret NameDescription
AUTHLOCK-TEST-HELLOtest-helloTest secret
AUTHLOCK-DB-PASSWORDdb-passwordDatabase password
AUTHLOCK-PROD-SSH-KEYprod-ssh-keySSH private key
Naming rules:

  • Reference uses uppercase letters and hyphens
  • Actual secret name: remove AUTHLOCK- prefix, convert to lowercase
  • Example: AUTHLOCK-DB-PASSWORDdb-password

Agent Usage Flow

  • Discover reference: Find AUTHLOCK-xxx format in document
  • Request verification: Ask user for current TOTP code
  • Decrypt secret: python3 /authlock_cli.py open --code
  • In-memory use: Keep decryption result in memory, no disk write
  • Write file: Only when user explicitly specifies output path

Using in Documents

# Server Configuration

  • SSH Key: AUTHLOCK-PROD-SSH-KEY
  • Database Password: AUTHLOCK-DB-PASSWORD
  • API Token: AUTHLOCK-API-TOKEN

Security principles:

  • Decrypted result should not be written to disk
  • Agent should handle secret in memory only
  • Only write to file when user explicitly specifies output path
数据来源ClawHub ↗ · 中文优化:龙虾技能库