Back to skill

Security audit

Feishu Bot Creator

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it says, but it handles Feishu credentials in ways that can expose long-lived app secrets and tokens.

Install only if you are comfortable with this skill creating Feishu apps and permissions using your tenant credentials. Do not set FEISHU_API_BASE unless you fully trust the endpoint, avoid running it where stdout is logged, choose a private output path, and restrict the saved config file because it contains app_secret and webhook data.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/feishu_bot_creator.py:15
Finding

Configurable API Base Allows Credential and Access-Token Exfiltration

Content
View full analysis

Vulnerability Details

File Location: scripts/feishu_bot_creator.py, lines 15 and 31–37; bearer tokens are subsequently transmitted using the same configurable base URL at lines 54–59, 89–94, and 113–118.
Vulnerability Type: Unrestricted sensitive-data transmission endpoint
Risk Level: High

Vulnerable Code

python
# Feishu API base URL
FEISHU_API_BASE = os.environ.get("FEISHU_API_BASE", "https://open.feishu.cn")
python
def get_access_token(self):
    """Get access token"""
    url = f"{FEISHU_API_BASE}/open-apis/auth/v3/tenant_access_token/internal"
    payload = {
        "app_id": self.app_id,
        "app_secret": self.app_secret
    }

    response = requests.post(url, json=payload)
    data = response.json()

Subsequent authenticated calls use the same unrestricted endpoint pattern:

python
url = f"{FEISHU_API_BASE}/open-apis/application/v4/app/create"
headers = {
    "Authorization": f"Bearer {self.access_token}",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

Technical Analysis

The script must transmit the Feishu app ID and app secret to obtain a tenant access token, which is necessary for its declared functionality. However, the destination is controlled entirely through the FEISHU_API_BASE environment variable.

The code does not enforce HTTPS, validate the destination hostname, restrict the endpoint to an approved allowlist, or prevent requests to an attacker-controlled service. Consequently, a modified process environment can redirect the initial credential exchange to any HTTP or HTTPS server. The same configurable base is then used for API requests carrying a bearer token in the Authorization header.

The lack of explicit timeouts also permits an untrusted endpoint to leave the process blocked indefinitely. The requests library follows redirects by default, while the code does ...[truncated 1631 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin production requests to the official endpoint, https://open.feishu.cn, instead of accepting an unrestricted environment variable.
  2. If alternate endpoints are required for legitimate regional or testing deployments, parse the URL and enforce:
    • The https scheme.
    • An explicit allowlist of trusted hostnames.
    • No embedded username or password.
    • No unexpected ports.
    • A fixed or validated path prefix.
  3. Reject loopback, private-network, link-local, and metadata-service destinations unless a documented test mode explicitly requires them.
  4. Disable redirects for credential-bearing requests with allow_redirects=False, or validate every redirect target against the same allowlist.
  5. Add bounded connection and response timeouts, for example:
    python
    response = requests.post(
        url,
        json=payload,
        timeout=(5, 30),
        allow_redirects=False,
    )
    
  6. Use a dedicated requests.Session with centralized endpoint validation so every authenticated request receives identical protections.
  7. Document any supported endpoint override as a high-trust administrator setting rather than a normal user-controlled option.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/feishu_bot_creator.py:137
Finding

Generated Application Secret Is Printed and Stored Without Explicit Access Controls

Content
View full analysis

Vulnerability Details

File Location: scripts/feishu_bot_creator.py, lines 78–79, 137–143, and 200–211
Vulnerability Type: Plaintext secret exposure through terminal output and configuration files
Risk Level: High

Vulnerable Code

The generated secret is printed directly:

python
app_info = data.get("data", {})
print(f"✅ Application created successfully: {name}")
print(f"   App ID: {app_info.get('app_id')}")
print(f"   App Secret: {app_info.get('app_secret')}")

return app_info

The configuration writer does not set restrictive permissions:

python
def save_config(self, config, output_path):
    """Save configuration file"""
    output_dir = os.path.dirname(output_path)
    if output_dir:
        os.makedirs(output_dir, exist_ok=True)

    with open(output_path, 'w', encoding='utf-8') as f:
        json.dump(config, f, indent=2, ensure_ascii=False)

    print(f"✅ Configuration saved: {output_path}")

The sensitive value is included in the saved configuration:

python
config = {
    "name": args.name,
    "description": args.description,
    "app_id": app_info.get("app_id"),
    "app_secret": app_info.get("app_secret"),
    "bot_id": bot_info.get("bot_id") if bot_info else None,
    "webhook_url": bot_info.get("webhook") if bot_info else args.webhook_url,
    "permissions": permissions
}

# Save configuration
output_path = args.output or f"~/.feishu/bots/{args.name}.json"
output_path = os.path.expanduser(output_path)
creator.save_config(config, output_path)

Technical Analysis

The script exposes the generated application secret through two independent channels.

First, it prints the complete secret to standard output. Terminal output is frequently retained by shell capture, CI/CD logs, job runners, monitoring agents, support bundles, or screen-recording systems. Printing the credential is unnecessary because the script already stores ...[truncated 2384 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove all plaintext secret output. Replace it with a non-sensitive confirmation:
    python
    print(f"   App ID: {app_info.get('app_id')}")
    print("   App Secret: generated and stored securely")
    
  2. Create the configuration directory with owner-only permissions:
    python
    os.makedirs(output_dir, mode=0o700, exist_ok=True)
    os.chmod(output_dir, 0o700)
    
  3. Create configuration files atomically with mode 0600, rather than relying on the process umask. Use os.open() with O_CREAT, O_EXCL or a safe replacement strategy, and 0o600.
  4. Verify the ownership and permissions of an existing destination before overwriting it.
  5. Prefer an operating-system credential store, encrypted secret manager, or Feishu-supported credential mechanism instead of embedding the app secret in general-purpose JSON.
  6. If the secret must remain in the JSON file, separate sensitive credentials from non-sensitive bot metadata and clearly identify the credential file as confidential.
  7. Avoid accepting secrets through command-line arguments because process arguments may be visible in process listings and command histories. Prefer protected environment injection, standard input, or an interactive no-echo prompt.
  8. Add documentation instructing users not to upload the configuration to source control, logs, ticketing systems, or shared storage, while treating documentation as supplementary rather than a replacement for technical controls.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (14)

Tainted flow: 'url' from os.environ.get (line 112, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
98% confidence
Finding

The base API URL is taken from the FEISHU_API_BASE environment variable and used directly for authenticated requests. If an attacker can influence that environment variable, the script will send the app ID, app secret, and later bearer tokens to an arbitrary host, enabling credential exfiltration and full compromise of the created Feishu app.

Content

Scanner excerpt · scripts/feishu_bot_creator.py (reported line 39)May include surrounding context.

python
"app_secret": self.app_secret
        }
        
        response = requests.post(url, json=payload)
        data = response.json()
        
        if data.get("code") != 0:

Tainted flow: 'url' from os.environ.get (line 112, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
95% confidence
Finding

After obtaining an access token, the script uses the same environment-controlled base URL for privileged API calls to create an application. A malicious endpoint could receive the bearer token and app metadata, allowing unauthorized use of tenant privileges and spoofed responses that trick the operator into trusting fake app details.

Content

Scanner excerpt · scripts/feishu_bot_creator.py (reported line 69)May include surrounding context.

python
"category": "效率办公"
        }
        
        response = requests.post(url, json=payload, headers=headers)
        data = response.json()
        
        if data.get("code") != 0:

Tainted flow: 'url' from os.environ.get (line 112, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
94% confidence
Finding

The permission update call sends an authorization bearer token to a URL derived from an environment variable. If redirected to an attacker-controlled server, the token can be harvested and used to perform or simulate privileged API actions, especially dangerous because this step manages application permissions.

Content

Scanner excerpt · scripts/feishu_bot_creator.py (reported line 99)May include surrounding context.

python
"permission_point_codes": permissions
        }
        
        response = requests.post(url, json=payload, headers=headers)
        data = response.json()
        
        if data.get("code") != 0:

Tainted flow: 'url' from os.environ.get (line 112, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
94% confidence
Finding

The bot creation request also relies on the untrusted FEISHU_API_BASE value, causing authenticated bot provisioning data and bearer tokens to be sent to any host specified in the environment. This expands the attack surface from secret theft to manipulation of returned bot configuration such as webhook values.

Content

Scanner excerpt · scripts/feishu_bot_creator.py (reported line 124)May include surrounding context.

python
"webhook": webhook_url if webhook_url else None
        }
        
        response = requests.post(url, json=payload, headers=headers)
        data = response.json()
        
        if data.get("code") != 0:

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script prints the newly created app secret directly to stdout. Secrets printed to terminal output can be captured by shell history tools, CI/CD logs, terminal recording, shared sessions, or monitoring systems, resulting in immediate credential exposure.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script writes app_id, app_secret, bot identifiers, and webhook data to a JSON file under the user's home directory without setting restrictive permissions or warning the user. On multi-user systems, backups, sync services, or compromised endpoints, this plaintext file becomes a durable source of credential leakage.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill automates network calls, reads environment variables for Feishu credentials, and writes bot secrets to local files, yet it declares no explicit tool scope or allowed-tools. This weakens sandboxing and informed consent because a host may permit broader capabilities than users expect, increasing the chance of unintended credential use or secret material being written to disk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill documentation notes that an app_secret is generated and shows it in output, but it does not prominently warn users that sensitive bot credentials will be stored in a local config file by default. This can lead to accidental exposure through weak filesystem permissions, backups, shared machines, or later source-control inclusion.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill is presented as a bot creator but actually provisions a full Feishu application and persists the resulting app secret. This scope expansion increases risk because users may run it expecting limited bot setup while it creates long-lived credentials with broader administrative value.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% 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/feishu_bot_creator.py (reported line 39)May include surrounding context.

python
"app_secret": self.app_secret
        }
        
        response = requests.post(url, json=payload)
        data = response.json()
        
        if data.get("code") != 0:

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% 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/feishu_bot_creator.py (reported line 69)May include surrounding context.

python
"app_secret": self.app_secret
        }
        
        response = requests.post(url, json=payload)
        data = response.json()
        
        if data.get("code") != 0:

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% 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/feishu_bot_creator.py (reported line 99)May include surrounding context.

python
"app_secret": self.app_secret
        }
        
        response = requests.post(url, json=payload)
        data = response.json()
        
        if data.get("code") != 0:

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% 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/feishu_bot_creator.py (reported line 124)May include surrounding context.

python
"app_secret": self.app_secret
        }
        
        response = requests.post(url, json=payload)
        data = response.json()
        
        if data.get("code") != 0:

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The manifest describes automating Feishu bot creation and configuration, but does not mention collecting credentials from process environment variables. While credentials are needed to call Feishu APIs, reading them from ambient environment state is an additional capability beyond the explicitly described bot-management actions.

Content

No source excerpt is available for this finding.