The sensor attacks towards the flight controller of unmanned aerial vehicles (UAV) induce the UAV to take false sensor signals or data and estimate fault system states, threatening the flight safety of UAVs. The state-of-the-art runtime sensor attack detection and recovery approaches have limited detection accuracy and lack persistence on the recovery effect. The computational resource limit of the UAV hardware also impacts the accuracy of the detection model and the respective attack detection. This paper proposes a runtime UAV sensor attack detection and recovery approach, called LDR, based on lightweight machine-learning models. We leverage the advantage of the machine-learning model’s representation ability on nonlinear feedback control systems compared with the linear system models to build the machine-learning model for each UAV sensor and predict the system states corresponding to each sensor. We also propose a new attack detection algorithm to mitigate the short-time vibration of the prediction deviation to reduce the potential errors. We apply our approach to detecting and recovering the GPS sensor attacks and gyroscope attacks. The experimental results show that the performance overhead of our approach meets the flight controller’s real-time requirements. Our approach is highly robust on normal flight tasks, and the prediction model is effective. The comparisons between our approach and related works demonstrate the effectiveness of our approach.