Back to skill

Security audit

飞书文档API对接

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real Feishu/Lark integration, but it needs review because it can send credentials to unvalidated configured endpoints and silently changes DNS behavior.

Review before installing. Use this only in trusted workspaces, keep .env and FEISHU_ENV_FILE under your control, do not set custom FEISHU_BASE_URL, FEISHU_TOKEN_URL, FEISHU_AUTH_URL, or FEISHU_AUTH_BASE_URL unless you have verified the exact host, and grant only the Feishu scopes needed. Consider removing the DNS fallback and pinning dependencies before using it with production credentials.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/feishu_api/config.py:45
Finding

Unrestricted API and OAuth endpoints can receive application secrets and access tokens

Content
View full analysis

Vulnerability Details

File Location: scripts/feishu_api/config.py:45-52, scripts/feishu_api/token_store.py:109-126, scripts/feishu_openapi_tool.py:182-235, and scripts/feishu_oauth_tool.py:90-105, 148-158, 263-278
Vulnerability Type: Arbitrary credential destination and insufficient transport validation
Risk Level: High

Vulnerable Code

scripts/feishu_api/config.py:45-52:

python
def env_value(name: str, default: str = "") -> str:
    return os.getenv(name, "").strip() or file_env.get(name, "").strip() or default

app_id = env_value("FEISHU_APP_ID")
app_secret = env_value("FEISHU_APP_SECRET")
base_url = env_value("FEISHU_BASE_URL", "https://open.feishu.cn")

scripts/feishu_api/token_store.py:109-126:

python
def tenant_access_token(settings: Any) -> str:
    url = settings.base_url.rstrip("/") + "/open-apis/auth/v3/tenant_access_token/internal"
    body = json.dumps({
        "app_id": settings.app_id,
        "app_secret": settings.app_secret,
    }, ensure_ascii=False).encode("utf-8")
    request = urllib.request.Request(
        url,
        data=body,
        headers={"Content-Type": "application/json; charset=utf-8"},
        method="POST",
    )
    try:
        with urllib.request.urlopen(request, timeout=30) as response:
            payload = json.loads(response.read().decode("utf-8"))

scripts/feishu_openapi_tool.py:182-235:

python
def base_url(env: dict[str, str]) -> str:
    return env.get("FEISHU_BASE_URL", "https://open.feishu.cn").rstrip("/")

def http_json(
    env: dict[str, str],
    method: str,
    path: str,
    *,
    bearer: str | None = None,
    body: dict[str, Any] | None = None,
    params: dict[str, Any] | None = None,
    retry_user_token: bool = True,
) -> dict[str, Any]:
    query = ""
    if params:
        clean_params = {k: v for k, v in params.items() if v is not None and v != ""}
  
...[truncated 5282 chars]
Remediation
View remediation

Remediation Suggestions

  1. Require HTTPS for every endpoint that receives credentials or bearer tokens.
  2. Allow only explicitly approved Feishu/Lark hosts by default, such as the documented official API and account hosts.
  3. Parse URLs with urllib.parse.urlsplit and reject:
    • Non-HTTPS schemes.
    • Embedded usernames or passwords.
    • Fragments.
    • Unexpected ports.
    • Missing or malformed hostnames.
    • Loopback, link-local, private, reserved, or unspecified destination addresses.
  4. Do not permit separate token and authorization URL overrides in ordinary operation. If private deployments require custom endpoints, gate them behind an explicit option such as --allow-custom-endpoint.
  5. Require the user to confirm the exact custom hostname before transmitting credentials.
  6. Disable automatic redirects for credential-bearing requests, or validate every redirect target against the same allowlist before following it.
  7. Never forward an Authorization header across a change of origin.
  8. Add tests proving that HTTP, arbitrary domains, embedded credentials, and redirects to unapproved hosts are rejected.
  9. Document that .env and FEISHU_ENV_FILE are security-sensitive inputs and must not be accepted from untrusted workspaces.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/feishu_api/dns.py:7
Finding

Process-wide DNS monkey patch silently routes Feishu traffic to hardcoded IP addresses

Content
View full analysis

Vulnerability Details

File Location: scripts/feishu_api/dns.py:7-48, duplicated in scripts/feishu_openapi_tool.py:25-70, and automatically installed by scripts/feishu_api/client.py:5-7
Vulnerability Type: Unsafe global network resolver modification and hardcoded endpoint routing
Risk Level: Medium

Vulnerable Code

scripts/feishu_api/dns.py:7-48:

python
FEISHU_HOST = "open.feishu.cn"
FALLBACK_IPV4 = (
    "101.89.125.72",
    "117.24.169.93",
    "106.227.20.100",
)

def install_feishu_dns_fallback() -> None:
    """Install a process-local DNS fallback for Feishu OpenAPI only."""
    if getattr(socket, "_openclaw_feishu_dns_fallback", False):
        return

    original_getaddrinfo = socket.getaddrinfo

    def patched_getaddrinfo(
        host: str | bytes | None,
        port: str | int | None,
        family: int = 0,
        type: int = 0,
        proto: int = 0,
        flags: int = 0,
    ) -> list[Any]:
        hostname = host.decode("utf-8", errors="ignore") if isinstance(host, bytes) else host
        if str(hostname or "").lower() != FEISHU_HOST:
            return original_getaddrinfo(host, port, family, type, proto, flags)

        try:
            return original_getaddrinfo(host, port, family, type, proto, flags)
        except socket.gaierror:
            pass

        if family == socket.AF_INET6:
            raise socket.gaierror(socket.EAI_NONAME, "Name or service not known")

        results: list[Any] = []
        for ip in FALLBACK_IPV4:
            results.extend(original_getaddrinfo(ip, port, socket.AF_INET, type, proto, flags))
        return results

    socket.getaddrinfo = patched_getaddrinfo
    socket._openclaw_feishu_dns_fallback = True

scripts/feishu_api/client.py:5-7:

python
from .dns import install_feishu_dns_fallback

install_feishu_dns_fallback()

The implementation also conflicts with `re ...[truncated 2640 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the socket.getaddrinfo monkey patch and all embedded fallback IP addresses.
  2. Allow DNS failures to propagate as clear, actionable errors.
  3. Direct users to repair operating-system, container, VPN, proxy, or enterprise DNS configuration.
  4. If a fallback is operationally unavoidable:
    • Make it opt-in rather than import-time behavior.
    • Use a configured and authenticated DNS resolver.
    • Validate returned addresses against current provider-owned ranges.
    • Preserve TLS hostname verification.
    • Avoid changing global socket functions.
    • Scope custom resolution to a dedicated HTTP transport.
  5. Add tests verifying that importing feishu_api.client does not alter socket.getaddrinfo.
  6. Keep implementation consistent with the security guidance in references/setup.md.

T08 · Insecure Dependencies

Note
Location
scripts/requirements.txt:1
Finding

Open-ended dependency versions permit unreviewed package upgrades

Content
View full analysis

Vulnerability Details

File Location: scripts/requirements.txt:1-2 and installation guidance in SKILL.md:34-36
Vulnerability Type: Unpinned third-party dependencies and non-reproducible installation
Risk Level: Low

Vulnerable Code

scripts/requirements.txt:1-2:

text
lark-oapi>=1.4.18
python-dotenv>=1.0.1

SKILL.md:34-36:

bash
python -m pip install -r scripts/requirements.txt

Technical Analysis

Both dependencies use open-ended minimum-version constraints. A future installation may therefore retrieve versions that were not reviewed as part of this Skill audit. The requirements file does not include cryptographic hashes, and the installation command uses whichever package index is configured in the environment.

The package names are consistent with the intended Feishu SDK and dotenv library; the audit found no evidence of typosquatting or an intentionally malicious dependency. The risk arises from uncontrolled future releases, compromised package-index infrastructure, dependency takeover, or a malicious index configured through pip settings.

Python packages can execute code during build or installation, and imported package code executes with the privileges of the user running the Skill.

Attack Path

  1. A future release of one of the permitted packages is compromised, or the active pip index serves a malicious package artifact.
  2. The user follows the documented installation command.
  3. Pip resolves the compromised version because it satisfies the open-ended minimum constraint.
  4. Malicious build, installation, or import-time code executes with the user's local privileges.
  5. The compromised dependency can access environment variables, token files, Feishu credentials, and any files available to the process.

Impact Assessment

A compromised dependency can execute arbitrary code with the privileges of the user running pip or invoking the service wrappe ...[truncated 376 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin each direct dependency to an exact reviewed version.
  2. Generate a lock file that includes all transitive dependencies.
  3. Record SHA-256 hashes and install with pip's --require-hashes option.
  4. Use a trusted, explicitly configured package index rather than relying on ambient pip configuration.
  5. Review changelogs and security advisories before updating locked versions.
  6. Test dependency upgrades in an isolated environment before publishing them.
  7. Consider distributing a verified wheel set or using an organization-controlled package mirror for sensitive deployments.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (98)

YARA rule 'info_stealer': Information stealer patterns (credential harvesting, browser data theft) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

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

md
rough bot routing plus direct OpenAPI calls. The package is portable: another user supplies only their app credentials, user OAuth token when needed, account IDs, folder IDs, document tokens, and target content.

## API-Only Rule

All Feishu document and content operations must use OpenAPI through this skill's scripts. Do not use `lark-cli`, Feishu CLI tools, browser automation, or copied browser cookies for Docx, Sheets, Base, Wiki, Drive, or IM operations. OpenClaw CLI is allowed only for OpenClaw routing and channel checks, such as `openclaw agents bind` or `openclaw channels status`.

## Safety Rules

- Never print `.env`, app secrets, user access tokens, refresh tokens, or webhook secrets.
- Before write operations, identify whether the call uses a user token or tenant/app token.
- Treat `expires_in` and `refresh_token_expires_in` returned by Feishu as the source of truth. Do not hard-code token lifetimes.
- `refresh_token` is single-use. After any refresh, immediately persist bot

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 · SKILL.md (reported line 19)May include surrounding context.

md
## Safety Rules

- Never print `.env`, app secrets, user access tokens, refresh tokens, or webhook secrets.
- Before write operations, identify whether the call uses a user token or tenant/app token.
- Treat `expires_in` and `refresh_token_expires_in` returned by Feishu as the source of truth. Do not hard-code token lifetimes.
- `refresh_token` is single-use. After any refresh, immediately persist both the new `FEISHU_USER_ACCESS_TOKEN` and the new `FEISHU_USER_REFRESH_TOKEN`.

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 · SKILL.md (reported line 73)May include surrounding context.

md
## Safety Rules

- Never print `.env`, app secrets, user access tokens, refresh tokens, or webhook secrets.
- Before write operations, identify whether the call uses a user token or tenant/app token.
- Treat `expires_in` and `refresh_token_expires_in` returned by Feishu as the source of truth. Do not hard-code token lifetimes.
- `refresh_token` is single-use. After any refresh, immediately persist both the new `FEISHU_USER_ACCESS_TOKEN` and the new `FEISHU_USER_REFRESH_TOKEN`.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python scripts/feishu_openapi_tool.py env-check --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

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

User OAuth tokens are obtained and refreshed with scripts/feishu_oauth_tool.py:

bash
python scripts/feishu_oauth_tool.py auth-url --env-file .env
python scripts/feishu_oauth_tool.py exchange-code --env-file .env --callback-url "$CALLBACK_URL"
python scripts/feishu_oauth_tool.py refresh --env-file .env

Static analysis

Detected: suspicious.exposed_secret_literal, suspicious.secret_argv_exposure

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
scripts/feishu_api/services/docs.py:87

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
scripts/feishu_openapi_tool.py:261

Instructions pass high-value credentials through process argv.

Critical
Code
suspicious.secret_argv_exposure
Location
references/operations.md:86

Instructions pass high-value credentials through process argv.

Critical
Code
suspicious.secret_argv_exposure
Location
SKILL.md:112