#441·LaTeX-OCR

Insecure Deserialization via pickle.load in Im2LatexDataset.load Leads to Arbitrary Code Execution

Author: Doria77486Created Jan 15, 2026Updated Mar 25, 2026

Description

The Im2LatexDataset.load method deserializes dataset files using Python’s pickle.load without any validation or trust boundary checks:

python
    def load(self, filename, args=[]):
        if not os.path.exists(filename):
            with in_model_path():
                tempf = os.path.join('..', filename)
                if os.path.exists(tempf):
                    filename = os.path.realpath(tempf)
        with open(filename, 'rb') as file:
            x = pickle.load(file)
        return x

When users load a dataset through this class, attacker-controlled pickle files can be deserialized directly. Since pickle is not safe for untrusted input, this behavior introduces a deserialization vulnerability that may lead to arbitrary code execution (RCE). Any user who loads a dataset from an untrusted or tampered source (e.g., downloaded datasets, shared files, third-party repositories) is affected.