Mitigating Malicious Attacks in Federated Learning via Confidence-aware Defense