The dynamics of capillary filling in the presence of chemically coated heterogeneous boundaries is investigated, both theoretically and numerically. In particular, by mapping the equations of front motion onto the dynamics of a dissipative driven oscillator, an analytical criterion for front pinning is derived, under the condition of diluteness of the coating spots. The criterion is tested against two dimensional Lattice Boltzmann simulations, and found to provide satisfactory agreement as long as the width of the front interface remains much thinner than the typical heterogeneity scale of the chemical coating.