T03 · Remote Payload Retrieval and Execution
- Location
scripts/hg-to-git.sh:56- Finding
Unpinned Remote Dependency Is Downloaded and Executed
- Content
View full analysis
/dev/null && ! command -v hg-fast-export.sh &> /dev/null; then FAST_EXPORT_DIR="${HOME}/.local/share/hg-fast-export" if [ ! -d "$FAST_EXPORT_DIR" ]; then mkdir -p "$(dirname "$FAST_EXPORT_DIR")" git clone https://github.com/frej/fast-export.git "$FAST_EXPORT_DIR" fi export PATH="$FAST_EXPORT_DIR:$PATH" fi # Determine fast-export command if command -v hg-fast-export &> /dev/null; then FAST_EXPORT_CMD="hg-fast-export" elif command -v hg-fast-export.sh &> /dev/null; then FAST_EXPORT_CMD="hg-fast-export.sh" elif [ -f "${HOME}/.local/share/hg-fast-export/hg-fast-export.sh" ]; then FAST_EXPORT_CMD="${HOME}/.local/share/hg-fast-export/hg-fast-export.sh" ``` ```bash # Perform conversion echo "" echo "Converting... (this may take a while for large repos)" "$FAST_EXPORT_CMD" -r "$HG_REPO" --force ``` ### Technical Analysis When `hg-fast-export` is unavailable, the script clones the current contents of an external GitHub repository and subsequently executes `hg-fast-export.sh`. The clone is not pinned to a reviewed commit or immutable release, and no checksum or cryptographic signature is verified. Consequently, the code executed during conversion can differ from the code that existed when this Skill was audited. Compromise of the upstream repository, its default branch, its maintainers, or the network trust chain could cause attacker-controlled code to be placed in the installation directory and executed. The script also trusts an existing `${HOME}/.local/share/hg-fast-export` directory without validating its ownership, contents, or integrity. An attacker who can prepopulate that location may be able to influence the executa ...[truncated 1207 chars]- Remediation
View remediation
