![]() |
|||||||||||||||||||||||||||||||||||||
SQL Virus Using Quines |
|||||||||||||||||||||||||||||||||||||
| A quine is a program that prints its own source code. If an RFID tag contains a quine, and it is executed on the database, the quine's source code can be copied onto other tags, spreading the virus. | |||||||||||||||||||||||||||||||||||||
PrerequisitesFor this virus to work, it is required that the database API allows multiple queries to be executed in a single API function call. To prevent errors, it is required that the API allows comments to be entered. To allow the quine to be executed at all, it is also required that the tag's contents are not escaped properly. |
|||||||||||||||||||||||||||||||||||||
DescriptionWhen a tag is scanned, its contents are loaded into the database using Query 1. The tag's contents and id will be inserted at the marked locations.
If the contents read from the tag are not escaped properly, inserting a single quote (') into the contents field will allow an attacker to modify the query. This exploit modifies the query so that the virus is copied into the NewContents field. When a tag's content field is updated, the virus will be copied onto the tag, allowing it to infect other systems. |
|||||||||||||||||||||||||||||||||||||
Exploit 1 shows the MySQL
form of this virus.
@a is
created and initialized. It contains the code on the third
line, in textual form.
The third line updates the Following the duplication of the virus, the payload is
executed. This is followed by a comment marker, to disable
the original end of Query 1
( |
|||||||||||||||||||||||||||||||||||||
ScopeThe virus can execute any SQL code the middleware is allowed to execute. Additionally, the virus can be used to propagate client-side scripting and Server-Side Include attacks. |
|||||||||||||||||||||||||||||||||||||
Concrete ExamplesThe following examples are available:
|
|||||||||||||||||||||||||||||||||||||
Affected SystemsPostgreSQL and Microsoft SQL Server allow multiple queries in a single API call and are therefore vulnerable. MySQL also allows multiple queries, but this feature must explicitly be enabled. Oracle does not allow this through the OCI API, but it is possible through iSQL*Plus. All these API's also allow comments to be specified. |
|||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||