Novelization by Foster covers it. Someone stole it from Han, by the name of Ducain (no info on him yet).
Impatiently, their captor gestured ever so slightly with the muzzle of his blaster. “Where’d you find this ship?”
“Right here.” She saw no reason not to tell the truth. “I mean, down on the surface. Niima Outpost, to be specific.”
Dropping his lower jaw to signify his disbelief, he stared back at her. “Jakku? That junkyard?”
“Thank you!” Finn said. “Junkyard!” His original opinion confirmed, he shot Rey a look that was pure I-told-you-so.
Looking away from them for the first time since they had emerged from below, their captor addressed his towering cohort. “Told ya we should’ve double-checked the Western Reaches! Just lucky we were in the general vicinity when the ship powered up and its beacon snapped on.”
He turned back to Rey. She was trying to make sense of the mismatched pair standing before her and failing utterly.
“Who had it?” he continued. “Ducain?”
Again, she thought: no reason to prevaricate. “I stole it from a salvage dealer named Unkar Plutt.”
Brows narrowed as the weathered visage wrinkled even more. “From who?”
“Look.” Taking a chance, Rey lowered her hands so she could spread her arms wide. “I don’t know all the details for sure. I’m not privy to Plutt’s private accounting. But talk says that Plutt stole this ship from the Irving Boys, who stole it from Ducain.”
“Who stole it from me!”