This paper focuses on the design of security enforcement mechanisms for the prevention of denial of service (DoS) attacks in wireless sensor networks. In the first part, we identify the requirement for security enforcement using auction theory, which allows us to detect non-cooperative nodes. Our novel scheme for preventing DoS attacks is called Secure Auction based Routing (SAR). In the proposed protocol, nodes prefer to participate in forwarding incoming packets and gaining reputation in the network. Nodes willing to do so must compete against each other, and the competition is based on auction theory. The amount of bid that each node offers is equal to its utility value; and the price that a winner of a bid pays is a reduction in its original battery power. Since a node’s truthful bidding is shown to be a dominant strategy, in order to prevent DoS attack, nodes that do not bid truthfully should be isolated. In the second part, we formulate the attack–defense problem as a non-cooperative, two-player, non-zero-sum game between an attacker and a wireless sensor network. We show that this game achieves Nash equilibrium, thus leading to a defense strategy for the network. We propose two novel schemes. The first one is called Utility based Dynamic Source Routing (UDSR), which incorporates the total utility of each en-route node in data packets, where utility is the difference between gain and cost for each node. The second scheme is based on a watch-list, where each node earns a rating from its neighbors, based on its previous cooperation in the network. Simulation results show that the proposed game theoretic framework significantly increases the chance of success in defense strategy for the wireless sensor network.