It’s the 9th attainment, sañña vedayita nirodha , perceptions & feelings cessation, where that invulnerability happens
MN 50 excerpt
Once upon a time, Evil One, the venerable Sañjīva was sitting at the root of a certain tree attaining the stopping of perceiving and feeling. Then, Evil One, cowherds, goatherds, yeoman farmers, travellers, saw the venerable Sañjīva sitting at the root of that tree attaining the stopping of perceiving and feeling; having seen him, it occurred to them: ‘Indeed it is wonderful, indeed it is marvellous, that this recluse is just sitting dead. Come, we will cremate him.’ Then, Evil One, these cowherds, goatherds, yeomen farmers, travellers, having collected grass and sticks and cow-dung and having heaped them over the venerable Sañjīva’s body, lit the fire and departed.
There’s another sutta where Sariputta while in sitting meditation gets hammered in a head by a yakkha that might have been fatal had he not been in attainment number 9. Instead, he comes out with a slight headache if I recall. (sutta ref. anyone?)
In theory someone with strong 4th jhāna and mastery of 5 of the 6 abhiñña, in particular the first one, should be able to withstand fire with no harm, as easily as they could walk on water, dive in to the earth like it’s water, etc.
There there is also Ven. Dibba, who had one of the coolest last words spoken ever recorded, while demonstrating his mastery over fire:
The First Discourse about Dabba
Thus I heard: At one time the Gracious One was dwelling near Rājagaha, in Bamboo Wood, at the Squirrels’ Feeding Place. Then venerable Dabba Mallaputta went to the Gracious One, and after going and worshipping the Gracious One, he sat down on one side.
While sat on one side venerable Dabba Mallaputta said this to the Gracious One: “Now is the time for my Complete Emancipation, Fortunate One.”
“Now is the time for whatever you are thinking, Dabba.”
Then venerable Dabba Mallaputta, after rising from his seat, worshipping and circumambulating the Gracious One, after going up into the sky, and sitting in cross-legged posture in the air, in the firmament, entering the fire-element, and emerging, attained Complete Emancipation.
Then while venerable Dabba Mallaputta—after going up into the sky, and sitting in cross-legged posture in the air, in the firmament, entering the fire-element, and emerging—was attaining Complete Emancipation, his body burning and being consumed, there was no charcoal and no ash evident.
Just as while ghee or oil is burning and being consumed there is no charcoal and no ash evident, so also while venerable Dabba Mallaputta—after going up into the sky, and sitting in cross-legged posture in the air, in the firmament, entering the fire-element, and emerging—was attaining Complete Emancipation, his body burning and being consumed, there was no charcoal and no ash evident.
Then the Gracious One, having understood the significance of it, on that occasion uttered this exalted utterance:
“The body broke up, perception ceased,
All feelings became cool,
Mental processes were pacified,
consciousness came to rest.”
What a nice thing to do for lay people as well. No messy carcass to dispose of.
I think it says that in Vism., I don’t recall any EBT’s that say that. Maybe in the sutta that lists 10 (?) benefits of practicing metta has some kind of protective power, but I don’t think un-flammability is one of them.
And then there’s SN 41.4 for another demonstration of mastery over fire, 4th jhana prerequisite:
13Then Citta the householder approached the Venerable Mahaka, paid homage to him, sat down to one side, and said to him: “It would be good, venerable sir, if Master Mahaka would show me a superhuman miracle of spiritual power.”
14“Then, householder, spread your cloak upon the verandah and scatter a bundle of grass upon it.”
15“Yes, venerable sir,” Citta the householder replied, and he spread his cloak upon the verandah and scattered a bundle of grass upon it.
16Then, when he had entered his dwelling and shut the bolt, the Venerable Mahaka performed a feat of spiritual power such that a flame shot through the keyhole and the chink of the door and burnt the grass but not the cloak.295 “” Citta the householder shook out his cloak and stood to one side, shocked and terrified.
17Then the Venerable Mahaka came out of his dwelling and said to Citta the householder: “Is this much enough, householder?” 
18“That’s enough, Venerable Mahaka. What’s been done is sufficient, Venerable Mahaka, what’s been offered is sufficient. Let Master Mahaka delight in the delightful Wild Mango Grove at Macchikāsaṇḍa. I will be zealous in providing Master Mahaka with robes, almsfood, lodgings, and medicinal requisites.”
19“That is kindly said, householder.”
20Then the Venerable Mahaka set his lodging in order and, taking bowl and robe, he left Macchikāsaṇḍa. When he left Macchikāsaṇḍa, he left for good and he never returned.
In Dipama’s biography, there’s an account where she could use her hands and cook food from the heat in her hand. Don’t remember if there was a flame.
Taoist master john chang doing similar trick with heated hands, starts at around 2 min 30 sec;