Skip to content

fix(security): do not enable trust_remote_code from basename registry#1587

Open
Solaris-star wants to merge 1 commit into
FlagOpen:masterfrom
Solaris-star:fix/1579-trust-remote-code-default-false
Open

fix(security): do not enable trust_remote_code from basename registry#1587
Solaris-star wants to merge 1 commit into
FlagOpen:masterfrom
Solaris-star:fix/1579-trust-remote-code-default-false

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

FlagAutoModel.from_finetuned resolved embedder config via os.path.basename(model_name_or_path) and, when trust_remote_code was omitted, copied model_config.trust_remote_code from the registry. Entries with trust_remote_code=True therefore enabled custom code for any path/repo whose basename collided with a trusted registry name — without an explicit user opt-in (#1579).

Change

  • When trust_remote_code is None, always default to False
  • If the registry entry would have preferred True, log a warning telling callers to pass trust_remote_code=True explicitly
  • Explicit trust_remote_code=True/False from the caller is unchanged

Test plan

  • tests/test_auto_embedder_trust_remote_code.py (2 passed)

Fixes #1579

from_finetuned used os.path.basename to look up AUTO_EMBEDDER_MAPPING and
copied model_config.trust_remote_code when the caller omitted the flag.
A colliding local path or Hub repo name could silently execute remote
code. Default to False; require an explicit trust_remote_code=True.

Fixes FlagOpen#1579
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.

Silent trust_remote_code=True enable in FlagAutoModel.from_finetuned via basename-only registry lookup

1 participant