The National Highway Transportation Safety Administration says the vehicles were made between Aug. 3, 2010, and July 1, 2011.
NHTSA says on its website that the adhesive between the sunroof's glass and retainer wasn't adequately applied.
There is a chance the sunroof glass could loosen and come off while driving, resulting in a potential road hazard for other cars and trucks and potentially causing a crash.
Subaru told NHTSA that it will notify owners. Dealers will inspect the adhesion and either apply extra adhesive or replace the glass for free.
The recall is expected to begin next month.