Back to skill

Security audit

dataworks-diagnoser

Security checks for vulnerabilities and agentic risk

Overview

This skill appears intended to diagnose Alibaba Cloud DataWorks task failures, but it handles cloud credentials in ways that can expose them and asks for broader permissions than its code appears to need.

Review before installing. Use a dedicated, least-privileged RAM role or short-lived credentials, avoid command-line --access-secret, do not keep credentials.json in project directories, protect any credential file with restrictive permissions, and redact sensitive task logs before saving or sharing reports.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/dataworks_diagnose.py:91
Finding

Alibaba Cloud AccessKey Secret Exposed Through Command-Line Arguments

Content
View full analysis

Vulnerability Details

File Locations:

  • scripts/dataworks_diagnose.py:66-67
  • scripts/dataworks_diagnose.py:91-94
  • scripts/fetch_instance_log.py:167-168
  • scripts/fetch_instance_log_sdk.py:155-156
  • README.md:149-152
  • SKILL.md:223-224

Vulnerability Type: Command-line credential exposure
Risk Level: High

Vulnerable Code

scripts/dataworks_diagnose.py:66-67:

python
parser.add_argument("--access-key", help="Access Key ID")
parser.add_argument("--access-secret", help="Access Key Secret")

scripts/dataworks_diagnose.py:91-94:

python
if args.access_key:
    fetch_args.extend(['--access-key', args.access_key])
if args.access_secret:
    fetch_args.extend(['--access-secret', args.access_secret])

scripts/fetch_instance_log.py:167-168:

python
parser.add_argument("--access-key", help="Access Key ID")
parser.add_argument("--access-secret", help="Access Key Secret")

scripts/fetch_instance_log_sdk.py:155-156:

python
parser.add_argument("--access-key", help="Access Key ID")
parser.add_argument("--access-secret", help="Access Key Secret")

The documentation also explicitly recommends passing the secret in the command line:

bash
python3 scripts/dataworks_diagnose.py INSTANCE_ID \
  --access-key LTAI5t... \
  --access-secret xxxxxx

Technical Analysis

Secrets placed in command-line arguments can be exposed through shell history, process inspection utilities, endpoint monitoring software, diagnostic reports, audit logs, and process telemetry. The all-in-one script further forwards the secret to a child Python process by including it in subprocess.run()'s argument list.

Although the subprocess is invoked with a list and is therefore not vulnerable to shell metacharacter injection, the AccessKey Secret remains visible in the parent command and child process argument vectors. This behavior is unnecessary because t ...[truncated 1406 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the --access-secret option from all scripts and documentation.
  2. Prefer the official Alibaba Cloud credential-provider chain, RAM roles, workload identity, or short-lived Security Token Service credentials.
  3. Avoid passing credentials from the orchestration script to a child process. Let the child SDK resolve credentials directly from a secure provider.
  4. If manual entry is required, use getpass.getpass() so the secret is not echoed or stored in an argument vector.
  5. Avoid long-lived primary-account AccessKeys and require a narrowly scoped RAM identity.
  6. Update examples in README.md and SKILL.md to prohibit command-line secrets explicitly.
  7. Rotate any credentials that may previously have been supplied through command-line arguments or recorded in shell history.

T09 · Insecure Skill Coding Practices

Warning
Location
README.md:142
Finding

Plaintext Credential Files Are Recommended Without Restrictive Permissions

Content
View full analysis

Vulnerability Details

File Locations:

  • README.md:142-148
  • SKILL.md:74-80
  • scripts/fetch_instance_log.py:40-53
  • scripts/fetch_instance_log_sdk.py:36-49

Vulnerability Type: Insecure plaintext credential storage and automatic credential discovery
Risk Level: Medium

Vulnerable Code

README.md:142-148 recommends creating a plaintext credential file without setting restrictive permissions:

bash
cat > ~/.alibabacloud/credentials << EOF
{
  "access_key_id": "LTAI5t...",
  "access_key_secret": "xxxxxx"
}
EOF

scripts/fetch_instance_log.py:40-53 automatically reads credentials from the home directory and then from a generic file in the current working directory:

python
config_path = Path.home() / '.alibabacloud' / 'credentials'
if config_path.exists():
    try:
        config = json.loads(config_path.read_text())
        return config.get('access_key_id'), config.get('access_key_secret')
    except Exception:
        pass

# Try current directory credentials.json
config_path = Path('credentials.json')
if config_path.exists():
    try:
        config = json.loads(config_path.read_text())
        return config.get('access_key_id'), config.get('access_key_secret')
    except Exception:
        pass

The same current-directory and home-directory behavior appears in scripts/fetch_instance_log_sdk.py:36-49.

Technical Analysis

The documented shell redirection creates or truncates a plaintext file under the user's active umask. The instructions do not create the containing directory securely, set file mode 0600, or verify ownership and permissions before the scripts read the file.

Automatic discovery of credentials.json in the current working directory also encourages storage of long-lived credentials inside project directories. Such directories are commonly committed to source control, synchronized to cloud storage, included in archives, ...[truncated 1368 chars]

Remediation
View remediation

Remediation Suggestions

  1. Prefer RAM roles, workload identity, or short-lived STS credentials instead of persistent plaintext AccessKeys.

  2. Remove automatic credential loading from the current-directory credentials.json file.

  3. If file-based credentials remain supported, use the official Alibaba Cloud credential format and provider implementation.

  4. Document secure creation explicitly:

    bash
    install -d -m 700 ~/.alibabacloud
    umask 077
    install -m 600 /dev/null ~/.alibabacloud/credentials
    
  5. Before reading a credential file, validate that it is a regular file, is owned by the current user, is not a symbolic link, and is not accessible by group or other users.

  6. Reject insecure permissions with a clear error rather than silently continuing.

  7. Add credentials.json and equivalent secret files to .gitignore, secret-scanning rules, packaging exclusions, and container ignore files.

  8. Warn users to rotate any AccessKeys that were previously committed, shared, or stored with permissive access.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
README.md:157
Finding

Documented RAM Policy Grants an Unused DataWorks Permission

Content
View full analysis

Vulnerability Details

File Locations:

  • README.md:157-171
  • SKILL.md:87-90
  • Relevant implemented API call: scripts/fetch_instance_log.py:94-103

Vulnerability Type: Violation of least privilege
Risk Level: Medium

Vulnerable Configuration

README.md:157-171 recommends granting both log retrieval and task-query permissions:

json
{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "dataworks:GetTaskInstanceLog",
        "dataworks:QueryTask"
      ],
      "Resource": "*"
    }
  ]
}

SKILL.md:87-90 repeats the same permission requirement:

text
The AccessKey needs these permissions:
- `dataworks:GetInstanceLog` - Fetch task instance logs
- `dataworks:QueryTask` - Query task information

The reviewed primary fetcher only constructs and sends a GetTaskInstanceLog request:

python
request = dataworks_models.GetTaskInstanceLogRequest(id=int(instance_id))

# Set runtime options
runtime = util_models.RuntimeOptions()

# Send request
response = client.get_task_instance_log_with_options(request, runtime)

No QueryTask invocation was found in the reviewed Python scripts.

Technical Analysis

Least privilege requires an identity to receive only the permissions necessary for the implemented operation. The Skill's executable workflow retrieves a task-instance log and performs local pattern analysis. It does not query general task information using QueryTask.

Granting dataworks:QueryTask therefore expands the credential's capabilities without supporting an observed code path. The policy also uses "Resource": "*", which may further broaden scope where the Alibaba Cloud action supports resource-level restrictions.

The permission names are inconsistent between the two documentation files: SKILL.md lists dataworks:GetInstanceLog, while README.md lists dataworks:GetTaskInstanceLog. Th ...[truncated 1297 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove dataworks:QueryTask from the documented policy unless a concrete feature is implemented that invokes it.
  2. Verify the exact Alibaba Cloud action name required by the GetTaskInstanceLog SDK operation and use it consistently in README.md and SKILL.md.
  3. Replace "Resource": "*" with the narrowest supported workspace, project, or resource scope.
  4. Publish a tested minimal RAM policy corresponding exactly to the API operations performed by the scripts.
  5. Use a dedicated RAM identity or role for this Skill rather than an existing broadly privileged AccessKey.
  6. Add an automated test or documentation check that compares implemented API operations with the permissions listed in the example policy.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (25)

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

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

md
"kind": "brew",
              "formula": "curl",
              "bins": ["curl"],
              "label": "Install curl (brew)",
            },
          ],
      },

Credential Access

High
Category
Privilege Escalation
Confidence
78% confidence
Finding

The script automatically reads access keys from a local credentials.json in the current working directory, which is an unsafe credential sourcing pattern. In an agent or automation context, the working directory may be attacker-influenced, causing the tool to silently consume unintended credentials or secrets from an untrusted file.

Content

Scanner excerpt · scripts/fetch_instance_log.py (reported line 48)May include surrounding context.

python
except Exception:
            pass
    
    # Try current directory credentials.json
    config_path = Path('credentials.json')
    if config_path.exists():
        try:

Credential Access

High
Category
Privilege Escalation
Confidence
78% confidence
Finding

This line is part of the same risky behavior: parsing a current-directory credentials.json without establishing trust in the file origin or permissions. In shared workspaces, CI jobs, or agent environments, that can lead to credential confusion, accidental use of planted keys, or unintended account access.

Content

Scanner excerpt · scripts/fetch_instance_log.py (reported line 49)May include surrounding context.

python
pass
    
    # Try current directory credentials.json
    config_path = Path('credentials.json')
    if config_path.exists():
        try:
            config = json.loads(config_path.read_text())

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/fetch_instance_log.py (reported line 76)May include surrounding context.

python
except Exception:
            pass
    
    # Try current directory credentials.json
    config_path = Path('credentials.json')
    if config_path.exists():
        try:

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/fetch_instance_log_sdk.py (reported line 44)May include surrounding context.

python
except Exception:
            pass
    
    # Try current directory credentials.json
    config_path = Path('credentials.json')
    if config_path.exists():
        try:

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/fetch_instance_log_sdk.py (reported line 45)May include surrounding context.

python
except Exception:
            pass
    
    # Try current directory credentials.json
    config_path = Path('credentials.json')
    if config_path.exists():
        try:

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/fetch_instance_log_sdk.py (reported line 70)May include surrounding context.

python
except Exception:
            pass
    
    # Try current directory credentials.json
    config_path = Path('credentials.json')
    if config_path.exists():
        try:

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README explicitly says task logs are sent to AI for analysis, but it does not clearly warn that those logs may contain sensitive business data, credentials, SQL text, identifiers, or personal data. In a diagnostics tool, users may paste or fetch production logs by default, so missing disclosure and sanitization guidance increases the risk of unintended data exposure to external AI services.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
82% confidence
Finding

The skill instructs users to persist long-lived Alibaba Cloud access keys in a local credentials file under the home directory. Storing static secrets on disk increases the chance of credential theft through local compromise, backups, permissive file permissions, or accidental inclusion in support bundles, especially because this skill is specifically used to fetch potentially sensitive task logs from a cloud environment.

Content

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

text

**Option B: Config File**
Create `~/.alibabacloud/credentials`:
```json
{
  "access_key_id": "your_access_key",

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The guide explicitly instructs users to collect and share complete error logs, task configuration screenshots, and resource monitoring data, but it provides no caution about redacting secrets or sensitive operational details first. In a DataWorks context, those artifacts can contain AccessKeys, usernames, hostnames, IP allowlist details, table names, internal topology, and other information that could enable credential exposure or reconnaissance if shared broadly.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python skill contains numerous hard-coded Chinese user-facing strings for causes, solutions, next steps, and report text, which effectively forces a specific language on all users. The file does not offer any language selection, opt-in, or justification for a Chinese-only locale, which matches the language/locale policy violation criteria.

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/dataworks_diagnose.py (reported line 31)May include surrounding context.

python
cmd = [sys.executable, str(script_path)] + args
    
    try:
        result = subprocess.run(
            cmd,
            capture_output=capture,
            text=True,

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's runtime messages and labels are consistently presented in Chinese, such as status updates and report headings. This enforces a specific language for all users without opt-in or justification, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code embeds Chinese-only titles and solution text in its diagnostic results, and the generated report is also Chinese-facing. Because the script does not offer users a language/locale option or clearly justify that it is intended only for a Chinese-speaking or region-specific environment, it creates a natural-language locale policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The user-facing report headers, labels, and guidance are emitted in Chinese regardless of user preference. This forces a specific language experience without opt-in or configurable locale selection, which fits the policy-violation criteria for natural-language handling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code loads cloud credentials from environment variables and local credential files, then uses them to make a remote API request to Alibaba Cloud. While the script's purpose is to fetch logs, there is no user-facing disclosure in the CLI help or operational output warning that credentials will be read from local sources and used for a network call.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

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

md
"""
    Fetch task instance log from DataWorks API using official SDK
    
    API: https://api.aliyun.com/api/dataworks-public/2024-05-18/GetTaskInstanceLog
    """
    # Load credentials if not provided
    if not access_key or not access_secret:

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

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

md
"""
    Fetch task instance log from DataWorks API using official SDK
    
    API: https://api.aliyun.com/api/dataworks-public/2024-05-18/GetTaskInstanceLog
    """
    # Load credentials if not provided
    if not access_key or not access_secret:

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/fetch_instance_log.py (reported line 64)May include surrounding context.

python
"""
    Fetch task instance log from DataWorks API using official SDK
    
    API: https://api.aliyun.com/api/dataworks-public/2024-05-18/GetTaskInstanceLog
    """
    # Load credentials if not provided
    if not access_key or not access_secret:

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script accepts the Alibaba Cloud access key and secret directly via command-line arguments. Command-line arguments are commonly exposed through shell history, process listings, audit logs, and job runners, which can leak long-lived cloud credentials to other local users or monitoring systems.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill documentation appears to force a single language/locale for all user-facing instructions. Under the stated policy, this is a natural-language locale constraint unless the skill offers an opt-in language choice or clearly documents that it is intended only for a specific region or audience.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The sample diagnostic output is entirely in Chinese, and the region table also uses Chinese labels, but the document does not state that output language is configurable or limited to a Chinese-language audience. This can violate language/locale policy expectations if users are not given a choice or warned that the skill may operate in a specific language.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
87% confidence
Finding

The dependency is specified with a lower-bound constraint only, which allows future upstream releases to be installed without review. This creates supply-chain risk because a breaking, vulnerable, or compromised release could be pulled into the environment unexpectedly.

Content

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

text
# DataWorks Diagnoser - Python Dependencies

# Alibaba Cloud SDK (required for API access)
alibabacloud_dataworks_public20240518>=1.0.0
alibabacloud_credentials>=0.3.0

# Optional: for HTTP requests to official docs

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
87% confidence
Finding

The dependency is unpinned and permits any version at or above the minimum, making builds non-reproducible and increasing exposure to malicious or vulnerable upstream releases. In a package that handles cloud access, unexpected dependency changes can affect authentication-related behavior or introduce supply-chain compromise paths.

Content

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

text
# Alibaba Cloud SDK (required for API access)
alibabacloud_dataworks_public20240518>=1.0.0
alibabacloud_credentials>=0.3.0

# Optional: for HTTP requests to official docs
# requests>=2.28.0

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring includes an example using --auto-fix, implying the tool can perform automatic remediation. However, the argument parser defines no --auto-fix option and the code only fetches logs, analyzes them, and optionally saves outputs, so the documentation contradicts actual behavior.

Content

No source excerpt is available for this finding.