Skip to content

fix(config): stop model bundles from choosing runner and remote-code trust - #1576

Open
wanjiang263 wants to merge 1 commit into
ModelTC:mainfrom
wanjiang263:fix-legacy-trust-remote-code-sites
Open

wanjiang263 wants to merge 1 commit into
ModelTC:mainfrom
wanjiang263:fix-legacy-trust-remote-code-sites

Conversation

@wanjiang263

Copy link
Copy Markdown

Summary

Related to #1559.

load_model_config merged every config.json sidecar and safetensors
__metadata__ field found inside the model directory straight into the startup
config. A model bundle is untrusted input, so it could:

  • replace the caller-selected runner (model_cls) — for example LTX-2.5 metadata
    forcing cosmos3, redirecting the load into the cosmos3 runner;
  • set trust_remote_code, re-enabling bundle-supplied code even when the caller
    disabled it.

This routes every model-bundle-derived merge through
update_from_model_bundle_config, which drops the keys that decide which code
LightX2V imports and which runner executes. Ordinary architecture fields still
merge unchanged, so benign bundles are unaffected.

Caller-supplied configs (config_data and --config_json) are deliberately left
untouched — those are the caller's own input, not the model's.

Relationship to #1571

#1571 defaults the cosmos3 tokenizer's trust_remote_code to False via
self.config.get("trust_remote_code", False). That default is bypassable until
this change lands: the cosmos3 branch merges {model_path}/transformer/config.json
into the same config, so a bundle can set trust_remote_code: true there and be
picked up by that .get().

This PR does not touch cosmos3 and does not overlap with #1571 — it hardens the
config trust boundary that #1571 relies on.

Test plan

  • pre-commit run --all-files — all hooks pass
  • pytest tests/test_set_config_model_bundle_trust.py — 4 passed

…trust

`load_model_config` merged every `config.json` sidecar and safetensors
`__metadata__` field found inside the model directory straight into the
startup config. A model bundle is untrusted input: a bundle could replace the
caller-selected runner (`model_cls`) -- for example LTX-2.5 metadata forcing
`cosmos3` -- or set `trust_remote_code`, re-enabling bundle-supplied code even
when the loader honours the config flag.

Route every model-bundle-derived merge through
`update_from_model_bundle_config`, which drops the keys that decide which code
LightX2V imports or which runner executes. Ordinary architecture fields still
merge unchanged, so benign bundles are unaffected.

Caller-supplied configs (`config_data` and `--config_json`) are deliberately
left untouched: those are the caller's own input rather than the model's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant