Motivated by the increasing interaction in cyberspace, researchers are developing optimization in both attack and defense techniques. This optimization is performed using artificial intelligence techniques enhanced with metaheuristics. This study aims to investigate the metaheuristics applied to optimize artificial intelligence techniques in the detection of threats or optimization of attacks by using specific measures: detection or attack technique, purpose and the type of metahauristics involved. The review was carried out in relevant literature databases such as Web of Science, SCOPUS, SciELO, ACM and Google Scholar. The date range of the articles consulted was from 1975 to 2020. After refining the search terms, a total of 126 articles were detected. Using the PRISMA methodology, it was reduced to a total of 41 documents. The research results show that a large proportion of the optimization in the detection of threats is based on the reduction of the features in the training stage. Metaheuristics play a key role in reducing these features. Our research concludes that researchers must reduce the training stage in order to decrease processing requirements and get closer to real time in detection.