Conversation
gokay-ai
marked this pull request as ready for review
September 14, 2026 11:48
RunningLeon
reviewed
Sep 16, 2026
RunningLeon
reviewed
Sep 16, 2026
POST /update_weights deserialized request-controlled pickle data before validation, which is unauthenticated RCE on the default api_server bind. Reject pickle over HTTP, accept safetensors or structured tensors, and gate engine pickle loads behind LMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS=1. HTTP pickle rejection is covered even when the engine opt-in env var is set, including that reconstruction callbacks and pickle.loads are never invoked. Fixes InternLM#4698 Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/fix-update-weights-pickle-1fc2
branch
from
September 16, 2026 10:25
289c8e5 to
a994860
Compare
Clone CPU tensors that share storage so Qwen3 tied embed/LM-head weights can be saved with serialize_named_tensors_safetensors. Honor LMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS=1 on HTTP /update_weights so XTuner FlattenedTensorBucket CUDA IPC (metadata-only reuse and empty finished=true) works. Default still rejects pickle for untrusted clients. The HTTP handler still does not pickle.loads. Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com> Co-authored-by: GokayAI <gokay-ai@users.noreply.github.com>
Author
|
Addressed both review threads:
|
RunningLeon
reviewed
Sep 17, 2026
Register LMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS in pytorch.envs so get_all_envs() copies it onto Ray workers. Default remains deny. Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com>
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.
Motivation
POST /update_weightsdeserialized request-controlled pickle (ForkingPickler.loads) before any tensor validation. On the defaultapi_serverbind (0.0.0.0, noapi_keys), that is unauthenticated RCE.Fixes #4698
Modification
/update_weightsrejects pickle by default.LMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS=1restores trusted same-node XTuner CUDA IPC (FlattenedTensorBucket, metadata-only reuse, emptyfinished=true). The HTTP handler still does not callpickle.loads.load_format="safetensors"or a structured dict of tensors ({dtype, shape, data}).serialize_named_tensors_safetensorsclones overlapping CPU storage so Qwen3 tied embed / LM-head weights can be saved.lmdeploy.pytorch.envsso Rayget_all_envs()forwards it to workers. Default remains deny.BC-breaking
Clients that POST pickle from
serialize_state_dictto/update_weightsget HTTP 400 unless the server setsLMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS=1. Untrusted clients should switch toserialize_named_tensors_safetensorswithload_format='safetensors', or use/update_weights_from_distributed//update_weights_from_ipc.Checklist
docs/en/advance/update_weights.mdanddocs/zh_cn/advance/update_weights.mdupdated.