Cosmic-ray acceleration in young protostars