The regulation of legal certainty for the undercover buy investigation mechanism in online prostitution crimes in this study is to emphasize the validity of the Undercover Buy investigation technique in criminal acts of prostitution through online media, the Undercover Buy research technique is only regulated in narcotics crime, how is the validity of Undercover Buy in law enforcement of the crime of prostitution in this online media. To analyze the existing problems, this study uses a statutory approach, a case approach and a conceptual approach, the results of the Undercover Buy analysis are regulated in the Criminal Procedure Code as a special form of investigation technique, law enforcement of prostitution crime through undercover buy in the future, the investigation is carried out with a series of actions taken by investigators in terms and according to ways regulated by law to seek and collect evidence about criminal acts of prostitution online and to find the suspect.