Internet of Things (IoT) technology has a dynamic atmosphere due to incorporating multiple smart peripherals, which provide autonomous homes, cities, manufacturing industries, medical domain, etc.; however, a threat by cyber security is still at constant risk, and it gets much attention in researches. Cyber issues in the IoT environment are usually coming due to intruder’s malware activity. This kind of malware affects the confidential data of users in the IoT environment. In this research, a novel framework is implemented with the association of an improved deep LSTM with Harris Hawk Optimization (DLSTM-HHO). This framework is highly improved by adopting an Apache Spark technique for pre-processing IoT dataset. An Apache Spark replaces the traditional data pre-processing, which provides more efficiency to this model for detecting the malware at the edge of the IoT environment. The implementation of this framework is done in the MATLAB2020a platform with Apache Spark. The proposed model provides better performance evaluation in terms of accuracy is at 98%, and the F1-Score at 98.5%.