Formal definitions of state-based and language-based security with respect to timing attacks are proposed and studied. Then various ways how to secure systems with respect to such attacks are discussed. First, we investigate time insertion functions. Conditions, when such functions exist and could protect systems, are investigated. Then we discuss the concept of supervisor control which can be used if there is no appropriate time insertion function to protect the systems.