Ensuring that a program uses an Application Programming Interface (API) correctly may be a challenging task. It requires having a specification of that API and verifying that the program uses that API according to that specification. Unfortunately, specifications are not always available or, if they are, they may be embedded into the documentation of the API among other information and not easily accessible. Assuming that a specification is indeed available, it becomes then necessary to verify that the code of the program does not violate that specification. This also is a difficult task because programs can be arbitrarily large and complex, and a specification violation may be the result of subtle interactions of different parts of the program code.
As part of the SAFE project, we have designed, developed and published two static analysis tools:
Although this work is more general than just security, it has a strong applicability to security APIs, as we showed in our papers. The reason for this is that using security (and, in particular, cryptography) APIs requires following well-defined specifications. For example, after instantiating a Java java.security.Signature object, a program can use that object to either sign or verify a document. The specification of the Signature API establishes veru precise usage patterns. Specifically, if the Signature object is to be used for signing, then its sign method be invoked, but that can only be done after invoking initSign. Similarly, if the Signature object is to be used for verifying, then its verify method must be invoked, but that can only be done after invoking initVerify. Any sequence of operations that does not respect one of these two patterns will inevitably generate a run-time error. Unfortunately, the compiler will not detect deviations from this specification. Our work can be used to detect this type of API specifications by mining client programs that use a given API, and by then verifying whether a certain client program uses an API according to the specification that was mined.
Please visit the SAFE Web site for more details on this work.
