Power grids with increasing number of distributed energy resources (DERs) equipped with fleet of smart devices are exposed to malicious attacks. These malicious actions can ultimately cause a large-scale blackout if these subversive activities are not prevented, detected, or promptly addressed. Power grids are being threatened by a category of cyber-physical attacks, which target both the physical and cyber layers of the system. This paper proposes an autonomous detection and corrective control framework consisting of two algorithms to identify anomalies and provide a corrective action on the distribution system using smart inverters. The proposed framework detects the inverter abnormal behaviors and identifies them as cyber-physical attack or internal failure of the inverter. A model predictive control (MPC) scheme is proposed to detect the inverter internal failure. In the case of inverter failure, the proposed MPC scheme adopts corrective actions to restore the inverter operation with a pre-defined power injection set-points. Additionally, this paper proposes a cyber-physical attack detection mechanism, based on measurements from a geographic community of smart devices. The proposed framework continuously assists the supervisory control and data acquisition (SCADA) system to differentiate anomalies on the distribution system and decide the appropriate control actions for the entire grid.