A party of whom a bond or other undertaking is required or permitted or by law allowed may agree with his sureties for the deposit or safekeeping of any or all moneys, assets and other property for which he, she or it is or may be held responsible, with a bank, savings bank, safe deposit, savings and loan association or trust company authorized by law to do business as such, and in such manner as to prevent the withdrawal or alienation thereof without the written consent of such sureties or an order of the court having jurisdiction of such fiduciary made on such notice to such sureties as such court may direct. It shall be lawful for such sureties to enter into contracts for their indemnity or security with any person, partnership, association or corporation, provided that such contracts are not prohibited by law or against public policy.
215 ILCS 5/391