Connected Automated Vehicle (CAV) has been considered as a transformative technology to improve traffic performance from various aspects. Many recent efforts have focused on the control of CAVs to dissipate stop-and-go waves in mixed-autonomy traffic. However, the safety impact of the CAV control design has not been fully addressed. A feedback controller that stabilizes the mixed vehicle platoon could cause rear-end collisions in some safety-critical scenarios, which hinders the application of CAV control design. This paper focuses on designing a Safety-critical Traffic Controller (STC) for a leading CAV that guarantees both safety and stability in the closed-loop mixed traffic system. We first propose the safe driving constraints for CAV and HDVs, based on which we design Control Barrier Functions (CBF) to penalize a nominal control input for any safety violation. We synthesize a safety-critical controller by integrating the CBF constraints with a nominal controller that achieves string stability and then solving a Quadratic Programming (QP) problem. Numerical simulations demonstrate that the proposed STC guarantees safety and expands the safety region of the mixed system. Simulations on the NGSIM dataset further validate that STC avoids rear-end collisions in real traffic.