Back to skill

Security audit

Feishu Docx

Security checks for vulnerabilities and agentic risk

Overview

This skill can operate on Feishu documents, but it ships live-looking credentials and tenant-specific scripts that upload local content to a fixed Feishu destination without clear user control.

Review carefully before installing. Do not use the bundled credentials; they should be revoked and replaced with your own securely stored Feishu credentials. Remove or ignore the tenant-specific scripts unless you explicitly intend to upload that exact local file to that exact Feishu folder, and verify any remote create, upload, import, or delete operation before running it.

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
SKILL.md:12
Finding
Hardcoded Feishu Application Credentials Exposed in Documentation and Executable Scripts<![CDATA[ ## Vulnerability Details **File Locations**: - `SKILL.md:12-15` - `SKILL.md:27-29` - `scripts/import_egg_cake_report.py:5-8` - `scripts/perfect_import_egg_cake.py:7-10` - `scripts/write_tangyuan.py:5-7` **Vulnerability Type**: Hardcoded application secret **Risk Level**: High ### Vulnerable Code `SKILL.md:12-15`: ```markdown ## 认证信息 使用该技能前,需确保已设置以下环境变量或在代码中显式传入: - `FEISHU_APP_ID`: cli_a92c5076b7789cd2 - `FEISHU_APP_SECRET`: 9jPdCn49G54RFoEoDPUCVcptnWZnTZqp ``` `SKILL.md:27-29`: ```python from scripts.feishu_docx_client import FeishuDocx client = FeishuDocx(app_id="cli_a92c5076b7789cd2", app_secret="9jPdCn49G54RFoEoDPUCVcptnWZnTZqp") ``` `scripts/import_egg_cake_report.py:5-8`: ```python def main(): app_id = "cli_a92c5076b7789cd2" app_secret = "9jPdCn49G54RFoEoDPUCVcptnWZnTZqp" folder_token = "CicIfQH2VlKqV0dBK4mceVMRnqf" ``` `scripts/perfect_import_egg_cake.py:7-10`: ```python def main(): app_id = "cli_a92c5076b7789cd2" app_secret = "9jPdCn49G54RFoEoDPUCVcptnWZnTZqp" folder_token = "CicIfQH2VlKqV0dBK4mceVMRnqf" ``` `scripts/write_tangyuan.py:5-7`: ```python def main(): app_id = "cli_a92c5076b7789cd2" app_secret = "9jPdCn49G54RFoEoDPUCVcptnWZnTZqp" ``` ### Technical Analysis A live-looking Feishu App ID and App Secret are embedded directly in distributed documentation and executable source files. The client submits these values to Feishu's tenant-token endpoint: ```python payload = { "app_id": self.app_id, "app_secret": self.app_secret } res = requests.post(url, json=payload) ``` Although sending credentials to Feishu's official HTTPS authentication endpoint is necessary for the declared functionality, distributing the secret in plaintext is not necessary. Anyone who can read the Skill package can extract and reuse the credentials independently of the Skill. The resulting access level depends on the permissions granted to the Feishu application. An attacker does not automatically gain unrestrict ...[truncated 1296 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Immediately revoke and rotate the exposed Feishu App Secret. 2. Review Feishu audit logs for token issuance and API activity involving this application. 3. Remove the secret from all documentation, scripts, examples, release artifacts, and source-control history. 4. Load credentials from environment variables or an approved secret manager: ```python app_id = os.environ["FEISHU_APP_ID"] app_secret = os.environ["FEISHU_APP_SECRET"] ``` 5. Fail safely when credentials are absent; do not provide fallback credentials. 6. Never place real secrets in example code. Use obvious placeholders such as: ```python client = FeishuDocx( app_id=os.environ["FEISHU_APP_ID"], app_secret=os.environ["FEISHU_APP_SECRET"], ) ``` 7. Restrict the Feishu application's scopes to the minimum necessary for document creation and editing. Remove Drive upload or deletion permissions if those operations are not essential. 8. Establish secret scanning in source control and CI to prevent future credential commits. 9. Use separate, short-lived credentials or applications for development and production environments. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/perfect_import_egg_cake.py:8
Finding
Private Workspace File Is Uploaded to a Hardcoded Tenant Destination<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/perfect_import_egg_cake.py:8-34` - `scripts/import_egg_cake_report.py:6-24` - `scripts/write_tangyuan.py:300-305` **Vulnerability Type**: Fixed local data source and tenant-specific cloud destination **Risk Level**: Medium ### Vulnerable Code `scripts/perfect_import_egg_cake.py:8-34`: ```python app_id = "cli_a92c5076b7789cd2" app_secret = "9jPdCn49G54RFoEoDPUCVcptnWZnTZqp" folder_token = "CicIfQH2VlKqV0dBK4mceVMRnqf" file_path = "/Users/cpjhy0535/.openclaw/workspace-master/cases/空气炸锅鸡蛋饼 - 爆款拆解报告.md" file_name = "空气炸锅鸡蛋饼 - 爆款拆解报告(完美版)" if not os.path.exists(file_path): print(f"Error: File not found at {file_path}") sys.exit(1) client = FeishuDocx(app_id, app_secret) try: # 1. 上传文件到云端 print(f"Uploading file: {file_path}") file_token = client.upload_file(file_path, folder_token) print(f"File uploaded, token: {file_token}") # 2. 发起导入任务 (Markdown -> Docx) print("Starting import task...") doc_token = client.import_markdown(file_token, file_name, folder_token) print(f"Import successful! New Doc Token: {doc_token}") print(f"URL: https://txx-claw.feishu.cn/docx/{doc_token}") # 3. 清理暂存的源文件 print(f"Deleting temporary source file: {file_token}") client.delete_file(file_token) ``` `scripts/import_egg_cake_report.py:6-24`: ```python app_id = "cli_a92c5076b7789cd2" app_secret = "9jPdCn49G54RFoEoDPUCVcptnWZnTZqp" folder_token = "CicIfQH2VlKqV0dBK4mceVMRnqf" file_path = "/Users/cpjhy0535/.openclaw/workspace-master/cases/空气炸锅鸡蛋饼 - 爆款拆解报告.md" title = "空气炸锅鸡蛋饼 - 爆款拆解报告" if not os.path.exists(file_path): print(f"Error: File not found at {file_path}") sys.exit(1) with open(file_path, 'r', encoding='utf-8') as f: content = f.read() client = FeishuDocx(app_id, ap ...[truncated 3271 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove tenant-specific workflow scripts and private filesystem paths from the distributable Skill. 2. Require the source path and destination folder token as explicit runtime inputs. 3. Before any upload, display: - The normalized local path. - The destination tenant and folder. - The file size and operation type. 4. Require affirmative user confirmation before transferring local content. 5. Restrict source files to a user-approved directory and reject symbolic-link escapes where appropriate. 6. Validate the selected file type, size, and path before opening it. 7. Do not bundle a default folder token. Require the user to select or configure a destination they control. 8. Separate Docx-only functionality from Drive upload/import functionality and request only the scopes needed for the chosen operation. 9. Implement transactional cleanup for partial failures, including deletion of documents created before a later operation fails. 10. Implement or remove calls to `append_markdown()` so scripts do not create empty documents and then fail. 11. Clearly document that upload/import operations transmit local content to Feishu and may create persistent cloud copies. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
scripts/feishu_docx_client.py:45
Finding
Feishu Resource Identifiers and API Error Bodies Are Written to Logs<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/feishu_docx_client.py:45-48` - `scripts/feishu_docx_client.py:68-71` - `scripts/feishu_docx_client.py:84-85` - `scripts/perfect_import_egg_cake.py:23-33` **Vulnerability Type**: Sensitive metadata exposure through diagnostic output **Risk Level**: Low ### Vulnerable Code `scripts/feishu_docx_client.py:45-48`: ```python res = requests.post(url, headers=headers, data=data, files=files) if res.status_code != 200: print(f"DEBUG Upload Error: {res.text}") res.raise_for_status() ``` `scripts/feishu_docx_client.py:68-71`: ```python print(f"DEBUG Payload: {json.dumps(payload)}") res = requests.post(url, headers=headers, json=payload) if res.status_code != 200: print(f"DEBUG Response: {res.text}") ``` `scripts/feishu_docx_client.py:84-85`: ```python else: raise Exception(f"Import failed: {check_res.text}") ``` `scripts/perfect_import_egg_cake.py:23-33`: ```python file_token = client.upload_file(file_path, folder_token) print(f"File uploaded, token: {file_token}") # 2. 发起导入任务 (Markdown -> Docx) print("Starting import task...") doc_token = client.import_markdown(file_token, file_name, folder_token) print(f"Import successful! New Doc Token: {doc_token}") print(f"URL: https://txx-claw.feishu.cn/docx/{doc_token}") # 3. 清理暂存的源文件 print(f"Deleting temporary source file: {file_token}") ``` ### Technical Analysis The code prints file tokens, document tokens, destination metadata, complete API payloads, tenant-specific URLs, and unfiltered response bodies to standard output. Feishu file and document tokens are resource identifiers and are not equivalent to the App Secret or bearer access token. They may not independently bypass Feishu access control. However, exposing them in terminal histories, CI log ...[truncated 1650 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove unconditional debug output from production code. 2. Do not print complete file tokens, document tokens, folder tokens, tickets, or tenant URLs. 3. Redact identifiers when operational correlation is required: ```python def redact(value: str) -> str: if not value: return "<missing>" return f"{value[:4]}...{value[-4:]}" ``` 4. Replace complete response-body logging with a sanitized status code, request correlation ID, and approved non-sensitive error fields. 5. Do not include raw response bodies in raised exceptions. 6. Use a structured logging framework with secure defaults and explicit log levels. 7. Disable debug logging by default and require an intentional opt-in. 8. Configure retention and access controls for CI, agent, and application logs. 9. Add tests confirming that credentials, bearer tokens, file tokens, document tokens, and folder tokens never appear in logs. ]]>
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 (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The skill description promises broad creation/editing capabilities but the implementation appears to perform only a narrow preset workflow against a fixed folder/resource using embedded credentials. This discrepancy is security-relevant because it conceals the true operational scope and destination of writes, making unauthorized or unintended modification of a specific Feishu resource more likely.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The skill description promises broad creation/editing capabilities but the implementation appears to perform only a narrow preset workflow against a fixed folder/resource using embedded credentials. This discrepancy is security-relevant because it conceals the true operational scope and destination of writes, making unauthorized or unintended modification of a specific Feishu resource more likely.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill description promises broad creation/editing capabilities but the implementation appears to perform only a narrow preset workflow against a fixed folder/resource using embedded credentials. This discrepancy is security-relevant because it conceals the true operational scope and destination of writes, making unauthorized or unintended modification of a specific Feishu resource more likely.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill description promises broad creation/editing capabilities but the implementation appears to perform only a narrow preset workflow against a fixed folder/resource using embedded credentials. This discrepancy is security-relevant because it conceals the true operational scope and destination of writes, making unauthorized or unintended modification of a specific Feishu resource more likely.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The documentation contains concrete App ID and App Secret values directly in setup instructions and code examples. Embedded live-looking credentials are highly dangerous because they can be harvested for unauthorized API access, token generation, remote document manipulation, and potential abuse of the associated Feishu tenant.

Missing User Warnings

High
Confidence
98% confidence
Finding
The skill not only exposes credentials but also normalizes hardcoded secret usage without any warning about secure handling. This encourages insecure operator behavior, increases the chance of credential reuse and leakage, and makes accidental compromise more likely in downstream copies of the example.

Lp3

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding
The skill declares no explicit tool scope or permissions despite clearly describing network-based API access and implying file access via the referenced client script. Missing scope declarations reduce transparency and can cause an agent or user to underestimate the skill’s effective capabilities, especially when combined with other undocumented behaviors flagged here.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The skill is described as creating and editing Feishu cloud documents, which can alter user data in an external service. However, the markdown does not include any explicit warning or confirmation note that using the skill will write to remote documents and may modify existing content.

External Transmission

Medium
Category
Data Exfiltration
Content
"app_id": self.app_id,
            "app_secret": self.app_secret
        }
        res = requests.post(url, json=payload)
        res.raise_for_status()
        return res.json().get("tenant_access_token")
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The skill description says it creates and edits Feishu docx documents, but the implementation also uploads arbitrary local files and deletes remote cloud files. This capability mismatch is dangerous because users or upstream agents may grant trust based on the narrower description, leading to unintended exfiltration of local data or destructive actions in Feishu Drive.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The upload_file method sends arbitrary local file contents to Feishu over the network without any built-in disclosure, confirmation, or restriction on what may be uploaded. In an agent skill context, this increases the risk of silent exfiltration of sensitive local files if the caller passes an unexpected path.

External Transmission

Medium
Category
Data Exfiltration
Content
}
        }
        print(f"DEBUG Payload: {json.dumps(payload)}")
        res = requests.post(url, headers=headers, json=payload)
        if res.status_code != 200:
            print(f"DEBUG Response: {res.text}")
        res.raise_for_status()
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
}
        }
        print(f"DEBUG Payload: {json.dumps(payload)}")
        res = requests.post(url, headers=headers, json=payload)
        if res.status_code != 200:
            print(f"DEBUG Response: {res.text}")
        res.raise_for_status()
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Tainted flow: 'check_url' from requests.post (line 75, network input) → requests.get (network output)

Medium
Category
Data Flow
Content
check_url = f"https://open.feishu.cn/open-apis/drive/v1/import_tasks/{ticket}"
        while True:
            time.sleep(1)
            check_res = requests.get(check_url, headers={"Authorization": f"Bearer {self.tenant_access_token}"})
            check_res.raise_for_status()
            result_data = check_res.json()["data"]["result"]
            if result_data["job_status"] == 0: # 成功
Confidence
65% confidence
Finding
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The delete_file method performs a remote deletion action with no confirmation, safety interlock, or user-facing warning. In an automation or agent setting, this can cause unintended destructive changes to cloud data if a wrong token is supplied or the action is triggered unexpectedly.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The script contains a hard-coded absolute local file path and reads that file's full contents, then later uploads the content to Feishu. In the context of a reusable skill, this creates a real data exposure risk because it normalizes accessing a user's local filesystem and transferring content off-host without validation, minimization, or clear consent controls.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
The script reads a local Markdown file and sends its contents to a third-party service using API credentials, but provides no user-facing disclosure or consent step before transmission. This is dangerous because sensitive local data could be exfiltrated to an external platform unintentionally, especially in an agent/skill setting where users may not realize local files are being uploaded.

Missing User Warnings

Medium
Confidence
99% confidence
Finding
The file embeds application credentials directly in source code and uses them without any disclosure or secure handling. Hard-coded secrets are highly dangerous because anyone with access to the code can reuse them to access the associated Feishu application, potentially leading to unauthorized document operations and broader data exposure.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The script uses a hard-coded absolute local path pointing to a user workspace file, which can cause unintended access to local data and makes the behavior non-transparent. In an agent skill context, hard-coded filesystem access is risky because it may exfiltrate sensitive user content without prompting and is not limited by runtime user choice.

Cloud Storage Exfiltration

Medium
Category
Data Exfiltration
Content
try:
        # 1. 上传文件到云端
        print(f"Uploading file: {file_path}")
        file_token = client.upload_file(file_path, folder_token)
        print(f"File uploaded, token: {file_token}")
        
        # 2. 发起导入任务 (Markdown -> Docx)
Confidence
93% confidence
Finding
The upload_file call sends a local file to cloud storage, which is a direct exfiltration path for potentially sensitive local data. In this skill context, that is more dangerous because the code targets a specific local file and performs the transfer automatically using embedded credentials, without any runtime consent or data classification checks.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The script performs file upload, remote import, and remote deletion operations even though the skill description emphasizes creating and editing Feishu docx documents. That expanded behavior increases the attack surface because local content is transmitted to the cloud and then a cleanup action deletes the uploaded source object without any explicit user approval or visibility into what data is being handled.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The script automatically uploads a local file to Feishu and deletes the temporary remote source file with no user warning, consent, or confirmation step. Silent cloud operations are dangerous because users may not realize local content is being transmitted off-device or that cleanup actions are modifying remote state.

Missing User Warnings

Medium
Confidence
99% confidence
Finding
The file hardcodes a Feishu App ID and App Secret directly in source code, exposing reusable credentials to anyone who can read the repository, logs, or packaged skill. Embedded secrets are easily leaked, difficult to rotate safely, and may allow unauthorized use of the Feishu API, document creation, or access within the associated tenant.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The script sends document content to Feishu using an external API but provides no user-facing notice or consent flow, so users may unknowingly transmit data off-host. In this specific file the content is not especially sensitive, but the skill is a generic document creation/editing capability and could be reused with sensitive content, making silent exfiltration to a third-party service a real privacy and security concern.

Natural-Language Policy Violations

Low
Confidence
82% confidence
Finding
The line states the skill allows `老大` to operate on documents, implying a fixed form of address in Chinese rather than a user-selectable language or locale-neutral phrasing. This is a natural-language policy concern because it imposes a specific linguistic convention without opt-in.

Static analysis

No suspicious patterns detected.