One key aspect of Kylo Ren's character in Star Wars is his reverence for his grandfather, Darth Vader, which was shown visually in The Force Awakens, both in his style and in his altar-like shrine to Vader's helmet. But while many questions about Ben Solo's fall to the Dark Side have been chronicled in works like Star Wars: The Rise of Kylo Ren, exactly how he obtained his grandfather's helmet remains a mystery.
However, that question may already have been answered in a short story published before the premiere of The Force Awakens. In author Delilah S. Dawson's "The Perfect Weapon," bounty hunter Bazine Netal is hired to obtain a mysterious case -- and its contents could very well be Vader's helmet.
For the most part, Star Wars media taking place in the sequel era have glossed over how Darth Vader's helmet came to be in Ren's possession. In Kristin Baver's Skywalker: A Family at War, it's stated that Luke Skywalker viewed the mask as a symbol of evil, and "the last piece of the Imperial machine Luke helped dismantle in his quest for freedom from his personal demons." Because Luke was working to break free from his father's legacy, it's unlikely he would've retrieved it from his father's funeral pyre on Endor's Forest Moon.
In contrast, Baver makes Ben Solo's connection to the mask clear, writing that he "viewed [the mask] not as a symbol of evil, but a family heirloom, a beloved relic from a bygone era." So, while he initially saw it as a piece of his family history, his view became warped once he turned to the Dark Side. Baver describes Kylo Ren's fixation on his grandfather's mask as almost religious in nature, but exactly how the mask came into his possession was left unclear.
While an answer to this question has not been definitively stated, Dawson's "The Perfect Weapon" may hold the key to unraveling this mystery. The story focuses on Bazine Netal, who appears in The Force Awakens when she alerts the First Order to BB-8's presence at Takodana Castle. The particular choice of Bazine for the main character of "The Perfect Weapon" also hints that the contents of the case are related to Kylo Ren and his family.
The character's other main appearance in the Star Wars franchise is in the Flight of the Falcon series that was meant to promote the ride of the same name at Star Wars: Galaxy's Edge. Throughout the series, she works for the First Order to find the Millennium Falcon. The ship can also be seen as a relic of Kylo Ren's past, even if it is one he seeks to destroy rather than revere. If the contents of the case were Darth Vader's helmet, then the Flight of the Falcon series could be seen as a continuation of Bazine's role as a bounty hunter for Kylo Ren specifically.
At the beginning of the story, Bazine's employer contacts her through a rusted protocol droid using a hologram. She observes that "the figure [in the hologram] was cloaked, naturally, and its voice was so well modulated that Bazine couldn't guess at its species, age or gender."
While the mystery figure is unidentifiable to Bazine, there are some clues here that they could be Kylo Ren. Ben also incorporated voice modulation into his appearance as Kylo after his fall to Dark Side. Additionally, when the droid finishes relaying the specifics of the mission to Bazine, it self-destructs, leaving the mercenary to observe that her employer was "dramatic." Several First Order members could fit that description, but Kylo's tantrums throughout The Force Awakens definitely make him the most likely candidate.
The mission, which Bazine chooses to accept, involves retrieving a case from Stormtrooper TK-1772, Jor Tribulus, a patient at Vashka City Medcenter One. She discovers that Tribulus was transferred to another facility, one that was infested by Vashkan apidactyls that killed most of the patients and employees there. The sole survivor, Stormtrooper TK-1403, Aric Nightdrifter, served under Tribulus, most notably at the Battle of Endor. This plot detail is particularly relevant because Star Wars: The Force Awakens Visual Dictionary states that the helmet was "scavenged from a funeral pyre on Endor."
Bazine does succeed in obtaining the case, having to defeat her mentor Delphi Kloda in the process. This twist mirrors Kylo Ren's own desire to destroy the parts of the past that he feels betrayed him, even though Kloda's betrayal is more concrete than perceived. So, while the short story never actually reveals the contents of the case, it's fair to say Kylo had his hand in the mission in one way or another.