In the last decade, many security solutions have been proposed to fulfil the security requirements of wireless sensor networks (WSNs). However, these solutions are specifically designed for particular security issues, based on different assumptions, and limited to certain WSNs applications. Can these security solutions work together to handle multiple problems at the same time? It is an interesting and difficult question. We believe good solutions in various security areas do not mean they can work together and deliver similar results, i.e. occurrence of any security weakness or attack in a particular security solution could expose the vulnerabilities of other solutions. Using these solutions together might also degrade WSN quality of service. To deal with the aforementioned issues, we therefore propose a novel component-based security system (COMSEC) based on proactive and reactive components. Each component looks after a particular security issue and is integrated with others. The proposed system provides better secure communication, Sybil attack detection, secure data aggregation and resilience against node capture attacks and replication attacks. COMSEC has been evaluated and compared against existing schemes. Evaluation results show a significant improvement in resilience against node capture attacks, Sybil attack detection data confidentiality, privacy, memory overhead and connectivity. Copyright © 2012 John Wiley & Sons, Ltd.