LAND CANNOT BE STOLEN
Gemara
43b (Beraisa): If Reuven sold a house or field, he cannot testify about it, for there is Achrayus (a guarantee of compensation if it will be taken, therefore, he is partial) If he sold a cow, he can testify about it, for there is no Achrayus.
44b (Rav Papa): If one sold land without Achrayus, the buyer has no claim against the seller if it is taken by a creditor, but he has a claim if the seller did not own it (and the owner takes it).
(Rav Zvid): He has no claim even if the seller did not own it. The seller can say 'this is why I sold it without Achrayus!'
Bava Kama 117b (Mishnah): (If Reuven stole Shimon's field and) the river flooded it, Reuven can say 'your field is in front of you.'
(Beraisa - R. Eliezer): (If Reuven stole Shimon's field and) the river flooded it, he must give him another field;
Chachamim say, he can say 'your field is in front of you.'
They learn (what can be stolen) from a verse. "He will deny his neighbor" is a Kelal (general term). "About a deposit" is a Perat (specific term). "Anything that he will swear about" is another Kelal. From the Kelal u'Frat u'Chlal we include only what is similar to the Perat, i.e. Metaltelim with intrinsic value, but not land, slaves (which are equated to land) or documents.
97a (Rav Daniel citing Rav): If Reuven grabbed Shimon's slave and made the slave work for him, he is exempt.
Question: If slaves are like land, the slave always belonged to Shimon. Shimon should own the labor!
Gitin 48b (Mishnah): (If a field was stolen,) one does not collect for the Peros from Meshubadim (property that was sold).
Bava Metzia 14b (Rava): If one stole a field laden with Peros, and ate the Peros and dug pits in the field, the owner collects principal (the damage due to the pits) even from Meshubadim, and the value of the Peros from Bnei Chorin.
15b (Rav): If Reuven bought a stolen field, even if he knew that the seller stole it, he gets back what he paid, but not Shevach (improvements);
(Shmuel): He does not get back even what he paid.
Answer: Rav holds that Reuven intended that the money be a deposit. Shmuel holds that he gave the money for a gift.
Question: According to both Rav and Shmuel, Reuven may use the land and eat the Peros. He reasons 'I will use the land like the thief would have used it. When the owner comes, I will return the land' (and, according to Rav, get back his money).
(Rava): The law is, whether or not he knew that the field was stolen, he gets back his money.
Achrayus Ta'os Sofer (if a document does not mention Achrayus), this is a mistake of the scribe (really, there is Achrayus) for a loan or sale.
Rishonim
Rif and Rosh (Bava Basra 24b and 3:44): The Halachah follows Rav Zvid.
Rambam (Hilchos Mechirah 8:19): If one sold land and explicitly stipulated that he has no Achrayus, even if it will became known that it was stolen, and the true owner took it from the buyer, the seller is not liable at all. We need not say that he is exempt if his creditor took it, for every monetary stipulation is binding.
Rambam (9:1): If one stole land and ruined it, e.g. he dug pits, cut trees, ruined the springs or destroyed the building, he must provide another house or field like at the time he stole, or pay for the loss he caused. If the land became ruined by itself, e.g. a river flooded it or it was burned by fire that came from Shamayim, he says 'your land is in front of you.' Land is in the Chazakah of its owner, so the thief is not liable for its ruin unless he overtly ruined it. This is unlike Metaltelim.
Rambam (Hilchos Edus 16:4): If Reuven sold a cow to Shimon, and Yehudah claims that it was his, Reuven may testify for Shimon. He does not benefit from his testimony, for in any case Reuven's creditor cannot collect from it. This is when Shimon knows that it was Reuven's. If not, Reuven would have to pay back Shimon if Yehudah proved that it was his and took it.
Tur (CM 37:9): The Rambam rules like Rav Papa. The Rosh rules like Rav Zvid.
Rebuttal (Beis Yosef DH she'Ein): This cannot be. The Rambam rules like Rav Zvid in Hilchos Mechirah! Rather, he holds that Rav Zvid argues only when he explicitly stipulated that there is no Achrayus. Normally, Achrayus Ta'os Sofer (for a sale of land). There is no Achrayus in a Stam sale of Metaltelim. Rav Zvid agrees that the seller must compensate the buyer if it was taken.
Bach (DH Yir'eh): The Tur understands that the Rambam discusses when he specified that there is no Achrayus. The Beis Yosef holds that he discusses a Stam sale. This is difficult. If so, why did the Beraisa distinguish a cow from a house? In either case, the seller must compensate unless he specified that there is no Achrayus! The Rambam rules like Rav Zvid, but regarding testimony even Rav Zvid agrees that the seller is partial, for he does not want the buyer to have claims and grievances against him (even though the Halachah is that there is no compensation).
Nimukei Yosef (Bava Metzia 8b DH v'Achrayus): We say Achrayus Ta'os Sofer not only regarding documents. Even if one sold a field in front of witnesses, (if it was taken) the buyer collects from Meshubadim (Bava Basra 41b), even if there was no mention of Achrayus (Bava Basra 43b). There are three kinds of Achrayus, in ascending order. One Achrayus is from himself, i.e. if he will take back the property (based on other rights he has to it - Kesuvos 91b). A second is due to himself, e.g. if his creditor will take the property. A third is from elsewhere, e.g. if it will be found that it was not his. Rav Hai Gaon says that even though Achrayus Ta'os Sofer, and if he did not specify, all are included, if he specified that he accepts due to himself, he excludes what is above this, i.e. from elsewhere. If he specified from elsewhere, this includes from himself and due to himself, which are below it.
Poskim
Shulchan Aruch (CM 225:5): If one sold land and explicitly stipulated that he has no Achrayus, even if it will became known it was stolen, and the true owner takes it from the buyer, the seller is not liable at all. We need not say that he is exempt if his creditor took it, for every monetary stipulation is binding.
Bach (6): Semag says that the Ri rules like Rav Papa. The seller must return the money, for it is not a sale at all; the owner takes the land and Peros. A creditor does not take Peros, therefore, until he takes it, it is considered a sale. If one bought a field and knew that it was stolen, Rav and Shmuel argue about whether what he paid is a deposit or a gift. If so, it was sold without Achrayus. This implies that in a similar case in which he did not know that it was stolen, all agree that he gets back his money.
Shulchan Aruch (CM 371:1): Land can never be stolen.
Shulchan Aruch (2): Therefore, if the land became ruined by itself, e.g. a river flooded it, the thief is not liable, for it belonged to the owner. He says 'your land is in front of you.' If the thief overtly ruined it, e.g. he dug pits, cut trees, ruined the springs or destroyed the building, he must provide another house or field like at the time he stole, or pay for the loss he caused.
Rema: Just like is land is in the Reshus of the owner (for his detriment) to allow the thief to say 'your land is in front of you', it is in the owners' Reshus for his benefit. Regarding Metaltelim, the thief pays only like at the time of the theft. If a thief used land and ate the Peros, he pays for his benefit.
Beis Yosef (DH uch'Shem): We learn from Gitin 48b and Bava Metzia 14b.
Note: The Rambam (Hilchos Malveh 21:1) explains Gitin 48b to discuss collecting for Peros from the thief. Rashi (Gitin 48b DH Ein) holds that if discusses one who bought a stolen field. The owner took it back with its Peros, and the buyer collects their value from the seller.
Shach (5): Likewise, if he lived there or rented it out, he pays what he benefited.