This paper addresses the inverse optimal security control problems for a class of stochastic non-strict feedback nonlinear Cyber-Physical Systems under sensor and actuator attacks. The concerned system model includes both stochastic disturbances and more general nonlinearity. First, to make the control design feasible, a linear state transformation is applied to the attacked system. Furthermore, in the process of backstepping design, based on the Nussbaum gain function formula, fuzzy logic system approximation method, and inverse optimal control theory, combing the available output signal, an output feedback inverse optimal controller is proposed. Specifically, the designed controller not only ensures that the system is secure under network attacks but also optimal in terms of the cost function. Finally, two physical examples are given to verify the effectiveness of the proposed control scheme in various network attacks.