Repository navigation
Conversation
…g.json The fix for CVE-2026-4372 blocks _attn_implementation_internal from being set via config.json. However, the public field attn_implementation is processed by kwargs.pop() before the exclusion check and triggers a property setter that writes directly to _attn_implementation_internal, bypassing the fix. This patch validates that attn_implementation values loaded from config do not contain '/' (Hub repo pattern). Standard values (eager, sdpa, flash_attention_2, etc.) are unaffected. Users can still set kernel implementations explicitly via from_pretrained(attn_implementation=...).
Contributor
|
CI Dashboard: View test results in Grafana |
Collaborator
|
Hey 👋 I'm closing this as this won't be a problem anymore with #46039, it will be rejected downstream by the kernels library then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject Hub kernel repository patterns (containing
/) in theattn_implementationfield when loaded fromconfig.json. This prevents a malicious model config from silently triggering remote kernel code download and execution duringfrom_pretrained()withouttrust_remote_code=True.Problem
When a model's
config.jsoncontains"attn_implementation": "some-org/some-repo", the value is processed bykwargs.pop()at line 299 ofconfiguration_utils.pyand passed through the_attn_implementationproperty setter, which writes it to_attn_implementation_internal. During model initialization,is_kernel()matches the Hub repo pattern, andget_kernel()is called to download and execute kernel code — all without requiringtrust_remote_code=True.An attacker can exploit this by publishing a model with a crafted
config.jsonto achieve remote code execution on any user who loads the model.Fix
Validate that
attn_implementationvalues loaded from config do not contain/(the Hub repo pattern). This blocks kernel-style repo IDs from being injected via config while preserving all standard values (eager,sdpa,flash_attention_2,flash_attention_3).Users can still set kernel implementations explicitly via
from_pretrained(attn_implementation=...)as that code path inmodeling_utils.pyruns after config loading and is a deliberate user choice.Test plan
attn_implementationvalues unaffected)config.jsonwith"attn_implementation": "some-org/some-kernel"is rejected with warningfrom_pretrained(attn_implementation="kernels-community/flash-attn")still works (user-explicit)