To address the challenges of selecting task schemes and ensuring secure channels duringdata collection and transmission by unmanned aerial vehicles, the study divides the secure transmission model into physical domain and social domain based on graph theory to ensure the security of unmanned aerial vehicles during task execution. Secondly, the multi to one matching problem was optimized through matching theory, achieving maximum benefits between drones and ground to ground (D2D) users. This study designed a stable matching scheme for drone task allocation based on bipartite graphs and a popular matching strategy for drone security spectrum resource allocation based on bipartite graphs. By adapting the design of a series of coherent actions of drones from information collection to information transmission, the efficiency and security of drone information transmission can be improved. The experimental results show that the average revenue of the designed algorithm for unmanned aerial vehicles is between 21 and 40, while the average revenue range for a single task is between 173 and 210. Compared with other algorithms in terms of security performance for drones and D2D users, the algorithm designed in the study shows strong advantages. Specifically, in terms of drone safety performance, the design algorithm's performance improves as the spectrum sharing limit increases. The advantage becomes more obvious when the sharing limit value reaches 1; From the perspective of D2D users, the average worst-case safety rate of the design algorithm increases with the increase of flight cycle and average power. Compared tofixed-trajectory drones, the overall performance gain of the research and design algorithm reaches about 18.2%, and compared with fixed power drones, the overall performance gain reaches about 15.5%. In summary, the research has made significant progress in task allocation and channel security spectrum resource allocation. The design algorithm achieves the optimal effect between computational complexity and performance, and overall maximizes the benefits between drones and D2D users.