T09 · Insecure Skill Coding Practices
- Location
index.js:43- Finding
Shell Command Injection and Refresh Token Exposure Through Process Arguments
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Aliyun Drive skill is mostly coherent for cloud file management, but it has unsafe command execution and credential-handling weaknesses that warrant manual review before installation.
Install only after the command execution path is fixed to use argument-vector subprocess execution, the token is no longer passed on the command line, dependencies are pinned, and destructive delete actions require explicit user confirmation. Treat the Aliyun refresh token like a password and avoid committing or sharing the .env file.
index.js:43Shell Command Injection and Refresh Token Exposure Through Process Arguments
SKILL.md:14Unpinned Python Dependencies Permit Non-Reproducible and Unsafe Package Resolution
This code accesses credentials from a local .env file, which is a sensitive secret source. In agent/plugin contexts, credential access is high risk because compromise of the skill or misuse of its capabilities can lead to unauthorized cloud account actions using long-lived refresh tokens.
];
/**
* 从 .env 读取 token
*/
function getEnvToken() {
const envPath = resolve(process.cwd(), '.env');
Reading the .env file contents directly into memory to extract a refresh token constitutes explicit credential access. Because the token likely permits account operations such as file management and sharing, exposure or misuse could enable unauthorized access to the user's cloud storage.
* 从 .env 读取 token
*/
function getEnvToken() {
const envPath = resolve(process.cwd(), '.env');
if (!existsSync(envPath)) return null;
const content = readFileSync(envPath, 'utf8');
const match = content.match(/ALIYUN_DRIVE_REFRESH_TOKEN="([^"]+)"/);
The code depends on a refresh token sourced from .env and fails if it is absent, confirming credential access is core behavior. In this context, the danger is elevated because the skill can perform state-changing cloud actions once the token is obtained, broadening the blast radius of any misuse.
*/
async function execPython(args) {
const token = getEnvToken();
if (!token) throw new Error('ALIYUN_DRIVE_REFRESH_TOKEN not found in .env');
const envPath = resolve(process.cwd(), '.env');
const python = findPython();
The refresh token is passed on the command line to a Python subprocess together with the .env path for saving, which is especially dangerous because command-line arguments are often observable via process listings, logs, or crash reports. This creates a concrete secret-exposure path beyond mere local credential access.
const token = getEnvToken();
if (!token) throw new Error('ALIYUN_DRIVE_REFRESH_TOKEN not found in .env');
const envPath = resolve(process.cwd(), '.env');
const python = findPython();
const cmd = [python, PYTHON_SCRIPT, ...args, '--token', token, '--save-token', envPath];
The --save-token argument allows the caller to specify an arbitrary local file that will be read and rewritten with a regex replacement. This creates an unintended local file modification primitive that can overwrite sensitive configuration files outside the intended Aliyun Drive scope, potentially corrupting configs or altering credentials on the host.
The skill advertises capabilities that imply file read, file write, and network access, but it does not declare any explicit tool scope or permission boundaries. That creates ambiguity for the agent/runtime and can lead to over-broad execution privileges, especially because this skill handles local files and cloud uploads using sensitive credentials.
The skill instructs users to extract a refresh_token from browser storage and save it in a local .env file without clearly warning that this token is a long-lived credential that can grant full account access. If exposed through logs, backups, local compromise, or accidental sharing, an attacker could access, upload, delete, or share files in the user's Aliyun Drive account.
The skill documents a delete capability but provides no warning about irreversible data loss and no expectation of explicit confirmation before performing destructive actions. In an agent setting, that omission increases the chance of accidental or unauthorized deletion of cloud files, especially when operating on IDs the user may not easily recognize.
The execution path accesses and forwards a refresh token to another process without any user-facing disclosure in this file's control flow. Even if needed for functionality, undisclosed credential handling is risky in an agent skill because users may not realize local secrets are being read and transmitted to subprocesses.
The code exposes a destructive delete capability that is not disclosed in the skill metadata, creating a mismatch between declared and actual behavior. In an agent setting, hidden destructive actions materially increase user risk because callers may invoke or permit the skill without understanding it can permanently remove cloud files.
The delete path executes immediately once given a file_id and contains no confirmation, safeguard, or dry-run mechanism. In a file-management skill, lack of friction around destructive operations increases the chance of accidental or manipulated deletion through prompt confusion or upstream agent mistakes.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
pan = AliyunPan(refresh_token=token)
# 直接调 auth API 绕过 SDK bug
resp = requests.post(
'https://auth.aliyundrive.com/v2/account/token',
json={"refresh_token": token, "grant_type": "refresh_token"},
timeout=10
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
pan = AliyunPan(refresh_token=token)
# 直接调 auth API 绕过 SDK bug
resp = requests.post(
'https://auth.aliyundrive.com/v2/account/token',
json={"refresh_token": token, "grant_type": "refresh_token"},
timeout=10
This code sends the user-supplied refresh token to https://auth.aliyundrive.com/v2/account/token to obtain access credentials. Although network use is intrinsic to cloud-drive functionality, there is no visible print/log/confirmation or comment near the CLI interface warning users that their credential will be transmitted to a remote service.
Data is uploaded to cloud storage (S3 / GCS / Azure Blob). This may be a legitimate backup or exfiltration to an external bucket. Manual review is recommended.
parent_id = ensure_folder(pan, target_folder, parent_id)
# 上传
result = pan.upload_file(parent_file_id=parent_id, path=path)
# upload_file 可能返回: str(file_id), False, None, 或 Response 对象
if isinstance(result, str):
The manifest description highlights uploading files, creating folders, searching files, and managing share links, but it does not mention deleting cloud files. The code exposes a delete action that permanently modifies remote content, which is a materially broader behavior than the described examples.
The delete operation performs an irreversible remote action with no confirmation, dry-run mode, or safety checks. In agent-driven contexts, this raises the risk of accidental or prompt-induced destructive behavior against user cloud data.
The code silently modifies stored credentials by writing a refreshed token back to disk, which is a sensitive side effect with no user-facing confirmation. Because the write target is user-controlled via --save-token, this also increases the chance of accidental or unsafe credential handling.
The natural-language comments identify the skill solely in Chinese and do not offer any language choice or opt-in. Under the locale policy, language constraints should be optional or clearly justified rather than implicitly forced.
The skill reads a refresh token directly from a local .env file without declaring that credential access behavior. In an agent environment, silent local secret consumption is dangerous because it expands trust boundaries and may use credentials the user did not intend to expose to this skill.
The code implements download-link retrieval and user account info access, but these capabilities are not clearly described in the skill metadata. Undisclosed data-access features reduce transparency and can expose file access URLs or account details in contexts where users only expected upload or folder-management behavior.
The top-level docstring describes the skill exclusively in Chinese and does not offer an alternate language or indicate that the locale restriction is intentional. This can violate language policy expectations when users are not given a choice of language.