The invention discloses a method for preventing a network attack performed by using legal data or tampering the legal data. A timestamp, an unrepeated random number and an appointed salt value are added into requested service data, a hash algorithm is performed on the above data to acquire a hash value, and a service terminal uploads both the above data and the service data to a server while accessing a cloud; a cloud signature verification module verifies whether the timestamp and the hash value accord with signature verification, if yes, the access data, and the timestamp, unrepeated randomnumber and salt value, appointed by the cloud and the terminal, uploaded by the service terminal are subjected to the hash algorithm to acquire the hash value, and then the acquired hash value is compared with the hash value uploaded by the service terminal, if the two hash values are consistent, the verification is passed, the subsequent work can be performed, and the hash value uploaded by the service terminal in this time is cached for being compared with the hash value accessed latterly, and if the above two hash values are inconsistent, a service request is rejected. According to the method provided by the invention, the situation that the normal access is affected due to the fact that the server resources are illegally occupied can be avoided, and thus the purpose of protecting network and server resources is achieved.