Inspired by the principles of immunity, a danger theory based model for network security risk assessment is proposed. After introducing the principle of the danger theory and with the improved concepts and formal definitions presented, the model architecture is described. And then, the methods of network intrusion detection and security risk assessment are given. Theoretical analysis and simu-lation results show that the proposed model can evaluate the network attack in real-time. Thus, it provides an effective risk assessment solution to network security.