Wireless sensor networks (WSNs) have been widely used in different fields, such as battle field, environment monitoring, and intrusion detection, where amount of nodes are deployed. There are many factors make sensor nodes being more vulnerable to be attacked and compromised. In order to address the issue, many different schemes and methods are proposed. Trust evaluation and trust management play an important role in detecting the malicious nodes. In this paper, we propose a trust management system for clustered WSNs monitoring the sensor nodes' behaviors and evaluating their trust values. This system employs a hash algorithm for generating identify labels for sensor nodes to distinguish external attackers from normal nodes and dynamically manages the trust value of each node to detect the compromised nodes based on the trust evaluating model, which is based on beta density function. The simulation results show that our scheme can detect the malicious nodes quickly, which prevents clustered WSNs from external attacks and internal compromised nodes' attacks. Copyright (c) 2015 John Wiley & Sons, Ltd.