The midrash is located in Bereishit Rabbah 79:7, which states:
וַיִּקֶּן אֶת חֶלְקַת הַשָּׂדֶה אֲשֶׁר נָטָה שָׁם אָהֳלוֹ וגו' בְּמֵאָה קְשִׂיטָה, אָמַר רַבִּי יוּדָן בַּר סִימוֹן זֶה אֶחָד מִשְׁלשָׁה מְקוֹמוֹת שֶׁאֵין אֻמּוֹת הָעוֹלָם יְכוֹלִין לְהוֹנוֹת אֶת יִשְׂרָאֵל לוֹמַר גְּזוּלִים הֵן בְּיֶדְכֶם, וְאֵלּוּ הֵן: מְעָרַת הַמַּכְפֵּלָה, וּבֵית הַמִּקְדָּשׁ, וּקְבוּרָתוֹ שֶׁל יוֹסֵף. מְעָרַת הַמַּכְפֵּלָה, דִּכְתִיב: וַיִּשְׁמַע אַבְרָהָם אֶל עֶפְרוֹן וַיִּשְׁקֹל אַבְרָהָם לְעֶפְרֹן, בֵּית הַמִּקְדָּשׁ, דִּכְתִיב: וַיִּתֵּן דָּוִיד לְאָרְנָן בַּמָּקוֹם וגו'. וּקְבוּרָתוֹ שֶׁל יוֹסֵף:
Rough translation:
Rabbi Yudan bar Simon brings three things that belong to Bnei Yisrael that no one can say they belong to someone else, and they are:
- Ma'arat HaMachpelah, as it says: "And Abraham listened to Ephron, and Abraham weighed out to Ephron the silver that he had named in the hearing of the sons of Heth, four hundred shekels of silver, accepted by the merchant." (Bereishit 23:16)
- The Beit HaMikdash, as it says: "And David gave to Ornan for the place shekels of gold weighing six hundred." (Divrei HaYamim I 21:15)
- The kever of Yosef, as it says: "And he bought the part of the field where he had pitched his tent from the sons of Hamor, the father of Shechem, for a hundred kesitas." (Bereishit 33:19)
It must be noted, however, that this midrash does not mention the reason Abraham purchased the field from Ephron (as opposed from taking the field for free, as Ephron offers), other than that the implication later is that because Abraham purchased Ma'arat HaMachpelah, no one can say that it does not belong to the Bnei Yisrael.
Translation of the passukim from Chabad.org. Text of the Midrash from Sefaria.org.