This paper is concerned with the event-based control problem for nonlinear cyber-physical systems (CPSs) with state constraints. A novel security control strategy consisting of a self-triggered mechanism is developed to decrease the network communication loads to the most extent on the basis of ensuring system safety and stability. The maximum capability of the designed self-triggered mechanism to resist denial-of-service (DoS) attacks occurring in controller-actuator (C-A) and sensor-controller (S-C) channels synchronously is also analyzed. In particular, we prove that the security control strategy guarantees the system safety and stability without resulting in Zeno behavior. Finally, a numerical example is provided to demonstrate the prominent effectiveness and the advantages over the existing results.