—In an action to recover damages, inter alia, for legal malpractice, the third-party defendants Rosenman & Colin, a law firm, and Joshua S. Rubenstein, a partner in the firm, appeal from so much of an order of the Supreme Court, Westchester County (Coppola, J.), dated June 17, 1991, as denied their motion, pursuant to CPLR 3211 (a) (1) and (7), to dismiss the third-party complaint and the cross claims asserted against them.
Ordered that the order is affirmed insofar as appealed from, with one bill of costs to the respondents appearing separately and filing separate briefs.
The plaintiff, the executor of the estate of Robert M. Weiss (hereinafter the estate), commenced this action against the law firm of Cuddy & Feder and Gary E. Bashian, a partner in the firm, to recover damages, inter alia, for the defendants’ *666failure to make a valid qualified terminable interest property (hereinafter QTIP) election pursuant to 26 USC § 2056 (b) (7) (B) and their overvaluation of the estate’s property on a Federal estate tax return (Form 706 [rev 1-84]), filed on or about August 15, 1986. Shortly after filing the return, the defendants’ representation of the estate ceased. Subsequently, as the result of an audit, the Internal Revenue Service (hereinafter IRS) determined that the estate had a tax deficiency of $1,316,852.69, plus interest and penalties. The record contains no indication of who represented the estate at the IRS audit.
On July 5, 1988, the plaintiff and the law firm of Rosenman & Colin entered into a retainer agreement in connection with appealing the deficiency determination. After a hearing before an IRS appeals officer, the IRS disallowed the QTIP deduction. Later, the IRS and the estate negotiated and executed a closing agreement pursuant to which, inter alia, the IRS allowed one-half of the QTIP deduction and the estate’s tax liability was reduced to $301,562.51. The plaintiff alleges in her complaint that the estate incurred a tax liability as a result of the defendants’ failure to exercise the appropriate degree of professional care.
The defendants commenced a third-party action, which includes a claim against the appellants for contribution and indemnification as a result of their. negligence and legal malpractice. The second cause of action asserted in the third-party complaint alleges that the issuance of a deficiency assessment by the IRS "was erroneous and unnecessary and resulted wholly and solely due to the omissions, misrepresentations, mistakes, negligence and errors of the third-party defendants representing * * * the estate during and after the audit conducted by the IRS.” The third cause of action asserted in the third-party complaint alleges that "[t]he closing agreement which the estate entered into with the IRS was unreasonable, improvident and the result of legal malpractice on the part of [the appellants]”. In addition, certain third-party defendants interposed cross claims for contribution or indemnification against the appellants.
The appellants moved, pursuant to CPLR 3211 (a) (1) and (7), for dismissal of the second and third causes of action asserted in the third-party complaint and for dismissal of the cross claims asserted against them. The Supreme Court properly denied their motion.
In determining whether a complaint is sufficient to withstand a motion pursuant to CPLR 3211 (a) (7) "the sole *667criterion is whether the pleading states a cause of action, and if from its four corners factual allegations are discerned which taken together manifest any cause of action cognizable at law a motion for dismissal will fail” (Guggenheimer v Ginzburg, 43 NY2d 268, 275). Moreover, in order to prevail on a defense based upon documentary evidence (see, CPLR 3211 [a] [1]), the documents relied upon must resolve all of the factual issues as a matter of law (see, Greenwood Packing Corp. v Associated Tel. Design, 140 AD2d 303; Reilly v Town of Brookhaven, 34 AD2d 1001).
We find that the third-party complaint states legally cognizable causes of action against the appellants and that the documentary evidence submitted is not dispositive of the third-party claims. The appellants submitted the retainer agreement between the appellant Rosenman & Colin and the estate as proof that, at the time it was retained, the estate had a pre-existing, outstanding Federal estate tax liability and that they mitigated, rather than exacerbated, the plaintiffs initial injuries. The defendants third-party plaintiffs contend that the Form 706, as filed, and its attachments clearly show that a QTIP deduction was taken and that the estate had a right to secure the full deduction. The defendants third-party plaintiffs furnished documentation to show that the IRS had recognized that a grammatical fault in Form 706 had caused taxpayers’ representatives to make defective QTIP elections and that the IRS had decided that those cases should be disposed of by closing agreements pursuant to which the QTIP deduction would be allowed. We, therefore, agree with the Supreme Court that there are factual questions with respect to the timing of the appellants’ involvement in this matter, the alleged impropriety of the closing agreement, and the advice given to the plaintiff with regard thereto. Mangano, P. J., O’Brien, Pizzuto and Santucci, JJ., concur.