## 1 Introduction  
A smart grid is a cyber-physical System (CPS) where physical processes, such as power demand and supply, are controlled and monitored from the cyber domain through advanced computation and communication technologies with humans in the loop [1]. The advancement in information and communication technology facilitates efficient grid operations, such as controlling load, distributed generation, resource allocation, and state monitoring through advanced metering infrastructure (AMI). The increase in the deployment of smart meters [2] enables various features such as demand response (DR) through which power engineers control the power demand and supply of a wider geographical area remotely. However, the dependency of the grid's functionalities such as DR on the cyber domain makes it susceptible to cyber-physical attacks (CPA) [3, 4]. Power engineers deploy security resources, such as intrusion detection systems [5, 6] or patch the grid's cyber functions [7, 8], to protect its cyber domain. However, recent attacks [3, 4] show such resource allocation is not sufficient. Although it is necessary to deploy security resources in the cyber domain, it is also vital to prevent attacks even when cyber systems are compromised, in order to cover the worst-case scenario. Over the last decade, researchers have focused on understanding the dynamics and evaluating the resilience of the grid in the presence of CPA [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]. They demonstrated how a cyber-attack propagates to the physical world and destabilize the grid by manipulating power demand and supply. [PERSON] et al. [11] presented the load drop attack to perform a transient sensitivity analysis of the power grid that changes the frequency (beyond a threshold) in a zip code causing generators to trip. [PERSON] et al. [19] show how an adversary controlling a high wattage IoT devices botnet degrades the resilience of the grid. A similar kind of attack is presented by [PERSON] et al. [15] where they increase the power demand by remotely activating the Central Processing Unit (CPUs), Graphical Processing Units (GPUs), etc. By performing contingency simulations in the Power World simulator [9; 10; 15; 19] or using other power models [12], these approaches demonstrated how a cyber-attack on the grid impacts its resilience. While performing contingency analysis, most researchers assume that a cyber system of the grid is compromised, and they analyze its impact on the physical system. Very few [20; 21; 22; 23] focused on designing a system that prevents malicious commands and maintains the grid's resilience even when a cyber system is compromised. Consider an adversary that compromises the DR server. They send malicious commands to perform load curtailment or load shedding in a zip code to manipulate power demand, thus destabilizing the grid. As compared to [22; 23], our motive in this paper is to prevent a compromised cyber system from sending legitimate commands that will put the grid in an unsafe state and start cascading failures. [PERSON] et al. [24] presented a server that provides a security mechanism to monitor and control load as per the security policies during normal operations as well as in the presence of load-altering attacks. The limitation of this approach is that it does not consider the undesired malicious commands that will not physically put the grid in an unsafe state but increase the operational cost in terms of customer dissatisfaction. Moreover, it does not discuss the following points: (1) a more general case where power utility (PU) is compromised and sends malicious commands to destabilize the grid; (2) a different combination of attacks to trick system administrator and how to prevent them using policy server; and (3) the factors that need to be considered for the implementation of a policy server. We address these gaps in this paper by designing an intelligent system that evaluates whether commands issued by a cyber system, which may or may not be compromised, place the grid in an unsafe state.