Agent Security Bench (ASB): Formalizing and Benchmarking Attacks and Defenses in LLM-based Agents