The New York Times' latest fake news provocation alleging that Russia's military-intelligence agency GRU solicited the Taliban (officially designated as "terrorists" by Moscow) to assassinate American soldiers in Afghanistan has brought a lot of attention to Moscow's ties with the militant group. The truth, however, is just as intriguing than the fake news about them. On the surface, it's surprising enough that Russia has diplomatic contacts with the Taliban considering that the latter grew out of the 1980s Mujahiddin that defeated the USSR.
Casual observers could be forgiven for thinking that Russia still holds a grudge against the group, but astute followers of the country's foreign policy have no such excuse. Russia's 21st-century grand strategy is to become the supreme "balancing" force in Eurasia, to which end it's sought to prioritize relations with non-traditional partners. The most prominent examples include Germany, Turkey, "Israel", Saudi Arabia, Iran, Pakistan, China, and Japan, all of which it has a long history of problems with stemming from the Old Cold War.
Nevertheless, Russia's new partnerships with all of the aforementioned prove that it's willing to let bygones be bygones and won't judge any of them based on the policies that they pursued at that time. Instead, it wants to turn the page and move past their troubled histories in order to chart a new era of multipolar cooperation together. The Taliban is but the latest addition to Russia's "balancing" network, but since it's no longer a state actor, Moscow's ties with the group are understandably limited to the Afghan peace process.
Russia, like every party to the Afghan peace process, has some degree of diplomatic contacts with the group through its Doha office, but that's the full extent of it. The previous fake news allegations about its material support to the Taliban, to say nothing of the present provocation by the New York Times, are intended to delegitimize its diplomacy by falsely portraying it as pursuing aggressive ends instead of the peaceful "balancing" ones that it truly aspires to advance.
Moscow hosted Taliban representatives on several occasions as part of the peace process that it sought to resurrect over the past year, and even Trump himself planned to meet with its leaders at Camp David last September before an unexpected attack in Afghanistan made that politically impossible on the eve of commemorating 9/11. Even so, his administration clinched a deal with the group a few months back in February, which proved that it has much closer contacts with the Taliban than Russia does.
It can only be speculated upon at this point pending official confirmation from the parties involved, but there's plausible reason to believe that Pakistan facilitated Russia's engagement with the Taliban. The fast-moving rapprochement between these Old Cold War-era rivals was initially driven by their shared assessment of security threats emanating from Afghanistan following ISIS' arrival in that theater. Both countries realize that the Taliban is the most effective anti-ISIS force in the country, hence their pragmatic interests in working with it.
The Taliban is an independent militant group fighting for national liberation from foreign occupation, but it historically has very close ties to Pakistan, hence why Moscow could have realistically used Islamabad's diplomatic services to proverbially break the ice between it and the Taliban. The trust-based relations that have been on full display between Russia and Pakistan as evidenced by their yearly anti-terrorist drills and joint participation in the multilateral Afghan peace process testify to just how close they've become in recent years.
Russia doesn't exploit the Taliban as a proxy for killing Americans, but seeks to nurture equally close relations with it along the lines of the ones that it presently enjoys with Pakistan. Moscow seems to believe that the group will likely return to power one of these days (ideally through peaceful means), so it makes sense to get on its good side. Once the war finally ends, Russia will require the Taliban's goodwill to ensure the security of any prospective trade corridor with Pakistan ("RuPak"/"N-CPEC+") for accessing the Afro-Asian ("Indian") Ocean.