T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/jira_reader.sh:5
- Finding
- Working-Directory-Dependent Sourcing Allows Arbitrary Code Execution in Jira Reader<![CDATA[ ## Vulnerability Details **File Location**: `scripts/jira_reader.sh`, lines 5-7 **Vulnerability Type**: Unsafe shell script sourcing **Risk Level**: High ### Vulnerable Code ```bash # Source authentication if [[ -f "../scripts/auth.sh" ]]; then source ../scripts/auth.sh fi ``` ### Technical Analysis The relative path `../scripts/auth.sh` is resolved from the caller's current working directory, not from the directory containing `jira_reader.sh`. An attacker who can create a file at that relative location can cause the script to source and execute attacker-controlled shell commands. Because `source` executes the target file in the current shell context, malicious code inherits the invoking user's privileges and can access the user's environment, including exported API tokens. The sourcing operation also occurs before argument validation. The documented project-root invocation does not reliably load the packaged authentication script because `../scripts/auth.sh` points outside the project when the current working directory is the project root. ### Attack Path 1. An attacker identifies or influences the directory from which the victim will invoke `jira_reader.sh`. 2. The attacker creates a malicious `../scripts/auth.sh` relative to that working directory. 3. The victim invokes the Jira reader using an absolute or relative path. 4. The script confirms that the attacker-controlled file exists and sources it. 5. The malicious commands execute with the victim's operating-system privileges and can read exported credentials or modify files accessible to the victim. ### Impact Assessment Successful exploitation provides arbitrary shell command execution with the privileges of the user running the reader. The attacker may access exported Jira and Confluence tokens, read or modify user-accessible files, invoke network tools, and perform any other action permitted to that user. This issue does not independently elevate privileges beyond those of the inv ...[truncated 156 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Resolve `auth.sh` relative to the executing script rather than the current working directory: ```bash set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" AUTH_FILE="$SCRIPT_DIR/auth.sh" if [[ ! -f "$AUTH_FILE" ]]; then printf 'Error: authentication script not found.\n' >&2 exit 1 fi source "$AUTH_FILE" ``` Additionally: - Ensure the installation directory and `auth.sh` are owned by a trusted account and are not writable by untrusted users. - Fail closed when the expected authentication script is missing. - Validate arguments before performing operations that are not required for argument handling. - Consider eliminating executable configuration sourcing entirely; use a non-executable configuration format if only data must be loaded. ]]>
