In general, privity is required before an attorney may be held liable in legal malpracitce. Sometimes, the attorney may be held for advice, especially opinion letters, to 3d parties, who did not hire the attorney, but relied upon the advice. Here is a case, reported by the Hinshaw firm, which restates the principal.
Mega Group, Inc. v. Pechenik & Curro, P.C., 819 N.Y.S. 796 (2006)
The court held that while the opinion letter provided in this corporate transaction did create a duty to the third party purchaser, the duty was not violated when the opinion letter contained only the information requested in the sales agreement and did not address the issue in controversy.