Is there a law that prevents a patent lawyer from using his position to modify failed patents he hears about and create a successful patents for himself? I can see that being a conflict of interest.
If the patent lawyer "hears about" such failed patents from clients, and then uses the client's work and modifies them into successful patent filings, that would seem to be a clear conflict of interest, just as a business lawyer cannot use info learned from a client to make his own business deals, unless the client grants an OK.
But if the patent lawyer just hears through shoptalk, or through communication by, perhaps, patent examiners that the lawyer works with, I don't see any conflict of interest, although as the comment by Eugene Styer suggests, there is likely to be enough prior art to make the patent invalid.
A patent lawyer can own a patent.
A patent lawyer can also be an inventor who doesn't use ideas from his or her clients.
If the patent lawyer's invention is actually derived from an appropriation of client ideas about which the patent lawyer was consulted, there can be a violation of professional duties by the lawyer, although the fact pattern contemplated by the body text of the question is not usually how it arises.
A more common fact pattern (although still extremely rare) which I have seen arise in practice, is one in which a patent lawyer is approached by two independent sets of clients who have a similar patentable idea for which no patent application has yet been filed, with one of those clients financing the work in part by giving the patent lawyer part-ownership in the patent to be sought, and the other offering to pay by the hour. Then, the lawyer uses information obtained from one potential client offering to pay on a purely fee for services basis whom he declined to represent further, to assist the other client obtain a patent enhanced by the other client's ideas.
Is there a law that prevents a patent lawyer from using his position to modify failed patents he hears about and create a successful patents for himself?
Yes. 35 U.S.C. 115 requires the applicant to execute an oath stating that he is the inventor(s) or is duly authorized by the inventor(s) to apply for the patent.
I can see that being a conflict of interest.
Regardless of the lawyer's relation (if any) with the inventor(s), the lawyer's scheme would hinder "the very point of patents, which exist to promote creation", Ass'n or Molecular Pathology v. Myriad, 133 S.Ct. 2107, 2116 (2013).