Genesis 3:24
22 And the Lord God said, “Now that the man has become like one of us, knowing good and evil, he must not be allowed to stretch out his hand and take also from the tree of life and eat, and live forever.” 23 So the Lord God expelled him from the orchard in Eden to cultivate the ground from which he had been taken. 24 When he drove the man out, he placed on the eastern side of the orchard in Eden angelic sentries who used the flame of a whirling sword to guard the way to the tree of life.
Numbers 22:24
22 Then God’s anger was kindled because he went, and the angel of the Lord stood in the road to oppose him. Now he was riding on his donkey and his two servants were with him. 23 And the donkey saw the angel of the Lord standing in the road with his sword drawn in his hand, so the donkey turned aside from the road and went into the field. But Balaam beat the donkey, to make her turn back to the road. 24 Then the angel of the Lord stood in a path among the vineyards, where there was a wall on either side.
Notes and References
"... the image of an angel armed with a sword is common to both stories. In Genesis 3:24 angels are placed at the entrance to the garden to obstruct human passage, thereby preventing the attainment of eternal life. In this way they are guardians of immortality, but guarantors of death to humankind. The angel in Numbers 22 is sent by God to frustrate Balaam's journey to Balak, and is clearly menacing to both Balaam and to the she-ass, but he represents a temporary danger rather than a permanent deterrent. Despite his hostile intention as described in 22:33 (Ί would have killed you'), his role turns out to be primarily cautionary, warning Balaam not to deviate from the message he will receive (Numbers 22:35). This provisional threat to Balaam's life is turned to a more positive purpose: to prevent harm from being done to Israel in the form of curse, and ultimately to guarantee life to Israel in the form of blessing ..."
Savran, George Beastly Speech: Intertextuality, Balaam's Ass, and the Garden of Eden (pp. 33-55) Journal for the Study of the Old Testament, 1994