Q. If someone sees that the fellow davening next to him has a Machzor that was obviously stolen from a shul and tell him that he may not comply with the davening as it is a Mitzva Haba'a Beavera, (a mitzva done by doing a sin)?
A. On question 3430 we wrote "A Shul from where books are taken outside the shul without permission and often not returned, can they place a sign that whoever takes out a Sefer without the permission of the Gabaim transgresses the prohibition of stealing and his Torah learning is considered a ‘Mitzva Haba’a Beavera’ or a mitzva complied while doing a prohibited act and is invalid.
To what we answered: Horav Shlomo Miller’s Shlit’a opinion is that it may indeed be considered a ‘Mitzva Haba’a Beavera’ and one may not be complying at all with the mitzva of learning Torah when at the same time one is performing the prohibited act of using a stolen sefer. This ruling can also be included in the sign posted on the shul, that prohibits the taking out of sefarim from the shul."
However the Rov Shlit'a mentioned that after the fact, one does not have to repeat the davening.
Rabbi A. Bartfeld as revised by Horav Dovid Pam, Horav Aharon Miller and Horav Chanoch Ehrentreu Shlit'a.