Abstract We present an analytical treatment for time-dependent diffusive shock acceleration at shocks inside magnetic clouds (MCs) observed near 1 au. The model includes the effects of (i) spatial diffusion of test particles upstream and downstream of the shock, (ii) proton advection with the plasma inside MCs, (iii) a reflecting boundary at distance L upstream of the shock to mimic the boundary of the MCs, and (iv) particle leakage out of the system at a constant rate, possibly through open field lines introduced by magnetic reconnection between the closed field lines of the MC and open field lines in the corona or heliosphere. The analysis reveals that the mean time for accelerating particles from p 0 to p is naturally reduced if the MC characteristic length is much smaller than the spatial diffusion length of energetic protons upstream of the shock. However, because most shocks inside MCs observed at 1 au are located in the back half of the MC, the time that the shock has propagated into the MCs is not sufficient to cause significant SEP enhancement—even with a reflecting boundary—if particles are only injected from the low-beta plasma inside MCs. To cause large SEP enhancements inside the shock–MC structure, magnetic reconnection at the back MC is essential to allow particles energized by the shock prior to its interaction with the MC to enter the MC. These particles consequently become the seed energetic protons that are reaccelerated at the shock inside MC.