T09 · Insecure Skill Coding Practices
- Location
scripts/make_install_sh.sh:19- Finding
Insufficient Package Publisher Verification Before Privileged Installation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/make_install_sh.sh, lines 19–25 and 31–33
Vulnerability Type: Insufficient package-signature validation
Risk Level: MediumVulnerable Code
bash echo "==> 校验 Apple 官方签名..." for p in "$MAIN_PKG" ${SDK_PKGS[*]}; do [ -f "\$DIR/\$p" ] && pkgutil --check-signature "\$DIR/\$p" | grep -q "signed" || { echo "签名校验失败: \$p"; exit 1; } done echo "==> 安装主包 (需要输入开机密码)..." sudo installer -pkg "\$DIR/$MAIN_PKG" -target / echo "==> 安装 SDK 支持包..."The generated script subsequently installs the optional SDK packages:
bash for p in "${SDK_PKGS[@]}"; do [ -f "$PKG_DIR/$p" ] && echo "sudo installer -pkg \"\$DIR/$p\" -target / || echo \"跳过 \$p\"" >> "$OUT" doneTechnical Analysis
The generated installation script checks whether
pkgutil --check-signatureoutput contains the generic substringsigned. It does not verify that the package was signed by Apple, validate the expected Apple certificate chain, or bind each fixed package name to trusted catalog metadata.Consequently, a substituted package signed by an unrelated but valid signing identity may satisfy the check. The script then supplies that package to macOS
installerundersudo, allowing package installation scripts and payload actions to run with elevated privileges.The documentation and generated status message characterize this as verification of an official Apple signature, but the implemented test establishes only a weaker property: that the output includes the word
signed.Attack Path
- The legitimate packages are placed in the user-writable download directory, normally
~/Downloads/clt-install. - An attacker who can modify that directory replaces one of the expected fixed-name package files with a malicious package carrying some otherwise valid signature.
- The user launches the generated
install-clt.shscript. pkgutil --check-signatureemits ...[truncated 1032 chars]
- The legitimate packages are placed in the user-writable download directory, normally
- Remediation
View remediation
Remediation Suggestions
- Replace the generic substring check with strict validation of the expected Apple signing chain. Capture the complete
pkgutil --check-signatureoutput and require the precise Apple package-signing identity and certificate authorities expected for CLT packages. - Fail closed if signature output is missing, malformed, ambiguous, expired, revoked, or associated with any non-Apple identity.
- Verify each downloaded package against trusted digest metadata from the authenticated Apple software catalog where such metadata is available.
- Allow only an explicit list of expected package filenames and reject symbolic links, unexpected file types, duplicate packages, or additional package files.
- Store downloads in a newly created directory with restrictive permissions and verify directory ownership and permissions before elevating privileges.
- Revalidate every package immediately before its corresponding
sudo installerinvocation to reduce the time-of-check/time-of-use window. - Abort the entire installation if any required package fails validation. Do not continue after an SDK package installation or validation error unless that package is explicitly documented and securely handled as optional.
- Replace the generic substring check with strict validation of the expected Apple signing chain. Capture the complete
