Install
openclaw skills install otc-confirmationOne-Time Confirmation code security mechanism for sensitive agent operations. Generates a cryptographically secure single-use code, delivers it via a private...
openclaw skills install otc-confirmationA security pattern that prevents unauthorized or accidental execution of sensitive operations by requiring out-of-band confirmation via a one-time code.
/dev/urandom instead of $RANDOMUser request (sensitive op)
→ Agent runs generate_code.sh (code stored in state file, never printed)
→ Agent runs send_otc_email.sh (reads code from state file, sends email)
→ Agent replies in chat: "需要确认,请查看邮箱"
→ User reads email, replies with code in ORIGINAL chat session
→ Agent runs verify_code.sh (reads state file, compares, deletes on match)
→ Agent executes operation
The code is single-use — the state file is deleted immediately after successful verification.
Key security property: The agent never captures or sees the code in its context. It only checks exit codes.
clawhub install otc-confirmation
Option A: OpenClaw Config (Recommended)
Add to openclaw.json:
{
"skills": {
"entries": {
"otc-confirmation": {
"enabled": true,
"env": {
"OTC_EMAIL_RECIPIENT": "user@example.com",
"OTC_EMAIL_BACKEND": "smtp",
"OTC_SMTP_HOST": "smtp.gmail.com",
"OTC_SMTP_PORT": "587",
"OTC_SMTP_USER": "your-email@gmail.com",
"OTC_SMTP_PASS": "your-app-password"
}
}
}
}
}
Option B: Environment Variables
export OTC_EMAIL_RECIPIENT=user@example.com
export OTC_EMAIL_BACKEND=smtp
export OTC_SMTP_HOST=smtp.gmail.com
export OTC_SMTP_PORT=587
export OTC_SMTP_USER=your-email@gmail.com
export OTC_SMTP_PASS=your-app-password
SKILL_DIR="{baseDir}"
# Step 1: Generate code (stored in secure state file, nothing printed to stdout)
bash "$SKILL_DIR/scripts/generate_code.sh"
# Step 2: Send email (reads code from state file internally)
bash "$SKILL_DIR/scripts/send_otc_email.sh" "Send email to john@example.com" "Discord #work"
# Step 3: Reply in chat (do NOT mention the code)
echo "需要确认,请查看你的注册邮箱"
# Step 4: Wait for user input, then verify (reads expected code from state file)
bash "$SKILL_DIR/scripts/verify_code.sh" "$USER_INPUT"
if [ $? -eq 0 ]; then
echo "OTC通过,执行操作..."
# Execute the operation
else
echo "确认码不匹配,操作取消"
fi
Uses curl to send email directly via SMTP. No additional tools required.
export OTC_EMAIL_BACKEND=smtp
export OTC_SMTP_HOST=smtp.gmail.com
export OTC_SMTP_PORT=587
export OTC_SMTP_USER=your-email@gmail.com
export OTC_SMTP_PASS=your-app-password
If you have the send-email skill installed:
export OTC_EMAIL_BACKEND=send-email
If you have himalaya installed:
export OTC_EMAIL_BACKEND=himalaya
Use your own email sending script:
export OTC_EMAIL_BACKEND=custom
export OTC_CUSTOM_EMAIL_SCRIPT=/path/to/your/send_email.sh
Your script must accept three arguments: <to> <subject> <body>
Security note: Ensure the custom script has restricted permissions and is located in a trusted directory. The skill validates that the script exists and is executable before invoking it.
OTC should be triggered for:
See references/trigger-categories.md for detailed categories.
Before every operation, follow the enforcement checklist:
See references/enforcement-checklist.md for the complete workflow.
examples/soul_md_integration.mdexamples/agents_md_integration.mdGenerate a cryptographically secure random OTC code.
bash scripts/generate_code.sh [prefix] [length]
# Default: cf-XXXX (prefix="cf", length=4)
# Code is stored in a secure state file (mode 600)
# Nothing is printed to stdout
Send OTC confirmation email. Reads the code from the state file.
bash scripts/send_otc_email.sh <operation> [session] [lang]
# Example:
bash scripts/send_otc_email.sh "Send email to john@example.com" "Discord #work"
# If email fails → exits with error (never falls through)
Verify user input against the stored code.
bash scripts/verify_code.sh <user_input>
# Exit code 0: verified (state file deleted — single-use)
# Exit code 1: mismatch or no pending code
Low-level SMTP email sending (used internally by send_otc_email.sh).
bash scripts/send_email_smtp.sh <to> <subject> <body>
# Requires OTC_SMTP_* environment variables
test -n "$OTC_SMTP_USER" && echo "set" || echo "not set"curl -v smtp://$OTC_SMTP_HOST:$OTC_SMTP_PORTIf using send-email or himalaya backend:
# Check if command exists
command -v send-email
command -v himalaya
# Install if missing
clawhub install send-email # or install himalaya
MIT
Lewis-404