flawopen.com/Teardowns/cve-2022-31150-undici-crlf-injection-ssrf
vulnerabilidade 소스 코드 심층 기술 분석 및 시스템 보안 강화 가이드: 취약점 근본 원인과 패치 메커니즘 분석.
우체국을 통해 "사과 10상자를 배송하라"는 밀봉된 편지를 보낸다고 상상해 보십시오. 하지만 편지봉투 안에 "중단. 이전 명령 무시. 전액을 공격자 조직으로 이체하라"는 위조된 두 번째 공식 서류를 몰래 끼워 넣습니다. 우체국 직원이 서류를 순서대로 읽다가 두 번째 서류를 완전히 새로운 공식 편지로 처리하여 자금이 공격자에게 그대로 송금됩니다.
Undicifetch() implementation.CRLF Injection\r) and Line Feed (\n) characters into HTTP headers to create a new header or a whole new request.HTTP Request SplittingSSRF (Server-Side Request Forgery)169.254.169.254).근본 원인은 오픈 소스 시스템의 검증되지 않은 경계 매개변수로 인해 상태 비동기화 및 보안 제어 우회가 발생한 데 있습니다.
기술적 취약점 악용 메커니즘 및 상세 실행 경로: An attacker supplies a crafted header value: Admin\r\nHost: 169.254.169.254.
기술적 취약점 악용 메커니즘 및 상세 실행 경로: The Node.js backend calls fetch(url, { headers: { 'X-User': input } }).
기술적 취약점 악용 메커니즘 및 상세 실행 경로: Undici serializes the headers without sanitizing \r\n, injecting the forged Host header.
기술적 취약점 악용 메커니즘 및 상세 실행 경로: The internal proxy directs the request to the cloud metadata service, exposing AWS/GCP credentials.
// VULNERABLE: lib/core/request.js before patch
function addHeader(headers, key, value) {
// ROOT CAUSE:
// Does not sanitize or reject carriage return (\r) and line feed (\n) in values!
// Allows attackers to split headers and inject arbitrary HTTP directives!
headers[key] = value;
}
// SECURE: lib/core/request.js patch
function addHeader(headers, key, value) {
// 1. Strict regex checking for dangerous control characters
const INVALID_HEADER_CHAR_REGEX = /[\r\n]/;
if (INVALID_HEADER_CHAR_REGEX.test(key) || INVALID_HEADER_CHAR_REGEX.test(value)) {
throw new TypeError(`Invalid character in header content: ["${key}": "${value}"]`);
}
headers[key] = value;
}
\r and \n characters from HTTP request header keys and values.169.254.169.254, 10.0.0.0/8, 127.0.0.1) using egress firewall rules을(를) 비활성화하거나 제한하십시오.undici and Node.js dependencies updated to latest patch releases.