The Rambam wrote in chapter 5: If tax collectors took his garment and returned to him another, behold these are his, because this is like a sale and the presumption is that the owners despaired of it and he does not know for certain that this is stolen. And if he was a pious person and strict with himself, he returns them to the original owners. In what case does this apply? When the tax collector is like a bandit, such as when the tax collector is a gentile, or a tax collector who stands on his own, or a tax collector who stands [by authority] but has no fixed rate, rather he takes what he wishes. But a tax collector who is on behalf of the king, and the king decreed upon him to take a fixed amount, and he appointed an Israelite tax collector to collect it for the king, and it is known that this man is trustworthy and adds nothing to what the king decreed, the law of the kingdom is the law. And not only that, but one who smuggles from this tax violates "you shall not steal" because he steals the portion of the king, whether it was a king of Israel or a king of the nations. And so too, one who bought the tax from the king must pay him in full, and one who conceals the tax, behold he steals from the one who holds the tax. But if an oppressor or a robber took the tax, it is permitted, because it is like the avoidance of his loan which is permitted in a place where there is no desecration of the Name. Thus far his words. And our teacher, the Beit Yosef, transcribed it in section 6.
And regarding that which he wrote, that with tax collectors the presumption is that the owners despaired, and regarding a gentile tax collector, they raised a difficulty against him from what was written in siman 368, that one who rescues from a gentile tax collector is obligated to return it because the owners did not despair. And there is one who answered that specifically in this case where they gave the garment to another, the victim of the robbery despairs since he sees that it was already sold [Sma ibid.]. And this is a forced explanation, for if so, if the victim of the robbery does not know of this, it does not belong to the one who exchanged it, and why did the Talmud and the poskim not mention this? [Taz]. And there is one who says that here we are dealing with an Israelite tax collector, and that which was written "In what case does this apply etc." does not refer to what was above but rather to the fundamental law of tax collectors and not to the preceding [ibid.]. And the forced nature is evident.
And it appears to me that in siman 368 it deals with a case where he knows for certain that it is stolen, for this is the language of "one who rescues," but here he does not know for certain that it is stolen, rather he takes his garment and he gives him another garment. And since this is like a sale and he does not know clearly that it is stolen, we lean toward leniency, that even if it is stolen, we say that the owners despaired; and they were not strict in a case of doubt where there is a loss, such that he would lose his garment. But to buy from him is forbidden. And so too, if it is known clearly that it is stolen, it is forbidden even in a case of loss, as the Rambam, of blessed memory, is precise in his words. And that which our teacher, the Rema, wrote, that if it is known that the owners did not despair, he must return it to the owners for free, thus far his words, the same law applies if it is only known that it is stolen, for even in an undefined case we say they did not despair as was written there. However, because it is explained in the wording of the Rambam and the Shulchan Aruch that the presumption is that the owners despaired, for this reason he says that if it is known that they did not despair, he must return it for free, for a change of domain without despair is nothing.
כתב הרמב"ם בפ"ה נטלו מוכסין כסותו והחזירו לו אחרת הרי אלו שלו מפני שזו כמכירה היא וחזקתה שנתייאשו הבעלים ממנה ואינו יודע בודאי שזו גזולה ואם היה ותיק ומחמיר על עצמו מחזירן לבעלים הראשונים בד"א שהמוכס כליסטים בזמן שהמוכס כותי או מוכס העומד מאליו או מוכס העומד שאין לו קצבה אלא לוקח מה שירצה אבל מוכס שמחמת המלך ופסק המלך עליו ליטול דבר קצוב והעמיד מוכס ישראל לגבותו למלך ונודע שאדם זה נאמן ואינו מוסיף כלום על מה שגזר המלך דינא דמלכותא דינא ולא עוד אלא שהמבריח ממכס זה עובר על לא תגזול מפני שהוא גוזל מנת המלך בין שהיה מלך ישראל בין שהיה מלך האומות וכן מי שקנה המכס מהמלך צריך לשלם לו בשלימות ומי שמעלים המכס ה"ז גוזל את מי שמחזיק המכס אבל אם אנס וגזלן לקח המכס מותר משום דהוי כהפקעת הלואתו דשרי במקום דליכא חילול ה' עכ"ל והעתיקו רבינו הב"י בסעיף ו' ובזה שכתב דבמוכסין חזקה שנתייאשו הבעלים ובמוכס כותי הקשו עליו ממ"ש בסי' שס"ח דבמציל ממוכס כותי חייב להחזיר מפני שלא נתייאשו הבעלים ויש מי שתירץ דדוקא בזה שנתנו הכסות לאחר מתייאש הנגזל כיון שרואה שכבר נמכר [סמ"ע שם] וזהו דוחק דא"כ אם הנגזל אינו יודע מזה אינו של זה שהחליפו ולמה לא הזכירו הש"ס והפוסקים מזה [ט"ז] ויש מי שאומר דכאן מיירי במוכס ישראל ומ"ש בד"א וכו' לא קאי אדלעיל אלא על עיקר דינא דמוכסין ולא על הקודם [שם] והדוחק מבואר ולי נראה דבסי' שס"ח מיירי שיודע בודאי שגזולה היא דזהו לשון המציל אבל בכאן אינו יודע בודאי שגזולה היא אלא נוטל כסותו ונותן לו כסות אחר וכיון שזהו כמכירה ואינו יודע בבירור שהיא גזולה תלינן לקולא שאפילו אם גזולה היא אנו אומרים שהבעלים נתייאשו ולא החמירו בספיקא במקום פסידא שיאבד כסותו אבל לקנות ממנו אסור וכן אם ידוע בבירור שהיא גזולה אסור אפילו במקום פסידא כמו שמדקדק הרמב"ם ז"ל בדבריו וזה שכתב רבינו הרמ"א דבידוע שלא נתייאשו הבעלים צריך להחזירו לבעלים בחנם עכ"ל ה"ה דאם רק ידוע שגזולה היא גם בסתמא אמרינן שלא נתייאשו כמ"ש שם אלא שמפני שמבואר בלשון הרמב"ם וש"ע דחזקתה שנתייאשו הבעלים לזה אומר דאם ידוע שלא נתייאשו צריך להחזירו בחנם דשינוי רשות בלא יאוש לאו כלום הוא: