Packet routing in computer networks significantly affects the effectiveness of the network, including its security. Various reasons can result in a certain router losing its trust from a security point of view. At the same time, it is necessary to ensure the delivery of packets in the network in general. To address such a situation we propose a new approach to packet routing when a distrustful router appears in the network. The proposed approach completely halts the transmission of transit packets through a distrustful node if it is possible to bypass it. A physical connection to a distrustful node will be used only to transmit packets addressed to this node. If there are no paths to all destinations without using the distrustful node, a path tree is obtained in which the number of nodes that receive packets through the distrustful node is minimized. At the same time, the transmission of packets to all destinations is completely preserved. The outcome of our approach is a path tree that optimizes the routing table, considering the presence of a distrustful router, and minimizes transit flows through this router and the number of physical connections to it.