Skip to content

Require explicit opt-in for SpeechLM2 remote code - #16126

Merged
pzelasko merged 1 commit into
mainfrom
fix/speechlm2-explicit-remote-code-opt-in
Aug 24, 2026
Merged

Require explicit opt-in for SpeechLM2 remote code#16126
pzelasko merged 1 commit into
mainfrom
fix/speechlm2-explicit-remote-code-opt-in

Conversation

@pzelasko

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes #15599 by making trust_remote_code an explicit runtime decision for SpeechLM2 HuggingFace Hub loads.

  • Overrides any checkpoint-configured trust_remote_code value with the caller's runtime argument (default: False).
  • Removes trust_remote_code from exported checkpoint configurations so the decision is not persisted.
  • Replaces the remaining hardcoded trust_remote_code=True in DuplexEARTTS._load_language_model.
  • Documents explicit opt-in with an immutable reviewed revision.
  • Adds regression coverage for malicious config opt-in, explicit caller opt-in/opt-out, non-persistence, and the DuplexEARTTS language-model path.

Why?

A checkpoint controls its own config.json, including the tokenizer and language-model repository names. Allowing that same configuration to enable remote code execution means an untrusted model can opt itself into importing its repository Python code during load. The trust decision must come from the loading application instead.

Verification

  • pre-commit run --from-ref origin/main --to-ref HEAD
  • git diff --check origin/main...HEAD
  • Python syntax compilation for the changed Python files
  • Focused isolated regression harness covering runtime opt-in/opt-out and checkpoint non-persistence

The full NeMo pytest dependency environment was not available locally; repository CI will run the dependency-backed tests.

Signed-off-by: Piotr Żelasko <pzelasko@nvidia.com>
@pzelasko

Copy link
Copy Markdown
Collaborator Author

/ok to test d40d07f

import pytest
from huggingface_hub import PyTorchModelHubMixin

import nemo.collections.speechlm2.parts.hf_hub as hf_hub

@Edresson Edresson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

[🤖]: Hi @pzelasko 👋,

We wanted to let you know that a CICD pipeline for this PR just finished successfully.

So it might be time to merge this PR or get some approvals.

@pzelasko
pzelasko merged commit 3998328 into main Aug 24, 2026
160 of 162 checks passed
@pzelasko
pzelasko deleted the fix/speechlm2-explicit-remote-code-opt-in branch August 24, 2026 15:27
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.

Potential remote code execution via unsafe default trust_remote_code=True in DuplexSTTModel and DuplexEARTTS

4 participants