We study the linear stability of transient electrodeposition in a charged random porous medium, whose pore surface charges can be of any sign, flanked by a pair of planar metal electrodes. Discretization of the linear stability problem results in a generalized eigenvalue problem for the dispersion relation that is solved numerically, which agrees well with the analytical approximation obtained from a boundary layer analysis valid at high wavenumbers. Under galvanostatic conditions in which an overlimiting current is applied, in the classical case of zero surface charges, the electric field at the cathode diverges at Sand's time due to electrolyte depletion. The same phenomenon happens for positive charges but earlier than Sand's time. However, negative charges allow the system to sustain an overlimiting current via surface conduction past Sand's time, keeping the electric field bounded. Therefore, at Sand's time, negative charges greatly reduce surface instabilities and suppress dendritic growth, while zero and positive charges magnify them. We compare theoretical predictions for overall surface stabilization with published experimental data for copper electrodeposition in cellulose nitrate membranes and demonstrate good agreement between theory and experiment. We also apply the stability analysis to how crystal grain size varies with duty cycle during pulse electroplating.