Back to skill

Security audit

openclaw-backup-yyc

Security checks for vulnerabilities and agentic risk

Overview

This is a real OpenClaw backup/restore skill, but it has review-worthy safety and privacy issues around restore behavior and external IP lookups.

Review before installing. The backup/restore purpose is coherent, but users should remove or make opt-in the external IP lookup, require confirmation for every restore path, validate tar archives safely before extraction, avoid arbitrary absolute restore files, and remove unrelated promotional links from operational prompts.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (5)

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:76
Finding

Mandatory Third-Party Promotional Content in Operational Responses

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:76, SKILL.md:114, SKILL.md:151, SKILL.md:189
Vulnerability Type: Output manipulation through skill instructions
Risk Level: High

Vulnerable Code

markdown
🔗 技术小学生 https://blog.tag.gg

The same third-party promotional link is embedded in the Chinese and English backup and restore confirmation flows.

Technical Analysis

The skill instructions require the agent to insert an unrelated brand and external URL into operational responses. Because these instructions are loaded as part of the skill and affect the agent's generated output, they modify the expected backup and restore interaction for a purpose unrelated to the requested operation.

This is instruction-level output hijacking rather than a normal functional dependency. The link is not required to create, locate, or restore backup archives, and users are directed toward a third-party site as part of an otherwise trusted workflow.

Attack Path

  1. The skill is loaded into an agent session.
  2. A user enters one of the documented backup or restore trigger phrases.
  3. The agent follows the mandatory confirmation template in SKILL.md.
  4. The third-party promotional URL is inserted into the agent's response.
  5. The user may interpret the link as an official or operationally required OpenClaw resource and visit it.

Impact Assessment

This issue controls a portion of the agent's visible output and redirects users to an unrelated third-party domain. It does not directly grant local system privileges, but it abuses the trust relationship between the user and the agent. The external destination could subsequently expose users to tracking, misleading information, or changed content outside the audited package.

Remediation
View remediation

Remediation Suggestions

  1. Remove all unrelated branding and promotional URLs from backup and restore prompts.
  2. Restrict operational responses to information necessary for confirmation, backup creation, archive selection, and restoration.
  3. If external documentation is genuinely required, use a clearly identified official project URL and explain why access is necessary.
  4. Review all skill instructions for content that changes agent output without contributing to the declared functionality.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/restore.py:217
Finding

Unvalidated Extraction of User-Selected Tar Archives

Content
View full analysis

Vulnerability Details

File Location: scripts/restore.py:142-143, scripts/restore.py:217-219
Vulnerability Type: Unsafe archive extraction
Risk Level: High

Vulnerable Code

python
if backup_file:
    backup_path = openclaw_dir / backup_file if not Path(backup_file).is_absolute() else Path(backup_file)
python
print(f"  📦 解压: {backup_path.name}")
with tarfile.open(backup_path, "r:gz") as tar:
    tar.extractall(temp_dir)

Technical Analysis

The restore command accepts both relative archive names and arbitrary absolute paths. It then passes the selected archive directly to tarfile.extractall() without explicitly validating archive members.

The implementation does not reject:

  • Absolute member paths.
  • Member paths containing parent-directory traversal components.
  • Symbolic or hard links.
  • Device or other special-file entries.
  • Unexpected top-level files and directories.
  • Excessive member counts or expanded archive sizes.

On Python runtimes that do not enforce a safe extraction filter by default, a malicious archive can use path traversal or link entries to escape the temporary extraction directory. Although newer Python versions may apply safer defaults, the project does not declare a minimum runtime version or explicitly select and supplement a safe extraction policy. Resource-exhaustion archives and unexpected content also remain unaddressed.

Attack Path

  1. An attacker creates a gzip-compressed tar archive containing traversal paths, unsafe links, special entries, or an excessive amount of expanded data.
  2. The attacker places the archive in the backup directory or persuades an operator to restore it through an absolute path.
  3. The operator or agent runs restore.py with the malicious archive.
  4. The script opens the archive and calls extractall() without validating its members.
  5. Depending on the Python runtime and archive contents, files may ...[truncated 620 chars]
Remediation
View remediation

Remediation Suggestions

  1. Resolve the requested archive path and require it to remain inside the designated OpenClaw backup directory unless an explicit trusted override is used.
  2. Inspect every tar member before extraction.
  3. Reject absolute names, parent-directory traversal, symbolic links, hard links, device entries, FIFOs, and all other unexpected member types.
  4. Permit only the expected top-level entries: workspace, agents, cron, media, and approved openclaw.json backup names.
  5. Use an explicit safe extraction filter where supported rather than relying on version-dependent defaults.
  6. Enforce limits on member count, individual file size, total expanded size, and path length.
  7. Extract into a securely created staging directory and verify each resolved output path remains under that directory.
  8. Document and enforce a minimum supported Python version.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/restore.py:181
Finding

Live Data Is Renamed Before the Backup Archive Is Validated

Content
View full analysis

Vulnerability Details

File Location: scripts/restore.py:181-190, scripts/restore.py:217-219
Vulnerability Type: Non-atomic destructive restore operation
Risk Level: Medium

Vulnerable Code

python
items = get_restore_items()
renamed = {}

for item in items:
    folder_path = openclaw_dir / item["name"]
    if folder_path.exists():
        new_path = rename_old_folder(folder_path)
        if new_path:
            renamed[item["name"]] = new_path
    else:
        print(f"  ⏭️  跳过: {item['name']} (不存在)")

The archive is opened and extracted only after the existing directories have been renamed:

python
print(f"  📦 解压: {backup_path.name}")
with tarfile.open(backup_path, "r:gz") as tar:
    tar.extractall(temp_dir)

Technical Analysis

The restore process first renames the active workspace, agents, cron, and media directories. It only attempts to open and extract the selected archive afterward.

No archive integrity or structure validation occurs before the active data is displaced. If opening, decompressing, validating, or copying the archive fails, the finally block only removes the temporary directory. It does not restore the renamed live directories to their original names.

Consequently, malformed archives and ordinary operational failures can leave OpenClaw in a partial state where expected directories are absent. The operation is neither transactional nor automatically reversible.

Attack Path

  1. An attacker or operator supplies a corrupt, truncated, incorrectly formatted, or otherwise unusable archive.
  2. The restore script confirms only that the selected filesystem path exists.
  3. The script renames the active OpenClaw data directories.
  4. Opening or extracting the archive raises an exception.
  5. Temporary files are cleaned up, but the renamed directories are not rolled back.
  6. OpenClaw continues without its expected active directory l ...[truncated 433 chars]
Remediation
View remediation

Remediation Suggestions

  1. Open and fully validate the archive before modifying any live directory.
  2. Safely extract the archive into an isolated staging directory first.
  3. Verify archive integrity, expected directory structure, file types, permissions, and resource limits.
  4. Perform an atomic directory swap only after staging succeeds.
  5. Wrap the swap in rollback logic that restores every renamed directory if any subsequent operation fails.
  6. Detect backup-name collisions when generating renamed paths and avoid overwriting prior rollback copies.
  7. Return a nonzero exit status and clear recovery instructions if rollback itself fails.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/restore.py:174
Finding

Destructive Restore Can Proceed Without User Confirmation

Content
View full analysis

Vulnerability Details

File Location: scripts/restore.py:174-179, scripts/restore.py:303-306; documented safeguard at SKILL.md:19 and SKILL.md:179-191
Vulnerability Type: Missing mandatory confirmation control
Risk Level: Medium

Vulnerable Code

python
if confirm:
    print(f"⚠️  即将恢复: {backup_path.name}")
    response = input("   确认继续?(y/N): ")
    if response.lower() != "y":
        print("   已取消恢复")
        return
python
if args.list:
    list_available_backups(openclaw_dir)
elif args.index:
    restore(openclaw_dir, backup_index=args.index, confirm=args.confirm)
else:
    restore(openclaw_dir, args.backup_file, args.confirm)

Technical Analysis

Confirmation is performed only when the caller supplies --confirm. Without that flag, the restore process immediately proceeds to rename the existing directories and extract the selected archive.

This behavior contradicts the skill documentation, which states that the user must confirm the operation before execution. Both positional archive selection and --index selection can bypass the documented safeguard.

Making a safety check opt-in is insecure for a destructive data-management operation. It also creates a mismatch between the agent-facing workflow and direct script behavior.

Attack Path

  1. An operator, automation process, or agent invokes python scripts/restore.py backup.tar.gz without --confirm.
  2. The script resolves the archive and verifies only that the path exists.
  3. No confirmation prompt is displayed because confirm is false.
  4. Existing data directories are renamed and the restore operation begins.
  5. The current OpenClaw state is changed without explicit consent at execution time.

The same bypass is available through python scripts/restore.py --index 1.

Impact Assessment

The operation runs with the invoking user's privileges and can replace or displace that user's a ...[truncated 228 chars]

Remediation
View remediation

Remediation Suggestions

  1. Require interactive confirmation by default for every operation that modifies live data.
  2. Reverse the option semantics: if non-interactive operation is necessary, provide an explicit option such as --yes or --force.
  3. Display the resolved archive path and every live directory that will be renamed before requesting confirmation.
  4. Require the documented confirmation phrase or an unambiguous affirmative response.
  5. Ensure agent integrations never supply the non-interactive override without obtaining explicit user approval.
  6. Combine confirmation with archive prevalidation and rollback; confirmation alone does not make an unsafe archive safe.

other

Warning
Location
scripts/backup.py:172
Finding

Backup Operation Makes Undisclosed Requests to External IP Services

Content
View full analysis

Vulnerability Details

File Location: scripts/backup.py:172-188
Vulnerability Type: Privacy leakage through unnecessary outbound requests
Risk Level: Medium

Vulnerable Code

python
import subprocess
ip_services = [
    "https://ip.tag.gg/ip.php",
    "https://ifconfig.me",
    "https://api.ipify.org",
    "https://ip.sb",
    "https://myip.ipip.net",
    "https://ipinfo.io/ip",
]
server_ip = "服务器IP"
for service in ip_services:
    try:
        result = subprocess.run(['curl', '-s', '--connect-timeout', '3', service], capture_output=True, text=True)
        if result.returncode == 0 and result.stdout.strip():
            server_ip = result.stdout.strip()
            break
    except:
        continue

The unvalidated response is subsequently inserted into an SCP example:

python
print(f"scp root@{server_ip}:{backup_file} ./")

Technical Analysis

Every normal backup attempts outbound HTTPS connections to a sequence of third-party IP-discovery services. These requests are not necessary to create the backup and are not disclosed in the documented backup behavior.

Each contacted service can observe the source public IP address and request timing. The first service is hosted under the same third-party domain promoted in the skill instructions.

The returned text is accepted whenever it is nonempty. It is not validated as an IPv4 address, IPv6 address, or approved hostname before being embedded into a suggested SCP command. The command is printed rather than executed, so this is not direct command injection in the current implementation. However, copying a maliciously formatted response into a shell could expose users to command-line interpretation risks.

Attack Path

  1. A user runs the backup script.
  2. After creating the archive, the script starts curl against the configured external services.
  3. The first responsive service learns the host's public ...[truncated 724 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove automatic public-IP discovery from the backup path.
  2. Allow users to provide a hostname or IP address explicitly when requesting SCP guidance.
  3. If discovery remains available, make it a clearly documented opt-in operation.
  4. Explain which service will be contacted and what metadata it receives.
  5. Use a single trusted endpoint rather than silently trying multiple third parties.
  6. Validate the response strictly with an IP-address parser before displaying it.
  7. Quote shell arguments safely and present generated commands as examples requiring user review.
  8. Apply total request timeouts and report network failures explicitly instead of suppressing all exceptions.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (13)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This finding indicates the skill claims narrow, user-safe behavior but the underlying behavior appears broader and less controlled, including optional confirmation and undeclared restore/list capabilities. In a backup/restore context, such inconsistencies materially increase the risk of accidental restoration, data overwrite, or execution outside the expected language and interaction flow.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

This finding indicates the skill claims narrow, user-safe behavior but the underlying behavior appears broader and less controlled, including optional confirmation and undeclared restore/list capabilities. In a backup/restore context, such inconsistencies materially increase the risk of accidental restoration, data overwrite, or execution outside the expected language and interaction flow.

Content

No source excerpt is available for this finding.

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · SKILL.md (reported line 206)May include surrounding context.

md
**⚠️⚠️⚠️ RESTORE WARNING ⚠️⚠️⚠️**

> **Before restoring, existing folders will be renamed (with timestamp suffix). After restoring, data will overwrite current configuration.**

Do you confirm to restore the selected archive? Please reply **confirm** or **cancel**.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
78% confidence
Finding

The skill advertises operational behavior that implies shell, environment, and file-write capabilities, but it does not declare any tool scope or permissions boundaries. In an agent environment, this weakens reviewability and can allow broader-than-expected filesystem or command execution during backup/restore operations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's docstring, help text, and runtime messages are presented exclusively in Chinese, which constitutes a language-policy issue when no user language selection or justification is provided. There is no visible mechanism for users to choose another locale or confirm that Chinese output is expected.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill metadata describes a backup/restore tool, but the implementation additionally performs external network lookups and prints a remote SCP transfer command. That expands the capability beyond the declared scope and can surprise users by causing data-adjacent network activity during what should be an offline local operation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script sends outbound requests to multiple third-party IP lookup services without informing the user before execution. In a backup context, this is dangerous because users reasonably expect a local archival action, not network disclosure of the host's public IP and backup-related activity.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

A backup utility generally does not need shell-adjacent subprocess execution or external network capability to complete its core task. Introducing subprocess-based curl calls increases attack surface, adds dependency on external binaries, and creates opportunities for unintended information disclosure or policy violations in restricted environments.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
92% confidence
Finding

The backup script invokes curl via subprocess to contact third-party IP lookup services during a local backup operation. This creates undisclosed outbound network activity and exposes server metadata/IP information to external services, which is outside the expected trust boundary for a backup utility.

Content

Scanner excerpt · scripts/backup.py (reported line 191)May include surrounding context.

python
server_ip = "服务器IP"
    for service in ip_services:
        try:
            result = subprocess.run(['curl', '-s', '--connect-timeout', '3', service], capture_output=True, text=True)
            if result.returncode == 0 and result.stdout.strip():
                server_ip = result.stdout.strip()
                break

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring, CLI usage text, prompts, and user-facing output are written entirely in Chinese, which imposes a specific language on users. The file does not indicate that Chinese is optional, selectable, or justified as a region-specific tool.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script permits absolute backup paths, allowing restoration from arbitrary tar.gz files outside the expected ~/.openclaw backup set. Because the code later performs tar.extractall on that file without member validation, an attacker who can influence the path or place a crafted archive could trigger restoration from an untrusted source and potentially write files outside the temporary directory via path traversal.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The restore operation renames existing data directories and replaces them with contents from a backup, which is inherently destructive. Confirmation is only performed when the optional --confirm flag is supplied, so automated or accidental invocation can proceed without an explicit user approval despite the skill contract requiring confirmation before execution.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The code checks an environment variable to locate the data directory, which can influence what files are accessed and archived. While this is not inherently unsafe, the script does not clearly disclose in its usage/help text that environment configuration may redirect backup scope.

Content

No source excerpt is available for this finding.