Whenever, except in criminal prosecutions, any special penalty, forfeiture, or liability is imposed on any officer of a county or judicial district for nonperformance or malperformance of official duties, the liability therefor attaches to the official bond of the officer, and to the principal and sureties thereon.