Feature-Aware Malicious Output Detection and Mitigation