QuestionQ61

VerifiedSecure, monitor, troubleshoot Azure solutions

A Python API uses a SQL statement to retrieve a document from Azure Database for PostgreSQL. The API receives the document ID from user input, and the current implementation inserts that ID directly into the SQL statement.

You need to secure execution of the SQL statement while minimizing the chance of SQL injection. How should the current implementation be modified?

Each configuration may be used once, more than once, or not at all.

Drag & Drop
Modify the SQL statement structure.
Bind user input.
Execute the statement.
Explanation

Parameterized queries keep SQL syntax separate from the document ID value. The ID is bound as an argument and passed in a parameter tuple to the database SDK's execution method, so it is treated as data rather than executable SQL. Escaping quotation marks is not a reliable substitute for parameter binding.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!