🇰🇷 한글 설명
Node.js의 cookies 라이브러리 0.9.2 미만 버전에서 domain 및 path 옵션에 세미콜론(;)이 포함될 수 있는 취약점이 발견되었습니다. 공격자가 신뢰할 수 없는 데이터를 해당 옵션에 주입할 경우, Set-Cookie 헤더에 추가 속성을 삽입하여 SameSite, Secure, HttpOnly 등의 보안 설정을 무력화할 수 있습니다.
💡 쉬운 설명
쿠키를 설정할 때 사용하는 이름이나 경로에 악의적인 명령어를 몰래 끼워 넣을 수 있는 문제입니다. 이를 통해 웹사이트의 중요한 보안 설정(쿠키 보호 기능 등)을 강제로 해제할 수 있습니다.
🇺🇸 원문 (English)
cookies is a Node.js library for reading and writing HTTP cookies, used by Koa via ctx.cookies. In versions before 0.9.2 the library validates the cookie name and value against character sets that reject the semicolon separator, but the domain and path options are checked only against a permissive RFC 7230 field-content matcher that allows semicolons, and both are written into the Set-Cookie header unescaped. An application that passes untrusted or request-derived data into the domain or path option can therefore inject additional cookie attributes, overriding SameSite, Secure, HttpOnly, or Domain on the cookies the application issues. This is a Set-Cookie attribute injection issue (CWE-74). The issue is fixed in cookies 0.9.2, which validates domain and path against RFC 6265 character sets. As a workaround, keep domain and path application-set rather than derived from untrusted input.
📍 영향받는 시스템
cookies library versions < 0.9.2
⚔️ 공격 벡터
사용자 입력값이 쿠키의 domain 또는 path 옵션에 직접 전달될 때 세미콜론을 이용한 속성 주입
🛡️ 대응 방법
cookies 라이브러리를 0.9.2 이상 버전으로 업데이트하거나, domain/path 값을 사용자 입력값이 아닌 고정된 값으로 설정
🔧 검증 코드
출력된 결과에서 cookies의 버전이 0.9.2 미만인지 확인합니다.
npm list cookies | grep cookies