Xinference загружает модели с безусловно включенным удаленным выполнением кода Hugging Face, и до версии 2.12.0 не предоставляет никаких настроек для его отключения. Шесть сайтов вызовов загрузчика передают доверие_remote_code=True как буквальное значение или как безусловное значение по умолчанию: RerankModel._get_tokenizer в xinference/model/rerank/core.py, SentenceTransformerRerankModel.load в xinference/model/rerank/sentence_transformers/core.py, SentenceTransformerEmbeddingModel.load в xinference/model/embedding/sentence_transformers/core.py, FlagEmbeddingModel.load в xinference/model/embedding/flag/core.py и двух сайтах в xinference/model/llm/transformers/core.py, где PytorchModel._sanitize_model_config и PytorchModel._get_comComponents по умолчанию имеют значение True. Поскольку вызывающая сторона с доступом к запуску модели может зарегистрировать модель, тип которой неизвестен, и предоставить произвольный путь к модели, сервер достигает _auto_detect_type, а затем AutoTokenizer.from_pretrained, который импортирует и выполняет Python, объявленный собственным tokenizer_config.json auto_map каталога модели, запуская предоставленный злоумышленником код с привилегиями рабочего процесса.
Версия 2.12.0 защищает каждый сайт с помощью параметраallow_trust_remote_code и XINFERENCE_TRUST_REMOTE_CODE, разрешая удаленный код только для встроенных моделей в комплекте.
Показать оригинальное описание (EN)
Xinference loads models with Hugging Face remote code execution unconditionally enabled, and before version 2.12.0 exposes no setting to disable it. Six loader call sites pass trust_remote_code=True as a literal or as an unconditional default: RerankModel._get_tokenizer in xinference/model/rerank/core.py, SentenceTransformerRerankModel.load in xinference/model/rerank/sentence_transformers/core.py, SentenceTransformerEmbeddingModel.load in xinference/model/embedding/sentence_transformers/core.py, FlagEmbeddingModel.load in xinference/model/embedding/flag/core.py, and two sites in xinference/model/llm/transformers/core.py where PytorchModel._sanitize_model_config and PytorchModel._get_components default the value to True. Because a caller with model launch access can register a model whose type is unknown and supply an arbitrary model path, the server reaches _auto_detect_type and then AutoTokenizer.from_pretrained, which imports and executes Python declared by the model directory's own tokenizer_config.json auto_map, running attacker-supplied code with the privileges of the worker process. Version 2.12.0 gates every site behind allow_trust_remote_code and the XINFERENCE_TRUST_REMOTE_CODE setting, permitting remote code only for bundled built-in models.
Характеристики атаки
Последствия
Строка CVSS v4.0