CVE-2021-32803 Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning
디렉토리 캐시 중독으로 인한 심볼릭 링크 보호가 불충분하여 임의의 파일 생성/복사
설명
The npm package "tar" (aka node-tar) before versions 6.1.2, 5.0.7, 4.4.15, and 3.2.3 has an arbitrary File Creation/Overwrite vulnerability via insufficient symlink protection. `node-tar` aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary `stat` calls to determine whether a given path is a directory, paths are cached when directories are created. This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory. This order of operations resulted in the directory being created and added to the `node-tar` directory cache. When a directory is present in the directory cache, subsequent calls to mkdir for that directory are skipped. However, this is also where `node-tar` checks for symlinks occur. By first creating a directory, and then replacing that directory with a symlink, it was thus possible to bypass `node-tar` symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite. This issue was addressed in releases 3.2.3, 4.4.15, 5.0.7 and 6.1.2.
버전 6.1.2, 5.0.7, 4.4.15, 3.2.3 이전의 npm 패키지 "tar"(일명 node-tar)는 심볼릭 링크로 수정되는 모든 파일이 추출되지 않도록 하는 것을 목표로 한다. 이것은 부분적으로 추출된 디렉토리가 심볼릭 링크가 아님을 보장함으로써 달성된다. 또한, 주어진 경로가 디렉토리인지를 결정하기 위해 불필요한 `stat` 호출을 방지하기 위해, 디렉토리가 생성될 때 경로가 캐시된다. 이 논리는 디렉터리와 같은 이름의 심볼릭 링크를 포함하는 tar 파일을 추출할 때 불충분했습니다. 이 작업 순서는 디렉토리를 만들고 `node-tar` 디렉토리 캐시에 추가되는 결과를 초래했습니다. 디렉토리가 디렉토리 캐쉬에 있을 때, 그 디렉토리를 위한 mkdir에 연속적인 외침은 건너뛴다. 그러나, 이것은 또한 `node-tar`가 심볼릭링크를 검사하는 곳이기도 하다. 디렉토리를 먼저 생성하고 그 디렉토리를 심볼릭 링크로 대체함으로써, 디렉토리에 대한 `node-tar` 심볼릭 링크 검사를 우회할 수 있었고, 본질적으로 신뢰할 수 없는 타르 파일이 임의의 위치에 심볼릭 링크를 허용하고 그 위치에 임의의 파일을 추출하여 임의의 파일 생성과 덮어쓰기를 허용했다. 이 문제는 릴리스 3.2.3, 4.4.15, 5.0.7 및 6.1.2에서 해결되었습니다.
영향 받는 제품 제품 1개
-
해결 버전 있음
npm
node-tar
영향 받는 버전
- 3.2.3 미만
- 4.0.0 이상 4.4.15 미만
- 5.0.0 이상 5.0.7 미만
- 6.0.0 이상 6.1.2 미만
해결 버전
- 3.2.3 이상
- 4.4.15 이상
- 5.0.7 이상
- 6.1.2 이상
참고 자료 6건
- cert-portal.siemens.com https://cert-portal.siemens.com/productcert/pdf/ssa-389290.pdf (새 창)
- github.com https://github.com/npm/node-tar/commit/9dbdeb6df8e9dbd96fa9e84341b9d74734be6c20 (새 창)
- github.com https://github.com/npm/node-tar/security/advisories/GHSA-r628-mhmh-qjhw (새 창)
- npmjs.com https://www.npmjs.com/advisories/1771 (새 창)
- npmjs.com https://www.npmjs.com/package/tar (새 창)
- oracle.com https://www.oracle.com/security-alerts/cpuoct2021.html (새 창)