In this paper, we investigate the impact of priority assignment on schedule-based attacks in fixed-priority real-time systems. Through the schedule-based attacks, attackers may manipulate the input and output buffers of victim tasks, cause instability, and/or steal hidden information. The success of those attacks highly depends on the proper positioning of the malicious task with respect to the victim tasks in the actual schedule. Firstly, we develop an optimal priority assignment algorithm that incorporates the user specified priority preferences that reflect task types (anterior task, posterior task, or victim task), while still meeting all the deadlines. Secondly, we propose a dynamic delaying algorithm to further reduce posterior schedule-based attacks at run-time. Finally, we derive and compare the performance of six attack-aware priority-assignment policies as well as their dynamic extensions through comprehensive simulations. Our results suggest that the well-known RMS algorithm can be easily outperformed in terms of reducing schedule-based attacks, by properly specifying the relative priorities of malicious, anterior, and posterior tasks through our optimal algorithm. In particular, the AMP assignment, which assigns the anterior, malicious, and posterior tasks execution priorities in decreasing order, is shown to offer rather robust and consistent performance even at high system utilizations. Our framework explicitly incorporates the logical execution time and attack effective window constraints to model schedule-based attacks in realistic manner.