It turns out that the story of Ali Baba and the Forty Thieves was a late addition to the 1001 Nights Anthology of stories probably added from oral tradition received in Syria by a Frenchman who is the first person to have put it in print, centuries after the other stories were written down.
And, the code word "Open Sesame" in the story, perfectly corresponds to the Serbian phase "otvori se za me" meaning "open yourself for me.", which is just what the magical stones do when prompted by the code word.
But, what is a Serbian phase doing in an Arabian story?
Well, it turns out the Slavs were relocated by the Byzantines to serve as buffer populations between them and the Islamic Ottoman empire right along the Syrian border. So it is natural that a Serbian story might make its way into an orally transmitted tale in Syria.
Via the Old European culture blog (indeed, "Baba" also has plausible Slavic etymologies consistent with the poor woodcutter of that name in the story, as explored in later posts at the same blog).