To solve the internal attack problem of the wireless sensor network, this paper proposes a credibility-based trust model by using the existing classical credibility mechanism. The model consists of three levels: credibility calculation, trust management and trust decision-making. Credibility calculation is the core of this model. The direct credibility, indirect credibility and energy credibility are combined to form a comprehensive credibility. The network energy consumption is reduced by updating the credibility regularly. The credibility threshold is set to make trust decisions, and effectively distinguish malicious nodes and aging nodes, thus to ensure the security and reliability of the network. The simulation results show that the model can detect malicious nodes effectively, has a high detection rate, and greatly reduces the energy consumption of the whole network.