Evolutionary multitasking optimization (EMTO) has emerged as a powerful tool for addressing complex optimization problems, particularly those involving multiple related tasks. However, current EMTO methods prioritize promoting convergence characteristics while paying little attention to potential privacy leakage issues during knowledge transfer among tasks. This paper designs privacy-preserving centralized and decentralized EMTO models based on inter-task knowledge transfer, and proposes a perturbation query strategy for the centralized EMTO. Furthermore, passive and active attacks in EMTO are proposed for the first time, and an example of active attacks in EMTO is provided by constructing a deceptive malicious task. The active attack technique can serve as a test to determine whether the EMTO methods can effectively identify and defend against malicious knowledge transfer. Experimental results show that the proposed privacy-preserving centralized EMTO method can protect clients’ privacy information while maintaining algorithm performance, and the proposed active attack technique can significantly slow down the convergence speed of the target task.