Over recent years, the number of cyberattacks on safety-critical systems, including railways has been rapidly increasing. To analyze the impact of cyberattacks on safety, we need to create methods supporting a systematic and rigorous analysis of system behavior in the presence of cyber threats. In this paper, we propose a methodology and automated tool support for an integrated analysis of the impact of cyberattacks on the safety of railway systems. Our approach relies on graphical modeling in SysML, HAZOP-based analysis of cyber threats and formal modeling in Event-B. The proposed approach allows the designers to identify and visualize the safety requirements that become violated as a result of various cyberattacks.