In this paper, we analyze the average secrecy rate (ASR) of a two-way relay system based on an unmanned aerial vehicle (UAV). Specifically, a UAV serves as an aerial relay station, assisting bidirectional transmission between terrestrial users in the presence of terrestrial eavesdroppers. By optimally combining transmit power and UAV trajectory, the total ASR in the proposed system is maximized. The ASR problem, which involves a tight combination of optimal variables and is therefore difficult to solve directly, is effectively addressed through successive convex approximations and block coordinate descent techniques. Simulation results reveal that eavesdroppers with scattered positions are more dangerous than those with concentrated positions. Furthermore, despite the assistance of the UAV, the downlink ASR is still significantly lower than the uplink ASR. Moreover, the ASR in the proposed system is better than that in the benchmark systems.