微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🔐

敏感操作前强制TOTP身份验证

Otp Challenger · v1.0.0
security-identity 安全 A 级 榜单 #1 作者 ryancnelson 公开目录收录
下载 2.8k 安装 0 收藏 9.1k 浏览 4
下载 Skill

简介

基于TOTP的身份验证技能,在执行部署、转账、数据访问等敏感操作前强制要求用户二次确认,提供24小时验证窗口和状态检查机制。

原始描述

Enable agents and skills to challenge users for fresh two-factor authentication proof (TOTP or YubiKey) before executing sensitive actions. Use this for identity verification in approval workflows - deploy commands, financial operations, data access, admin operations, and change control.

通过你的 Agent 添加

把这个链接发给你正在用的 Agent,让它自己下载安装:

或者手动装到对应目录

Claude Code~/.claude/skills/otp-challenger/
其它 Agent解压到它自己的 skills 目录即可

技能包里是 SKILL.md 加它附带的文件,解压后目录名就是技能名。 不同 Agent 的 skills 目录位置以各自文档为准;技能申请的权限由作者决定,装前请确认它要读什么、能执行什么。

中文使用说明 来自收录源

核心用法

OTP Skill 是一个为 OpenClaw 生态设计的身份验证中间件,允许任何 Skill 在执行敏感操作前强制要求用户输入 TOTP(基于时间的一次性密码)验证码。核心工作流程为:

  1. 验证触发:敏感操作 Skill 调用 verify.sh <user_id> <code> 发起身份挑战
  2. 本地校验:与存储的 Base32 密钥比对,采用 RFC 6238 标准 TOTP 算法(HMAC-SHA1,30秒窗口)
  3. 状态管理:验证通过后写入 memory/otp-state.json,记录验证时间戳与过期时间
  4. 时效检查:后续操作通过 check-status.sh 查询验证是否在有效期内(默认24小时)

显著优点

  • 零网络依赖:纯本地运算,无外部 API 调用,彻底杜绝数据外泄风险
  • 标准合规:严格遵循 RFC 6238 TOTP 标准,兼容 Google Authenticator、Authy、1Password、Bitwarden 等主流应用
  • 灵活集成:通过 source 方式嵌入其他 Skill,两行代码即可为任意 Bash 脚本添加身份验证层
  • 隐私最小化:仅持久化时间戳,不存储任何用户身份或验证码信息,符合 GDPR 最小化原则
  • 防御暴力破解:内置速率限制与文件锁机制,防止竞态条件和暴力破解
  • 企业级密钥管理:支持环境变量、1Password/Bitwarden 密钥引用,避免硬编码

潜在缺点与局限性

  • T3 来源级别:维护者为个人开发者(Ryan Nelson),非知名组织,重大更新需人工代码审查
  • 依赖管理风险:Node.js 版本依赖 otpauth npm 包,需手动关注安全更新,缺乏 package.json 锁定机制
  • 配置解析不一致:get-current-code.sh 使用 grep 正则提取 YAML 配置,存在解析错误风险(verify.sh 已使用 Python 安全解析)
  • 状态文件权限未加固:创建 otp-state.json 时未显式设置 0600 权限,多用户环境存在信息泄露隐患
  • 无内置审计日志:虽支持外部日志记录,但 Skill 本身不自动写入 syslog 或结构化日志
  • 时钟同步依赖:TOTP 有效性依赖系统时间 NTP 同步,时钟漂移会导致验证失败

适合人群

  • DevOps/平台工程师:为 kubectl、Terraform、Ansible 等部署脚本添加强制审批流程
  • 安全管理员:在 AI Agent 环境中实施最小权限原则,防止会话劫持导致的越权操作
  • 财务/合规团队:为自动转账、报表导出、敏感数据访问等操作建立密码学级身份证明
  • 个人高阶用户:为自建 OpenClaw 实例添加企业级安全层,保护云基础设施

常规风险

风险类型 说明 缓解措施
密钥泄露 若攻击者获取 shell 访问权限,可读取 OTP_SECRET 环境变量或配置文件 使用 1Password/Bitwarden 密钥引用,限制文件系统权限
钓鱼攻击 用户可能被诱骗在非预期场景输入 OTP 码 严格遵循 Skill 设计哲学,仅对真正敏感操作挑战用户,并明确提示验证原因
设备丢失 认证设备(手机)被盗后,攻击者可生成有效验证码 结合其他因素(如 IP 白名单、硬件密钥)构建纵深防御
重放攻击 截获的 OTP 码在 30 秒内可重复使用 单次验证后即更新状态,同一验证码无法通过重复验证
社会工程学 攻击者伪装成 Agent 诱导用户执行 /otp 命令 建立明确的操作语境,避免在聊天界面滥用 OTP 提示

使用建议

遵循其设计哲学「OTP 应在需要时显而易见,不需要时完全隐形」,避免对每个命令都挑战用户导致「安全疲劳」。建议配置 8-12 小时的 intervalHours,配合 15 分钟 gracePeriodMinutes,在安全性与用户体验间取得平衡。生产环境部署前,建议审查 GitHub 仓库最新 commit,确认无恶意变更后再启用。

技能正文


name: otp description: Enable agents and skills to challenge users for fresh two-factor authentication proof before executing sensitive actions. Use this for identity verification in approval workflows - deploy commands, financial operations, data access, admin operations, and change control. metadata: {"openclaw": {"emoji": "🔐", "homepage": "https://github.com/ryancnelson/otp-skill", "requires": {"bins": ["jq", "python3"], "anyBins": ["oathtool", "node"]}, "install": [{"id": "jq", "kind": "brew", "formula": "jq", "bins": ["jq"], "label": "Install jq via Homebrew", "os": ["darwin", "linux"]}, {"id": "python3", "kind": "brew", "formula": "python3", "bins": ["python3"], "label": "Install Python 3 via Homebrew", "os": ["darwin", "linux"]}, {"id": "oathtool", "kind": "brew", "formula": "oath-toolkit", "bins": ["oathtool"], "label": "Install OATH Toolkit via Homebrew", "os": ["darwin", "linux"]}]}}

OTP Identity Challenge Skill

Purpose: Enable agents and skills to challenge users for fresh two-factor authentication proof before executing sensitive actions.

What This Is For

This skill provides identity verification for approval workflows. When your agent needs to execute a command with change-control concerns (deploying code, modifying infrastructure, accessing sensitive data, financial transactions), it can challenge the user to prove their identity with a time-based one-time password (TOTP).

This is not about securing your chat channel—it's about verifying identity before specific actions.

Use Cases

  • Deploy commands: Require fresh 2FA before kubectl apply or terraform apply
  • Financial operations: Verify identity before wire transfers or payment approvals
  • Data access: Challenge before exporting customer data or PII
  • Admin operations: Verify before user account modifications or permission changes
  • Change control: Enforce approval workflows with cryptographic proof of identity

How It Works

  1. Your agent or skill calls verify.sh with the user's ID and their 6-digit code
  2. The skill validates the code against your TOTP secret
  3. If valid, verification state is recorded with a timestamp
  4. Other scripts can check check-status.sh to see if verification is still fresh
  5. Verification expires after a configured interval (default: 24 hours)

Installation

Via ClawHub (recommended)

clawhub install otp

Manual

cd ~/.openclaw/skills
git clone https://github.com/ryancnelson/otp-skill.git otp

Check Dependencies

After installation, verify required dependencies:

# Check what's available
which jq && echo "✅ jq available" || echo "❌ Install: brew install jq"
which python3 && echo "✅ python3 available" || echo "❌ Install: brew install python3"
which oathtool && echo "✅ oathtool available" || echo "❌ Install: brew install oath-toolkit"

Note: oathtool is optional - the skill includes a built-in TOTP generator, but oathtool provides additional validation.

Setup

1. Generate a TOTP Secret

Use the included secret generator:

cd ~/.openclaw/skills/otp
./generate-secret.sh "your-email@example.com"

This will display:

  • A QR code to scan with your authenticator app
  • The base32 secret for manual entry
  • Configuration instructions

Alternative: Use any other TOTP secret generator. You need a base32-encoded secret.

2. Scan QR Code

Add the secret to your authenticator app:

  • Google Authenticator
  • Authy
  • 1Password
  • Bitwarden
  • Any RFC 6238 compatible app

3. Store the Secret

Option A: In your OpenClaw config

# ~/.openclaw/config.yaml
security:
  otp:
    secret: "YOUR_BASE32_SECRET_HERE"
    accountName: "user@example.com"
    issuer: "OpenClaw"
    intervalHours: 24  # Re-verify every 24 hours

Option B: In environment variable

export OTP_SECRET="YOUR_BASE32_SECRET_HERE"

Option C: In 1Password (recommended for security)

security:
  otp:
    secret: "op://vault/OpenClaw OTP/totp"

4. Test Your Setup

After configuring the secret, test that everything works:

# Get current code from your authenticator app (6 digits)
./verify.sh "testuser" "123456"  # Replace with actual code
# Should show: ✅ OTP verified for testuser (valid for 24 hours)

# Check verification status
./check-status.sh "testuser"
# Should show: ✅ Valid for 23 more hours

# Test error case
./verify.sh "testuser" "000000"
# Should show: ❌ Invalid OTP code

5. Optional: Run Test Suite

# If you have bats installed, run the full test suite
bats tests/verify.bats
bats tests/check-status.bats

Usage

For Skill Authors

When your skill needs to verify user identity:

#!/bin/bash
# In your sensitive-action.sh

# Source the OTP skill
source ../otp/verify.sh

USER_ID="$1"
OTP_CODE="$2"

# Challenge the user
if ! verify_otp "$USER_ID" "$OTP_CODE"; then
  echo "❌ OTP verification failed. Run: /otp <code>"
  exit 1
fi

# Proceed with sensitive action
echo "✅ Identity verified. Proceeding with deployment..."
kubectl apply -f production.yaml

Checking Verification Status

#!/bin/bash
source ../otp/check-status.sh

if check_otp_status "$USER_ID"; then
  echo "✅ User verified within last 24 hours"
else
  echo "⚠️ Verification expired. User must verify again."
fi

For End Users

When prompted by a skill:

User: deploy to production
Agent: 🔒 This action requires identity verification. Please provide your OTP code.

User: /otp 123456
Agent: ✅ Identity verified. Deploying to production...

Scripts

  • verify.sh <user_id> <code> - Verify OTP code and update state
  • check-status.sh <user_id> - Check if user verification is still valid
  • generate-secret.sh <account_name> - Generate new TOTP secret
  • get-current-code.sh <secret> - Get current valid code (testing only)

Configuration

Set these in your OpenClaw config or environment:

  • OTP_SECRET - Base32 TOTP secret (required)
  • OTP_INTERVAL_HOURS - Verification expiry (default: 24)
  • OTP_GRACE_PERIOD_MINUTES - Grace period after expiry (default: 15)
  • OTP_STATE_FILE - State file path (default: memory/otp-state.json)

Security Considerations

What This Protects Against

  • Session hijacking: Even if someone steals your chat session, they can't execute protected actions without your physical device
  • Replay attacks: Codes are time-based and expire quickly
  • Unauthorized actions: Cryptographic proof that you authorized the specific action

What This Doesn't Protect Against

  • Compromised agent: If someone has shell access to your OpenClaw instance, they can read the secret
  • Phishing: Users can still be tricked into providing codes to malicious actors
  • Device theft: If someone has your authenticator device, they can generate codes

Best Practices

  1. Store secrets securely: Use 1Password/Bitwarden references, not plaintext in config
  2. Short expiry: Keep intervalHours reasonable (8-24 hours)
  3. Audit logs: Skills should log verification events
  4. Scope carefully: Only require OTP for truly sensitive actions
  5. Clear prompts: Always tell users WHY they're being asked for OTP

Technical Details

TOTP Implementation

  • Standard: RFC 6238 (Time-Based One-Time Password)
  • Algorithm: HMAC-SHA1 (standard TOTP)
  • Time window: 30 seconds (configurable)
  • Code length: 6 digits
  • Clock skew: ±1 window tolerance (90 seconds total)

State Management

Verification state is stored in memory/otp-state.json:

{
  "verifications": {
    "user@example.com": {
      "verifiedAt": 1706745600000,
      "expiresAt": 1706832000000
    }
  }
}

No secrets are stored in state—only timestamps.

Dependencies

Required:

  • jq - for JSON state file manipulation
  • python3 - for secure YAML config parsing

Optional:

  • oathtool - provides additional TOTP validation (skill has built-in generator)
  • Node.js - only needed for totp.mjs standalone CLI
  • bats - for running test suite

Examples

Deploy Command with OTP

#!/bin/bash
# skills/deploy/production.sh

source ../otp/verify.sh

USER="$1"
CODE="$2"
SERVICE="$3"

# Require OTP for production deploys
if ! verify_otp "$USER" "$CODE"; then
  echo "🔒 Production deployment requires OTP verification"
  echo "Usage: deploy production <service> --otp <code>"
  exit 1
fi

echo "✅ Identity verified. Deploying $SERVICE to production..."
# ... deployment logic ...

Payment Authorization

#!/bin/bash
# skills/finance/transfer.sh

source ../otp/check-status.sh

USER="$1"
AMOUNT="$2"
RECIPIENT="$3"

# Check if user verified recently
if ! check_otp_status "$USER"; then
  echo "💳 Large transfer requires fresh identity verification"
  echo "Please verify with: /otp <code>"
  exit 1
fi

echo "✅ Processing transfer of \$$AMOUNT to $RECIPIENT"
# ... transfer logic ...

Philosophy

OTP should be invisible when not needed, obvious when required.

Don't force users to verify for every action—that trains them to treat it as a meaningless ritual. Only challenge when:

  1. The action has real-world consequences
  2. The risk justifies the friction
  3. You need cryptographic proof of intent

Think of OTP like sudo—you use it before commands that matter, not every command.

Troubleshooting

"OTP verification failed"

  • Check your authenticator app has the correct secret
  • Verify system time is synchronized (NTP)
  • Try the code from the previous/next 30-second window

"Secret not configured"

  • Set OTP_SECRET environment variable
  • Or configure security.otp.secret in OpenClaw config

"State file not found"

  • First verification creates the file
  • Check memory/ directory permissions

License

MIT

Contributing

Issues and PRs welcome at: https://github.com/ryancnelson/otp-skill

See Also

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

其他来源收录

同一技能在不同目录的原始页面:

标签

authenticationtotp2faapproval-workflowidentity-verificationsecurityshell-scriptdevopscompliance

同类 Skill