xkcd.WTF!?

Image loading failed. try again

Exploits of a Mom

Her daughter is named Help I'm trapped in a driver's license factory.

Explanation

Mrs. Roberts receives a call from her son's school. The caller, likely one of the school's administrators, asks if she really named her son Robert'); DROP TABLE Students;--, a rather unusual name. Perhaps surprisingly, Mrs. Roberts responds in the affirmative, claiming that she uses the nickname "Little Bobby Tables." As the full name is read into the school's system's databases without data sanitization, it causes the "Students" table in the database to be dropped, meaning it gets deleted.

This comic was a prequel for the 1337 series where the entire family is shown for the first time. The title of this comic is a pun: "exploit" can mean an accomplishment or heroic deed, but in computer science, the term refers to a program or technique that takes advantage of a vulnerability in other software. The title can also refer to her choice of name for her son, which is rather extraordinary. In SQL, a database programming language, commands are separated by semicolons ;, and strings of text are often delimited using single quotes '. Parts of commands may also be enclosed in parentheses ( and ). Data entries are stored as "rows" within named "tables" of similar items (e.g., Students). The command to delete an entire table (and thus every row of data in that table) is DROP TABLE, as in DROP TABLE Students;. In 1253: Exoplanet Names, someone (presumably Mrs. Roberts) attempts to perform a similar trick, submitting the name e'); DROP TABLE PLANETS;-- to the IAU.

The exploited vulnerability here is that the single quote in the name input was not correctly "escaped" by the software. That is, if a student's name did indeed contain a quote mark, it should have been read as one of the characters making up the text string and not as the marker to close the string, which it erroneously was. Lack of careful parsing is a common SQL vulnerability; this type of exploit is referred to as SQL injection. Mrs. Roberts thus reminds the school to make sure that they have added data filtering code to prevent code injection exploits in the future.

For example, to add information about Elaine to a data table called 'Students', the SQL query could be:
INSERT INTO Students (firstname) VALUES ('Elaine');

However, using the odd name Robert');DROP TABLE Students;--  where we used "Elaine" above, the SQL query becomes:
INSERT INTO Students (firstname) VALUES ('Robert');DROP TABLE Students;-- ');

By insertion of the two semi-colons in the odd name, this is now three well-formed SQL commands:
INSERT INTO Students (firstname) VALUES ('Robert');

DROP TABLE Students;

-- ');

The first line is valid SQL code that will legitimately insert data about a student named Robert. The second line is valid injected SQL code that will delete the whole Students data table from the database. The third line is a valid code comment (--  denotes a comment), which will cause the rest of the line to be ignored by the SQL server. For this to work, it helps to know the structure of the database. But it's quite a good guess that a school's student management database might have a table named Students.

Of course, in real life, most exploits of this kind would be performed not by engineering a person's name such that it would eventually be entered into a school database query, but rather by accessing some kind of input system (such as a website's login screen or search interface) and guessing various combinations by trial and error until something works, perhaps by first trying to inject the SHOW TABLES; command to see how the database is structured. In 2019, a person chose a vanity license plate that said "NULL" and subsequently received thousands of dollars in fines from random vehicles for which the license plate was unavailable. Some database programmers somewhere along the way failed to consider the difference between the string NULL and the value NULL.

In 2017, a Swiss group called their book "<script>alert("!Mediengruppe Bitnik");</script>" to make e-commerce websites display an innocuous pop-up as soon as the book name loads. It immediately worked on several sites and to this day, some websites are still affected. In 2020, the British corporate register accepted a registration for ""><SRC=HTTPS://MJT.XSS.HT> LTD", which was soon officially renamed "THAT COMPANY WHOSE NAME USED TO CONTAIN HTML SCRIPT TAGS LTD" to avoid a cross-site scripting problem.

To include the odd name correctly and harmlessly in the Students table in the school database the correct SQL is:
INSERT INTO Students (firstname) VALUES ('Robert'');DROP TABLE Students;-- ');

Note that the single quote after Robert is now sanitized by doubling it, which changes it from malicious code to harmless data, and the full first 'name' of the student Robert');DROP TABLE Students;-- is now stored correctly. It should be noted that while data sanitization can mitigate the risks of SQL injection, the proper prevention technique is to use Prepared statements. Noting the difference between the "actual" name using the word TABLE and the child's nickname being Bobby Tables, one could argue that there's an implied reference to one of the most argued topics of database naming conventions - should table names be singular or plural.

The title text references that Mrs. Roberts' daughter is named "Help I'm trapped in a driver's license factory". This is a play on how if someone is stuck and forced to work in a manufacturing factory/plant, then they will write on the product "Help I'm trapped in a ____ factory" in order to tell people on the outside. Having this name would cause any police officer who pulls her over to show some concern towards the hypothetical artesan who created the identification. And getting the license in the first place would likely be difficult. The idea of inserting a help message like this was already used in 10: Pi Equals. It was later revealed that the daughter's middle and last names (which she more generally was known by) together are "Elaine Roberts".