Задача Задача №3619915
А
А
It looks like a time-based blind SQL injection payload for PostgreSQL, written in exam-style form.
What it does (high level):
- pg_sleep(15) is a PostgreSQL function that pauses for 15 seconds.
- The payload uses OR 756 = (SELECT 756 FROM pg_sleep(15)) to force a delay when the injected condition is evaluated.
- The idea is to check whether the input is being treated as SQL by the app. If the application is vulnerable, the query will sleep for 15 seconds, which the attacker can notice by measuring the response time.
- The -- at the end is a comment, used to ignore the rest of the original query so the injected part becomes the final condition.
Why this matters in an exam context:
- It demonstrates knowledge of a time-based blind SQL injection technique (as opposed to error-based or union-based).
- It also shows understanding of how input being unsafely concatenated into SQL can lead to logic changes and delays.
Defensive conclusions (how to prevent this in real apps):
- Use parameterized queries / prepared statements for all user inputs. Do not concatenate user input into SQL strings.
- Example idea (PostgreSQL): SELECT * FROM users WHERE id = $1;
- Validate and whitelist input values (e.g., integer IDs should be numeric and within expected ranges).
- Use the principle of least privilege for the database user the app connects with.
- Avoid returning detailed error messages to users; log them server-side instead.
- Consider input sanitization and ORM usage that automatically parameterizes queries.
- Employ web app firewalls and security scanning tools to catch injection patterns (always in a test/authorized environment).
- Regularly review code for dynamic SQL usage and perform security testing in a safe lab.
If you’d like, I can:
- Explain how to recognize similar payloads in exam questions and craft concise defensive answers.
- Provide a short practice question with a defensible answer.
- Show a tiny example in code (safe, non-exploitable) of how to fix a vulnerable query.
