Back to skill

Security audit

Backup Recovery Toolkit

Security checks for vulnerabilities and agentic risk

Overview

The skill is a real backup tool, but its restore and backup-path handling can overwrite files outside intended folders, so users should review it carefully before installing.

Install only after reviewing and preferably fixing the restore and path-validation issues. Do not restore untrusted archives, run the tool with least-privileged accounts, use empty staging directories for restores, avoid passing long-lived database passwords on command lines, and pin or remove dependencies before production use.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/backup_toolkit.py:360
Finding

Unsafe Archive Extraction Permits Writes Outside the Restore Destination

Content
View full analysis

Vulnerability Details

File Location: scripts/backup_toolkit.py, lines 360-363
Vulnerability Type: Path traversal during archive extraction
Risk Level: High

Vulnerable Code:

python
if backup_path.endswith('.tar.gz'):
    with tarfile.open(backup_path, "r:gz") as tar:
        tar.extractall(destination)
        result['files_restored'] = len(tar.getmembers())

Technical Analysis

The restore function extracts every member of a supplied TAR archive without validating member paths or link targets. A malicious archive may contain entries using absolute paths, ../ traversal components, or unsafe symbolic or hard links.

On Python versions or configurations where a safe extraction filter is not automatically enforced, tar.extractall(destination) may write such entries outside the requested destination. Merely creating the destination directory does not constrain archive member paths to that directory.

Attack Path

  1. An attacker creates a .tar.gz archive containing a member such as ../../target-file.
  2. The archive is provided to a user or automation process as a legitimate backup.
  3. The victim runs:
    bash
    python scripts/backup_toolkit.py restore \
      --backup malicious.tar.gz \
      --dest /intended/restore
    
  4. tar.extractall() processes the unvalidated member.
  5. The member is written outside /intended/restore if the target location is writable by the process.

Impact Assessment

An attacker can create or overwrite files accessible to the account running the restore operation. The scope is limited by that account's operating-system permissions, but it may include application configuration, user startup files, scripts, data files, or other backups. If the tool is run by a privileged account, the impact expands to privileged filesystem locations and may lead to code execution through overwritten executable or configuration files.

Remediation
View remediation

Remediation Suggestions

  • Resolve and normalize every archive member path before extraction.
  • Verify that each resolved output path remains within the resolved destination directory.
  • Reject absolute member names, traversal components, device files, and unsafe symbolic or hard links.
  • On supported Python versions, use the data extraction filter, while retaining explicit containment checks for compatibility and defense in depth.
  • Extract into a newly created staging directory with restrictive permissions before moving validated files to the final destination.
  • Add tests using absolute paths, ../ entries, symbolic links, hard links, and special-file members.

Example containment logic:

python
destination_real = os.path.realpath(destination)

for member in tar.getmembers():
    target = os.path.realpath(os.path.join(destination_real, member.name))
    if os.path.commonpath([destination_real, target]) != destination_real:
        raise ValueError(f"Unsafe archive member: {member.name}")

tar.extractall(destination_real, filter="data")

T09 · Insecure Skill Coding Practices

Error
Location
scripts/backup_toolkit.py:76
Finding

Unvalidated Backup Names Permit Destination-Directory Escape and File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/backup_toolkit.py, lines 76-82 and 149-153
Vulnerability Type: Path traversal through attacker-controlled output names
Risk Level: High

Vulnerable Code:

python
backup_name = name or f"backup_{timestamp}"
backup_path = os.path.join(self.destination, backup_name)

if self.compress:
    backup_path += ".tar.gz"
    result = self._backup_compressed(backup_path)
else:
    result = self._backup_uncompressed(backup_path)
python
backup_name = (name or "incremental") + f"_{timestamp}"
backup_path = os.path.join(self.destination, backup_name + ".tar.gz")

# 获取已备份文件的哈希 | Get hashes of backed up files
reference_hashes = self._get_reference_hashes()

# 只备份变更的文件 | Only backup changed files
with tarfile.open(backup_path, "w:gz") as tar:

Technical Analysis

The CLI-provided --name value is used directly in os.path.join() without restricting it to a filename. Absolute paths cause os.path.join() to discard the configured destination, while names containing ../ can resolve outside that destination.

Compressed backups are opened using tarfile.open(..., "w:gz"), which creates or truncates the resolved output path. Uncompressed backups similarly create or merge into a directory derived from the untrusted name. Appending .tar.gz or a timestamp does not prevent traversal.

Attack Path

  1. An attacker controls or influences the --name argument used by a backup job.
  2. The attacker supplies an absolute path or a value containing traversal components, such as ../../outside/backup.
  3. The application joins that value with the configured backup destination without validating containment.
  4. The resulting archive or directory is created outside the intended destination.
  5. If a matching file already exists and is writable, compressed backup creation can truncate and replace it.

Impact Assessment

The attacker can cre ...[truncated 431 chars]

Remediation
View remediation

Remediation Suggestions

  • Treat backup names strictly as names rather than paths.
  • Reject absolute paths, path separators, . and .. components, null bytes, and platform-specific alternate separators.
  • Apply a conservative allowlist, such as letters, digits, underscores, periods, and hyphens.
  • Resolve the final output path and verify with os.path.commonpath() that it remains under the resolved destination.
  • Use exclusive file creation or explicitly reject existing paths to prevent accidental truncation.
  • Apply the same validation to full and incremental backup names.

Example validation:

python
import re

if not re.fullmatch(r"[A-Za-z0-9._-]+", backup_name):
    raise ValueError("Invalid backup name")

destination_real = os.path.realpath(self.destination)
backup_path = os.path.realpath(
    os.path.join(destination_real, backup_name + ".tar.gz")
)

if os.path.commonpath([destination_real, backup_path]) != destination_real:
    raise ValueError("Backup path escapes destination")

if os.path.exists(backup_path):
    raise FileExistsError(backup_path)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/backup_toolkit.py:267
Finding

Database Passwords Are Exposed in Child-Process Command-Line Arguments

Content
View full analysis

Vulnerability Details

File Location: scripts/backup_toolkit.py, lines 267-278 and 315-326
Vulnerability Type: Plaintext credential exposure through process arguments
Risk Level: Medium

Vulnerable Code:

python
port = self.port or 3306
cmd = [
    'mysqldump',
    '-h', self.host,
    '-P', str(port),
    '-u', self.user,
    f'-p{self.password}',
    self.database
]

with open(destination, 'w') as f:
    subprocess.run(cmd, stdout=f, check=True)
python
port = self.port or 27017
cmd = [
    'mongodump',
    '--host', f'{self.host}:{port}',
    '--db', self.database,
    '-u', self.user,
    '-p', self.password,
    '--archive', destination,
    '--gzip'
]

subprocess.run(cmd, check=True)

Technical Analysis

Both MySQL and MongoDB backup routines place the database password directly in the subprocess argument vector. Depending on the operating system and monitoring configuration, command-line arguments may be observable through process-inspection tools, process metadata, audit systems, diagnostics, crash reports, or command logging.

Using a list-form subprocess.run() call prevents shell metacharacter injection, but it does not protect secrets embedded in the argument list.

Attack Path

  1. A database backup starts and launches mysqldump or mongodump.
  2. The plaintext password is included in the child process's argument vector.
  3. A local user, monitoring agent, or diagnostic process with sufficient process-inspection access reads the arguments while the dump is running.
  4. The observer obtains a reusable database credential.
  5. The credential may then be used to access the database according to the compromised account's assigned permissions.

Impact Assessment

Exposure can compromise the configured database account. The resulting scope depends on that account's database privileges and network accessibility. Potential consequen ...[truncated 260 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not place passwords in command-line arguments.
  • For MySQL, use a temporary defaults file with mode 0600, or another supported credential mechanism that does not expose the password in the process list.
  • For MongoDB, use a protected configuration file or supported credential source rather than the -p argument.
  • Create temporary credential files using secure exclusive creation, apply restrictive permissions before writing, and remove them in a finally block.
  • Use dedicated backup accounts with only the minimum database permissions.
  • Ensure commands, environment dictionaries, exceptions, and diagnostic logs are redacted before logging.
  • Prefer secret-manager integration rather than accepting long-lived plaintext credentials from source code or static configuration.

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding

Open-Ended and Unused Dependencies Create Avoidable Supply-Chain Exposure

Content
View full analysis

Vulnerability Details

File Location: requirements.txt, lines 1-9; installation instruction at README.md, lines 20-22
Vulnerability Type: Unpinned and unnecessary third-party dependencies
Risk Level: Medium

Vulnerable Code:

text
schedule>=1.2.0
psutil>=5.9.6
pymysql>=1.1.0
psycopg2-binary>=2.9.9
pymongo>=4.6.0
paramiko>=3.3.1
cryptography>=41.0.7
pytest>=7.4.0
pytest-cov>=4.1.0

The documented installation command is:

bash
pip install -r requirements.txt

Technical Analysis

Every dependency uses an open-ended lower-bound constraint. A future installation can therefore resolve to package versions that were not reviewed or tested during this audit. The dependency file also lacks integrity hashes.

None of these third-party packages are imported by the reviewed executable implementation, which relies on the Python standard library and invokes external database dump programs. Installing unused runtime dependencies unnecessarily expands the number of third-party installation and import surfaces. Test-only packages are also mixed with purported runtime dependencies.

No specific malicious package was identified in the reviewed dependency list. The finding concerns unnecessary and mutable supply-chain exposure rather than evidence that a listed package is currently malicious.

Attack Path

  1. A user follows the documented installation command.
  2. Package resolution selects versions newer than those available when the project was reviewed.
  3. Pip downloads and installs the selected packages and any transitive dependencies.
  4. Package build or installation logic executes under the privileges of the installing user.
  5. If a selected future release or transitive component is compromised, its code can execute during installation or later import.

Impact Assessment

A compromised dependency may execute with the privileges of the user performing installation or ru ...[truncated 304 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove dependencies that are not imported or otherwise required by implemented functionality.
  • Separate runtime, optional database, development, and test dependencies.
  • Pin reviewed versions exactly in a lock file.
  • Generate and enforce cryptographic hashes, such as with pip-compile --generate-hashes and pip install --require-hashes.
  • Review transitive dependencies and use automated vulnerability scanning.
  • Upgrade dependencies through a controlled review and test process rather than unrestricted lower-bound resolution.
  • Install dependencies in an isolated virtual environment as a nonprivileged user.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (30)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The code substantially matches several declared features: file backup, database backup, incremental backup, and restore functionality. However, there is no implementation of scheduled task support (no cron/job scheduling, timers, or task management). The 'disaster recovery' claim is also broader than what the code provides; the implementation offers only basic file restore and database dump generation, without orchestration, recovery planning, verification, failover, replication, or recovery automation typical of disaster recovery tooling. No suspicious unrelated or undeclared capabilities are present, but the declared description overstates the implemented feature set enough to constitute a mismatch.

Content

No source excerpt is available for this finding.

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · scripts/backup_toolkit.py (reported line 300)May include surrounding context.

python
'-f', destination
        ]
        
        env = os.environ.copy()
        env['PGPASSWORD'] = self.password
        
        subprocess.run(cmd, env=env, check=True)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The restore logic calls tar.extractall(destination) on archive contents without validating member paths. A malicious tarball can contain path traversal entries or symlinks that write outside the intended restore directory, enabling arbitrary file overwrite and potentially code execution or persistence if sensitive paths are targeted.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file describes file backup, restore, and scheduled backup commands, including restoring into /data, but does not warn users that restore operations may overwrite existing files or that scheduled jobs can affect system state. For markdown files, SQP-2 applies when the skill description omits warnings about behaviors that could affect user data or system integrity.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The documentation shows database backup usage with username/password parameters and states support for local and remote backup, but it provides no warning about handling sensitive credentials or backing up potentially sensitive data. Under SQP-2 for markdown files, user-facing descriptions should disclose privacy or data-handling risks when the skill can affect sensitive data.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill documents operations that inherently require shell, file read/write, and likely environment access, but it does not declare any tool scope or permissions boundaries. In an agent environment, this increases the risk of overbroad execution privileges, making destructive backup/restore actions or unintended data access more likely if the skill is invoked incorrectly or abused.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documented restore command writes data into a destination path without any warning that existing files may be overwritten or replaced. In backup tooling, restore is a destructive-capable action, and omission of overwrite warnings increases the chance of operator error leading to data loss or corruption.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The MySQL, PostgreSQL, and MongoDB backup methods use provided passwords and launch subprocesses to create backup files, but there is no visible disclosure to users in CLI output/help or comments/docstrings explaining that credentials are passed to external tools. This matters because the code handles sensitive secrets and performs shell-adjacent system operations that users may not realize.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/backup_toolkit.py (reported line 278)May include surrounding context.

python
]
        
        with open(destination, 'w') as f:
            subprocess.run(cmd, stdout=f, check=True)
        
        result.files_backed_up = 1
        result.total_size = os.path.getsize(destination)

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/backup_toolkit.py (reported line 303)May include surrounding context.

python
env = os.environ.copy()
        env['PGPASSWORD'] = self.password
        
        subprocess.run(cmd, env=env, check=True)
        
        result.files_backed_up = 1
        result.total_size = os.path.getsize(destination)

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/backup_toolkit.py (reported line 326)May include surrounding context.

python
'--gzip'
        ]
        
        subprocess.run(cmd, check=True)
        
        result.files_backed_up = 1
        result.total_size = os.path.getsize(destination)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The restore path performs archive extraction and file copies directly into the user-specified destination, which can modify or overwrite existing files. Although the function name indicates restoration, there is no user-facing warning, confirmation prompt, or explicit disclosure in nearby CLI help/comments that destination contents may be changed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The skill advertises cron-style scheduled backups, which can repeatedly write data and consume storage or system resources over time. The markdown description does not include any user-facing warning about validating schedules, retention, or disk usage before enabling automation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This file uses bilingual text, but the primary framing and runtime output prominently enforce Chinese-language messaging in many strings and headings. Under the policy, a skill should not force a specific language or locale without opt-in unless the constraint is clearly documented and justified.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is specified with a lower-bound range instead of an exact pinned version, which makes builds non-reproducible and can silently pull in newer releases with regressions or security issues. In a backup/recovery toolkit, reliability and trust in the execution environment are important, so dependency drift increases operational and supply-chain risk.

Content

Scanner excerpt · requirements.txt (reported line 1)May include surrounding context.

text
schedule>=1.2.0
psutil>=5.9.6
pymysql>=1.1.0
psycopg2-binary>=2.9.9

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

Using an unpinned psutil version allows environment-dependent installs and makes it impossible to guarantee which code will execute in production. This weakens reproducibility and can expose deployments to vulnerable or incompatible releases if package resolution changes.

Content

Scanner excerpt · requirements.txt (reported line 2)May include surrounding context.

text
schedule>=1.2.0
psutil>=5.9.6
pymysql>=1.1.0
psycopg2-binary>=2.9.9
pymongo>=4.6.0

Unverifiable Dependency: psutil has 2 known advisory(ies) (CVE-2019-18874 (Double Free in psutil); CVE-2019-18874 (psutil (aka python-psutil) through 5.6.5 can have a double free. This occurs bec)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
84% confidence
Finding

Because psutil is not pinned, it is not possible to determine from this manifest alone whether deployments will install a version affected by known advisories. This uncertainty is itself a security weakness because vulnerable packages may be introduced without visibility, though no specific affected version is proven here.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

An unpinned PyMySQL dependency permits different installations to resolve to different releases, reducing build integrity and making vulnerability exposure hard to assess. Because this toolkit likely handles database backups, a compromised or buggy client library could affect sensitive data operations.

Content

Scanner excerpt · requirements.txt (reported line 3)May include surrounding context.

text
schedule>=1.2.0
psutil>=5.9.6
pymysql>=1.1.0
psycopg2-binary>=2.9.9
pymongo>=4.6.0
paramiko>=3.3.1

Unverifiable Dependency: pymysql has 2 known advisory(ies) (CVE-2024-36039 (PyMySQL SQL Injection vulnerability); CVE-2024-36039 (PyMySQL SQL Injection vulnerability)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
90% confidence
Finding

PyMySQL has known advisories, and the unpinned requirement prevents verification that installed versions are safe. In a database backup tool, a vulnerable database client is more concerning because it directly interfaces with sensitive data systems and may amplify the consequences of a flaw.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
93% confidence
Finding

The psycopg2-binary package is not pinned, so dependency resolution may vary over time and across systems. For backup software interacting with production databases, that unpredictability increases the chance of introducing a vulnerable or unstable client component.

Content

Scanner excerpt · requirements.txt (reported line 4)May include surrounding context.

text
schedule>=1.2.0
psutil>=5.9.6
pymysql>=1.1.0
psycopg2-binary>=2.9.9
pymongo>=4.6.0
paramiko>=3.3.1
cryptography>=41.0.7

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

Leaving pymongo unpinned creates a supply-chain and reproducibility weakness because the installed version can change without code changes. In a tool that may access backup data stores, that uncertainty can affect both security posture and operational stability.

Content

Scanner excerpt · requirements.txt (reported line 5)May include surrounding context.

text
psutil>=5.9.6
pymysql>=1.1.0
psycopg2-binary>=2.9.9
pymongo>=4.6.0
paramiko>=3.3.1
cryptography>=41.0.7
pytest>=7.4.0

Unverifiable Dependency: pymongo has 4 known advisory(ies) (CVE-2024-5629 (PyMongo Out-of-bounds Read in the bson module ); CVE-2013-2132 (Use of NullPointerException Catch to Detect NULL Pointer Dereference in Pymongo); CVE-2013-2132 (bson/_cbsonmodule.c in the mongo-python-driver (aka. pymongo) before 2.5.2, as u) +1 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
86% confidence
Finding

The manifest does not pin pymongo, so advisory exposure cannot be verified and a vulnerable release could be installed in some environments. Given the toolkit context, this matters more because backup workflows may interact with production MongoDB instances and sensitive stored data.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

Paramiko is security-sensitive because it handles SSH transport, and specifying only a minimum version means future installs may resolve unpredictably. In a backup/recovery toolkit that may transfer backups over SSH, unpinned crypto/transport dependencies increase the chance of introducing exploitable behavior or protocol weaknesses.

Content

Scanner excerpt · requirements.txt (reported line 6)May include surrounding context.

text
pymysql>=1.1.0
psycopg2-binary>=2.9.9
pymongo>=4.6.0
paramiko>=3.3.1
cryptography>=41.0.7
pytest>=7.4.0
pytest-cov>=4.1.0

Unverifiable Dependency: paramiko has 12 known advisory(ies) (CVE-2018-7750 (Paramiko not properly checking authentication before processing other requests); CVE-2023-48795 (Prefix Truncation Attack against ChaCha20-Poly1305 and Encrypt-then-MAC aka Terr); CVE-2018-1000805 (Paramiko Authentication Bypass vulnerability) +9 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
93% confidence
Finding

Paramiko has a substantial advisory history, and the unpinned requirement means the actual installed version cannot be assessed for known weaknesses. Since backup tools often use SSH for remote operations or transfer, an unverifiable SSH library meaningfully increases the security risk in this skill's context.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

Cryptography is a high-sensitivity dependency, and not pinning it means builds may consume different underlying cryptographic implementations over time. For software involved in backup protection or secure transport, this can directly affect confidentiality and integrity guarantees.

Content

Scanner excerpt · requirements.txt (reported line 7)May include surrounding context.

text
psycopg2-binary>=2.9.9
pymongo>=4.6.0
paramiko>=3.3.1
cryptography>=41.0.7
pytest>=7.4.0
pytest-cov>=4.1.0