arXiv:2609.01781cs.SESep 2026

Manuscript Offprint

arXiv:2609.01781

Modelstamp: Pre-Deserialization Verification of Machine-Learning Artifacts and Runtime Environment State

Anagha Dhekne

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Anagha Dhekne

Independent Researcher

Abstract—Persisted machine-learning models can remain byte-identical while the software environments in which they are loaded evolve, creating a verification problem that artifact integrity checks alone cannot expose. This paper presents Modelstamp, a lightweight Python persistence library for verifying artifact integrity and represented runtime-environment state before deserialization. At persistence time, Modelstamp associates a serialized artifact with a sidecar JSON manifest containing a SHA-256 digest, runtime metadata, and installed versions from a bounded tracked-package set; a separately recorded model-relevant subset determines which package versions participate in drift comparison. Optional HMAC authentication supports workflows in which the producer and verifier share a secret key. At verification time, the artifact and represented current environment are checked against this recorded evidence before the model is deserialized. Modelstamp is evaluated using 14 controlled environment-drift scenarios, eight controlled trust-boundary scenarios, and an artifact-size scaling benchmark from 10 MiB to 1 GiB. The controlled drift experiments behaved as specified across relevant dependency changes, unchanged environments, and unrelated environmental changes, including broader noise controls. The trust-boundary experiments similarly confirmed both intended detections and expected limitations, including shared-key forgery and replay. Median verification time increased from 0.032 s at 10 MiB to 3.334 s at 1 GiB, with measured throughput of approximately 307–312 MiB/s in the benchmark environment. These results characterize Modelstamp as a complementary pre-deserialization reference-state verification control rather than as a replacement for dependency-management systems, malicious-model detection, safe deserialization, or public publisher authentication.

Index Terms—Artifact integrity, dependency drift, environment verification, machine learning, model persistence, software supply chain security.

I. INTRODUCTION

Machine-learning models are routinely serialized so that they can be stored, transferred, deployed, and reused without retraining. In Python-based workflows, however, a persisted model is not necessarily independent of the software environment in which it is later consumed. Its successful loading and behavior may depend on the Python runtime, machine-learning framework, and supporting libraries present at deserialization time. A model artifact can therefore remain byte-identical while the environment around it evolves, creating a condition that is invisible when only the serialized file itself is considered.

This creates two distinct verification concerns. The first is artifact integrity: whether the serialized bytes being loaded are the same bytes that were previously established as the reference artifact. The second is environment drift: whether model-relevant runtime dependencies at verification time differ from those recorded when the artifact was persisted. Cryptographic hashing can identify byte-level modification of an artifact, but an unchanged digest cannot reveal that a relevant dependency has changed. Conversely, a dependency-version difference does not imply that the artifact itself has been modified, nor does it necessarily mean that model behavior has changed. Artifact integrity and environment consistency should therefore be treated as related but separate properties of persisted-model verification.

Existing research and tooling address important aspects of ML artifact trust and reuse, including unsafe serialization, malicious-artifact detection, constrained deserialization, publisher authentication, dependency representation, environment capture, and software-artifact verifiability. Model-persistence and lifecycle tooling can also record dependency metadata or warn about cross-version incompatibility. These mechanisms answer different questions about an artifact's origin, contents, execution, reproducibility, or software context. The concern investigated here is narrower: given an ML artifact whose reference state has already been established, can artifact consistency and a model-oriented projection of recorded runtime state be checked before deserialization while keeping the limits of those checks explicit?

This paper presents Modelstamp, a lightweight Python persistence library designed to investigate this problem. When an ML artifact is persisted, Modelstamp creates a companion manifest containing artifact-integrity information and runtime metadata. The current implementation records Python/runtime fields and installed versions from a bounded tracked-package set, while a separately recorded model-relevant subset determines which package versions participate in drift comparison. The artifact is associated with a SHA-256 digest, and an optional HMAC mechanism can authenticate the recorded evidence in controlled shared-secret workflows. During subsequent verification, Modelstamp checks the artifact against its recorded integrity evidence and compares the represented current environment with the applicable recorded state before deserialization occurs.

A central design consideration is determining which recorded package changes are relevant to the persisted model. Comparing every installed Python package can generate warnings for changes that have no relationship to the model being loaded. Modelstamp therefore separates bounded package-state capture from model-specific comparison: the manifest records installed versions from the tracked set, and relevance rules select a subset for package-drift evaluation. This introduces an empirical question: whether relevant dependency changes can be surfaced without producing warnings for unrelated environmental changes. It also creates a clear limitation: the selected subset is an approximation of model relevance rather than a complete representation of every factor capable of affecting execution.

The evaluation examines Modelstamp along three dimensions. First, a 14-scenario controlled environment-drift validation examines framework and supporting-dependency changes alongside identical-environment and unrelated-package controls. Second, an eight-scenario controlled trust-boundary validation examines artifact integrity and optional authentication under both detectable modifications and conditions intentionally outside the mechanism's guarantees. Third, an artifact-size scaling benchmark measures verification cost for artifacts ranging from 10 MiB to 1 GiB, using repeated measurements with verification isolated from deserialization. These experiments address the following research questions:

RQ1 — Environment drift: In controlled persisted-model scenarios, can Modelstamp distinguish changes in model-relevant runtime dependencies from unrelated environmental changes?

RQ2 — Trust boundaries: Which artifact-integrity and authentication threats can Modelstamp detect before deserialization, and which remain possible under its stated trust model?

RQ3 — Performance: How does the computational cost of Modelstamp verification scale across persisted artifacts ranging from 10 MiB to 1 GiB?

This paper makes three contributions. First, it investigates a lightweight artifact-bound persistence design that combines cryptographic artifact-integrity evidence, bounded runtime-state capture, model-relevance-filtered package comparison, and pre-deserialization verification under an explicit trust model. This combination is positioned as complementary to existing dependency-management, persistence, and artifact-security mechanisms rather than as the invention of dependency recording or cross-version warnings. Second, the evaluation shows that Modelstamp produced the expected distinction between relevant and unrelated environmental changes across all 14 controlled scenarios, including broader environmental-noise cases in which multiple unrelated package versions changed while relevant drift remained independently detectable. Third, the experiments characterize both the limits and operational cost of the verification model: all eight trust-boundary scenarios behaved according to the stated guarantees, including cases intentionally

accepted because hashing or shared-secret authentication cannot provide provenance or freshness guarantees; across artifacts ranging from 10 MiB to 1 GiB, median verification time increased from approximately 0.032 s to 3.334 s, while measured throughput remained approximately 307–312 MiB/s in the benchmark environment.

Modelstamp is not intended to establish that an artifact is intrinsically benign or correct, provide public publisher identity, or constrain code execution during deserialization. Rather, it complements mechanisms addressing those concerns by making artifact identity and recorded model-relevant environment state explicit and verifiable before deserialization.