A surety is liable, notwithstanding any mere personal disability of the principal, though the disability be such as to make the contract void against the principal; but he is not liable if for any other reason there is no liability upon the part of the principal at the time of the execution of the contract, or the liability of the principal thereafter ceases, unless the surety has assumed liability with knowledge of the existence of the defense. Where the principal is not liable because of mere personal disability, recovery back by the creditor of any res which formed all or part of the consideration for the contract shall have the effect upon the liability of the surety which is attributed to the recovery back of such a res under the law of sales generally.
Ca. Civ. Code § 2810