We study the behaviour of the $chi_{c1}(3872)$, also known as $X(3872)$, in dense nuclear matter. We begin from a picture in vacuum of the $X(3872)$ as a purely molecular $(D bar D^*-c.c.)$ state, generated as a bound state from a heavy-quark symmetry leading-order interaction between the charmed mesons, and analyze the $D bar D^*$ scattering $T-$matrix ($T_{D bar D^*}$) inside of the medium. Next, we consider also mixed-molecular scenarios and, in all cases, we determine the corresponding $X(3872)$ spectral function and the $D bar D^*$ amplitude, with the mesons embedded in the dense environment. We find important nuclear corrections for $T_{D bar D^*}$ and the pole position of the resonance, and discuss the dependence of these results on the $D bar D^*$ molecular component in the $X(3872)$ wave-function. These predictions could be tested in the finite-density regime that can be accessed in the future CBM and PANDA experiments at FAIR.