높음취약점
onnx Vulnerable to Path Traversal via Symlink
GHSA-3r9x-f23j-gc73 · CVE-2026-27489 · PYSEC-2026-2239 · 갱신 2026. 7. 13.
영향 받는 패키지
| 생태계 | 패키지 | 수정 버전 |
|---|---|---|
| PyPI | onnx | 1.21.0 |
GHSA-3r9x-f23j-gc73 · CVE-2026-27489 · PYSEC-2026-2239 · 갱신 2026. 7. 13.
| 생태계 | 패키지 | 수정 버전 |
|---|---|---|
| PyPI | onnx | 1.21.0 |
model.dataln -s /etc/passwd model.dataimport onnx
from onnx.external_data_helper import load_external_data_for_model
def load_onnx_model_basic(model_path="model.onnx"):
model = onnx.load(model_path)
return model
def load_onnx_model_explicit(model_path="model.onnx"):
model = onnx.load(model_path, load_external_data=False)
load_external_data_for_model(model, ".")
return model
if __name__ == "__main__":
model = load_onnx_model_basic("model.onnx")
A common misuse case for successful exploitation is that an adversary can provide victim with a compressed file, containing poc.onnx and poc.data (symlink). Once the victim uncompress and load the model, symlink read the adversary selected arbitrary file.
Read sensitive and arbitrary files and environment variable (e.g. /proc/1/environ) from the host that loads the model.
NOTE: this issue is not limited to UNIX.
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
int open_external_file_no_symlink(const char *base_dir,
const char *relative_path) {
int dirfd = -1;
int fd = -1;
struct stat st;
// Open base directory
dirfd = open(base_dir, O_RDONLY | O_DIRECTORY);
if (dirfd < 0) {
return -1;
}
// Open the target relative to base_dir
// O_NOFOLLOW => fail if final path component is a symlink
fd = openat(dirfd,
relative_path,
O_RDONLY | O_NOFOLLOW);
close(dirfd);
if (fd < 0) {
// ELOOP is the typical error if a symlink is encountered
return -1;
}
// Inspect the *opened file*
if (fstat(fd, &st) != 0) {
close(fd);
return -1;
}
// Enforce "regular file only"
if (!S_ISREG(st.st_mode)) {
close(fd);
errno = EINVAL;
return -1;
}
// fd is now:
// - not a symlink
// - not a directory
// - not a device / FIFO / socket
// - race-safe
return fd;
}