Restrict worker result deserialization - #6444
Conversation
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
|
| Filename | Overview |
|---|---|
| dali/python/nvidia/dali/_multiproc/messages.py | Normalizes arbitrary worker exceptions to RuntimeError and StopIteration, fully addressing the previously reported subclass behavior. |
| dali/python/nvidia/dali/_multiproc/shared_batch.py | Introduces an allowlisted worker-result unpickler while retaining generic deserialization for trusted parent-originated tasks. |
| dali/test/python/test_external_source_parallel_shared_batch.py | Tests rejection of unsafe globals and verifies that StopIteration subclasses retain termination semantics after serialization. |
Sequence Diagram
sequenceDiagram
participant Parent
participant Queue as Shared-memory queue
participant Worker
Parent->>Queue: "Task descriptor (worker_id = -1)"
Queue->>Worker: Trusted task payload
Worker->>Queue: CompletedTask and batch metadata
Queue->>Parent: Worker result descriptor
Parent->>Parent: Restricted protocol deserialization
Reviews (3): Last reviewed commit: "Preserve worker StopIteration semantics" | Re-trigger Greptile
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
|
!build |
1 similar comment
|
!build |
|
CI MESSAGE: [61556838]: BUILD STARTED |
|
CI MESSAGE: [61556838]: BUILD PASSED |
| # Messages written by the parent may contain user-provided batch arguments and are trusted | ||
| # parent-to-child input. Worker-to-parent messages have a fixed protocol and are restricted. | ||
| if shm_message.worker_id >= 0: | ||
| return restricted_pickle_loads(buffer) |
There was a problem hiding this comment.
Why trust the parent but not the children? Is it because it's really impractical (or impossible) to add validation for the types passed by the parent or is there something else?
There was a problem hiding this comment.
The trust boundary is deliberately worker → parent: a compromised worker can write a forged shared-memory result that the parent would otherwise deserialize. Parent → worker messages originate in the controlling process and may contain arbitrary user batch arguments, so restricting them to the internal result protocol would break supported inputs.
Category:
Bug fix
Description:
Restrict deserialization of worker-to-parent shared-memory results to the internal multiprocessing protocol object graph.
Addresses:
The multiprocessing subsystem uses pickle.loads() to deserialize data from shared memory regions written by worker processes. In
shared_batch.py, bothdeserialize_sample_meta()(line 162) andread_shm_message()(line 296) callpickle.loads()on data read from shared memory buffers. If a worker process is compromised (e.g., through a malicious data source callback), it could write crafted pickle payloads to shared memory that would achieve arbitrary code execution in the parent process when deserialized.Additional information:
Affected modules and functionalities:
Key points relevant for the review:
RuntimeError, andStopIteration.StopIterationworker exceptions are normalized before serialization.Tests:
-test_external_source_parallel_shared_batch.test_restricted_unpickler_normalizes_stop_iteration_subclasses
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A