T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:32
- Finding
- Executable Workspace Configuration Enables Arbitrary Shell Command Execution<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 32-35 **Vulnerability Type**: Executable configuration file / arbitrary command execution **Risk Level**: High ### Vulnerable Code ```bash CONFIG_FILE="${OPENCLAW_WORKSPACE}/.bijian_config" [ -f "$CONFIG_FILE" ] || CONFIG_FILE="$HOME/.openclaw/workspace/.bijian_config" [ -f "$CONFIG_FILE" ] && source "$CONFIG_FILE" && echo "✅ 配置已加载" || echo "❌ 请创建 .bijian_config" ``` The same configuration file is sourced before the documented API operations: ```bash source "$CONFIG_FILE" && python3 scripts/bijian_api.py spaces ``` ```bash source "$CONFIG_FILE" && python3 scripts/bijian_api.py generate \ --space-id ${SPACE_ID} \ --topic-theme "${TOPIC_THEME}" \ --viewpoints "${VIEWPOINTS}" \ --reference-content "${REFERENCE_CONTENT}" \ --user-require "${USER_REQUIRE}" \ --is-need-picture false ``` ### Technical Analysis The workflow uses the shell `source` command to load `.bijian_config`. Unlike a data-only configuration parser, `source` interprets the entire file as shell code. The documented sample contains only environment-variable declarations, but no validation restricts the file to those declarations. The preferred file is taken directly from the workspace identified by `OPENCLAW_WORKSPACE`. A malicious or compromised project, archive, shared workspace, or prior process could therefore place commands in `.bijian_config`. When the Agent follows the documented workflow, those commands execute before the Python API client. For example, a malicious configuration could combine apparently valid settings with arbitrary commands: ```bash export BIJIAN_API_TOKEN='token' export BIJIAN_BASE_URL='https://bj.aizmjx.com/api' arbitrary_attacker_command ``` This is an unsafe configuration-loading pattern even though the audited project does not itself contain a malicious `.bijian_config`. ### Attack Path 1. An attacker gains the ability to supply or modify `<workspace>/.bijian_config`, such a ...[truncated 1263 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not execute configuration files with `source`, `.`, `eval`, or an equivalent shell mechanism. 2. Store configuration in a data-only format such as JSON, TOML, or a strictly parsed dotenv file. 3. Parse only an explicit allowlist of fields: - `BIJIAN_API_TOKEN` - `BIJIAN_TOKEN_HEADER` - `BIJIAN_TOKEN_PREFIX` - `BIJIAN_BASE_URL` - `BIJIAN_USER_ID` 4. Reject command substitutions, shell metacharacters, multiline values, unexpected keys, and malformed quoting. 5. Prefer reading configuration directly in `bijian_api.py` instead of passing it through a shell. 6. Require the configuration file to have restrictive permissions, such as mode `0600`, and verify that it is owned by the expected user. 7. Prefer a trusted user configuration directory over a project-controlled workspace. If workspace configuration must be supported, require explicit user approval before loading it. 8. Document that configuration files must be treated as sensitive data and must never be committed to source control. ]]>
