In this article, we focus on the complex relationship between the shape of dark matter (DM) halos and the cosmological models underlying their formation. We have used three realistic cosmological models from the DEUS numerical simulation project. These three models have very distinct cosmological parameters (Ωm, σ8, and w) but their cosmic matter fields beyond the scale of DM halos are quasi-indistinguishable, providing an exemplary framework to examine the cosmological dependence of DM halo morphology. First, we developed a robust method for measuring the halo shapes detected in numerical simulations. This method avoids numerical artifacts on DM halo shape measurements, induced by the presence of substructures depending on the numerical resolution or by any spherical prior that does not respect the triaxiality of DM halos. We then obtain a marked dependence of the halo’s shape both on their mass and the cosmological model underlying their formation. As it is well known, the more massive the DM halo, the less spherical it is and we find that the higher the σ8 of the cosmological model, the more spherical the DM halos. Then, by reexpressing the properties of the shape of the halos in terms of the nonlinear fluctuations of the total cosmic matter field or only of the cosmic matter field which is internal to the halos, we managed to make the cosmological dependence disappear completely. This new fundamental cosmological invariance is a direct consequence of the nonlinear dynamics of the cosmic matter field. As the universe evolves, the nonlinear fluctuations of the cosmic field increase, driving the dense matter halos toward sphericity. The deviation from sphericity, measured by the prolaticity, triaxiality, and ellipticity of the DM halos, is therefore entirely encapsulated in the nonlinear power spectrum of the cosmic field. From this fundamental invariant relation, we retrieve with remarkable accuracy the root-mean-square of the nonlinear fluctuations and, consequently, the power spectrum of the cosmic matter field in which the halos formed. We also recover the σ8 amplitude of the cosmological model that governs the cosmic matter field at the origin of the DM halos. Our results therefore highlight, not only the nuanced relationship between DM halo formation and the underlying cosmology but also the potential of DM halo shape analysis of being a powerful tool for probing the nonlinear dynamics of the cosmic matter field.