The Boundary Between Code and Data
Software systems constantly translate between instructions and information. A browser interprets markup, a database processes queries, and a programming language evaluates expressions. Problems arise when a system cannot reliably distinguish the instructions it is meant to execute from the data supplied by a user.
This is not an abstract edge case. Search terms, account names, uploaded files and form values are all data. If a program inserts those values directly into a command or query, characters intended as ordinary content may be interpreted as part of the instruction. The resulting flaw is often described as injection, but the deeper issue is a broken boundary.
When querying a database, parameterised statements keep the query structure separate from the values supplied at runtime. The database receives the intended operation and the user-provided values through distinct channels. This is safer than constructing a query by concatenating strings, because the data is not simply pasted into the command text.
The same principle applies to HTML. Text should be inserted as text, not treated as trusted markup. When an application intentionally accepts markup, it needs an explicit sanitisation policy appropriate to the allowed content. Escaping must also be context-aware: the correct treatment depends on whether a value is placed in HTML text, an attribute, a URL, CSS or JavaScript.
Input validation is useful, but it is not a replacement for preserving this separation. Validation checks whether a value fits the application’s expected rules. Parameterisation and context-aware encoding ensure that accepted values remain data in the environment where they are used.
It is tempting to treat injection prevention as a last-minute security checklist. A more reliable approach is to design interfaces so that code and data remain distinct throughout the system. Use APIs that accept structured values, avoid evaluating strings as code, and make trust boundaries visible during review.
Tests should include ordinary inputs as well as values containing punctuation, delimiters and unexpected formats. The goal is not to reject every unusual character. It is to ensure that unusual data cannot silently change the program’s instructions.
This boundary is one of the quiet foundations of safe software. When it is maintained, users can supply information without becoming accidental authors of the commands the system executes.