Ensuring security of systems based on supervisory control and data acquisition (SCADA) is a major challenge. Cyber-physical systems employing remote sensors and actuators and sparse communication networks are pervading the infrastructure. The goal of this thesis is to develop model-based techniques capable of detecting integrity attacks on the sensors of a control system. The effect of integrity attacks on control systems is analyzed and countermeasures capable of exposing such attacks are proposed. The main contributions of the thesis, beyond the novelty of the problem formulation, lies in enumerating the conditions of the feasibility of the replay attack, and suggesting countermeasures that optimize probability of detection by conceding control performance. The methodologies are illustrated and the theoretical results are validated using several sets of simulations. Sensor networks use binary measurements and state estimations for several reasons, including communication and processing overheads. Such a state estimator is vulnerable to attackers that can hijack a subset of the sensors in an effort to change the state estimate. After exhibiting a simulation that demonstrates the possible effect of integrity cyberphysical systems, a prototypical problem of estimating a binary state using measurements provided by binary sensors is considered, and a new approach to estimate the states based on sensor measurements that may have been corrupted by an attacker is proposed. The problem is formulated as a minimax problem in which a detector attempts to maximize the probability of detection in case of the worst case attempt by the attacker to minimize this probability. A fixed form of the detector is proposed in the case where the sensors are of equivalent specifications, along with a method to find the optimal detector parameters. The methodology for designing the detectors resilient to integrity attacks is extended to systems where the sensor measurements are not independent. In cyberphysical systems, the sensors in question monitor a system constrained to obey physical laws, so that physical quantities measured by and the noise in each sensor will be correlated to the sensors close to it. Further increase in the confidence of the estimate can be achieved by considering these correlations. This thesis focuses on modeling the correlation between the sensors and its ramifications on the worst-case probability of detection.