What is the main reason to avoid constructing database statements dynamically from unchecked user input?
Answer
The input may change the intended query logic
Explanation
### Why this is right
Unchecked input can be interpreted as part of the database command. That can change the intended query logic and allow actions such as bypassing authentication or accessing data.
### The concept
Dynamic construction from untrusted values mixes data and instructions. Parameterized queries avoid this by providing values separately. Input validation is useful as an additional safeguard, but it does not make unsafe query construction a sound design.
### The other options
- **B. The database will always encrypt the input**: encryption is not the mechanism that prevents query logic from changing.
- **C. Dynamic statements prevent all database errors**: dynamic construction can create errors and injection weaknesses.
- **D. Unchecked input automatically reduces account permissions**: permissions are set through access controls, not by the input itself.
### Terms
- **Unchecked input**: data accepted without sufficient examination against expected rules.
- **Parameterized query**: a query that separates supplied values from its instructions.
### Remember
The key danger is that input may become part of the command.
Related Questions
- A database-backed application needs to stop showing detailed database errors to ordinary users while retaining information for investigation. Which approach best matches the lesson?(intermediate)
- Regular security audits and penetration tests can help identify and fix application weaknesses before attackers exploit them.(basic)
- A Web Application Firewall (WAF) should be treated as a replacement for secure query construction.(basic)
- A database account should have only the permissions required for its task. This is the principle of _____.(basic)
- In blind Structured Query Language (SQL) injection, the attacker cannot directly see the result and instead infers information from application behavior.(basic)
Want to practice more questions like this?
Join myBenkio free and practice past questions for your Nigerian university courses with AI explanations for every answer.
Start Practicing Free