fix(security): remove insecure self-update from cli.sh scripts [DEVA11Y-475]#16
fix(security): remove insecure self-update from cli.sh scripts [DEVA11Y-475]#16sunny-se wants to merge 2 commits into
Conversation
F-003 / DEVA11Y-475 — script_self_update() fetched the script from a mutable branch head with no integrity verification (CWE-494). The ^#! regex check is trivially bypassed. Remove self-update entirely; users should update via git pull or package manager. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Suggestion: Keep self-update with HTTPS + SHA-256 integrity check instead of removing it. Problem with full removalThe Proposed alternativeKeep self-update but harden it:
script_self_update() {
local remote_url="https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/bash/cli.sh"
local checksum_url="${remote_url}.sha256"
local updated_script
updated_script=$(curl -sfSL "$remote_url") || return 0
local expected_hash
expected_hash=$(curl -sfSL "$checksum_url") || return 0
local actual_hash
actual_hash=$(echo "$updated_script" | shasum -a 256 | cut -d' ' -f1)
if [[ "$actual_hash" == "$expected_hash" ]] && [[ $updated_script =~ ^#! ]]; then
echo "$updated_script" > "$SCRIPT_PATH"
fi
}This requires publishing Why this is sufficient
ActionShip Same approach should apply to PR #18 (DEVA11Y-478 — |
Instead of removing script_self_update() entirely, restore it with hardening: HTTPS-only fetch (pairs with PR #13) + SHA-256 checksum verification against a .sha256 sidecar file. Silently skips update if checksum fetch fails or hash mismatch — never overwrites with unverified content. Requires publishing .sha256 sidecar files alongside each script. DEVA11Y-475 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
script_self_update()function and its invocation from all 3 CLI scriptsWhy:
script_self_update()fetched the script from a mutable branch head (refs/heads/main) via curl with no integrity verification (CWE-494). The only guard was a^#!regex — trivially bypassed by any attacker who controls the response. This ran unconditionally before any subcommand, making it a silent supply-chain vector.Users should update scripts via
git pullor their package manager.Verification
Jira
DEVA11Y-475 — F-003
🤖 Generated with Claude Code