Depends on the state, but here is Illinois' rule:
RULE 1.6: CONFIDENTIALITY OF INFORMATION
(a) A lawyer shall not reveal information relating to the representation of a client unless the client gives informed consent, the disclosure is impliedly authorized in order to carry out the representation, or the disclosure is permitted by paragraph (b) or required by paragraph (c).
(b) A lawyer may reveal information relating to the representation of a client to the extent the lawyer reasonably believes necessary:
(1) to prevent the client from committing a crime in circumstances other than those specified in paragraph (c);
(2) to prevent the client from committing fraud that is reasonably certain to result in substantial injury to the financial interests or property of another and in furtherance of which the client has used or is using the lawyer’s services;
(3) to prevent, mitigate or rectify substantial injury to the financial interests or property of another that is reasonably certain to result or has resulted from the client’s commission of a crime or fraud in furtherance of which the client has used the lawyer’s services;
(4) to secure legal advice about the lawyer’s compliance with these Rules;
(5) to establish a claim or defense on behalf of the lawyer in a controversy between the lawyer and the client, to establish a defense to a criminal charge or civil claim against the lawyer based upon conduct in which the client was involved, or to respond to allegations in any proceeding concerning the lawyer’s representation of the client; or
(6) to comply with other law or a court order.
(c) A lawyer shall reveal information relating to the representation of a client to the extent the lawyer reasonably believes necessary to prevent reasonably certain death or substantial bodily harm.
(d) Information received by a lawyer participating in a meeting or proceeding with a trained intervener or panel of trained interveners of an approved lawyers’ assistance program, or in an intermediary program approved by a circuit court in which nondisciplinary complaints against judges or lawyers can be referred, shall be considered information relating to the representation of a client for purposes of these Rules.