Skip to content

fix(security): reject pickled update_weights payloads by default#4765

Open
Solaris-star wants to merge 1 commit into
InternLM:mainfrom
Solaris-star:fix/4698-safe-update-weights
Open

fix(security): reject pickled update_weights payloads by default#4765
Solaris-star wants to merge 1 commit into
InternLM:mainfrom
Solaris-star:fix/4698-safe-update-weights

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

POST /update_weights accepted serialized_named_tensors as a base64 pickle string and deserialized it with ForkingPickler.loads (native pickle) before any tensor validation. With the default unauthenticated api_server bound to 0.0.0.0, this is unauthenticated RCE.

Changes

  1. HTTP gate (api_server.py): reject str / list[str] pickle payloads with HTTP 400; only structured dict/list tensors are accepted over the public endpoint.
  2. Engine gates (TurboMind + PyTorch agent): pickle loads require LMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS=1 so trusted local IPC can still opt in; default is deny.

Testing

  • Static review of call sites
  • Full suite not run here (GPU/engine env); CI should cover

Fixes #4698

POST /update_weights previously accepted base64 pickle in
serialized_named_tensors and deserialized it with ForkingPickler.loads
before validation. On an unauthenticated api_server this is remote code
execution.

Reject string/list-of-string pickle payloads on the HTTP endpoint, and
gate remaining engine-side pickle loads behind
LMDEPLOY_ALLOW_PICKLE_UPDATE_PARAMS=1 for trusted local IPC only.

Fixes InternLM#4698

Signed-off-by: Solaris-star <820622658@qq.com>
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.

[Bug] /update_weights deserializes request-controlled pickle data before validation

1 participant