Новая Школа - онлайн-школа подготовки к ЕГЭ
Задача Задача №3623428
А
Аноним
18 июня 2026 14:15 · публичный вопрос
А
Аноним

555-1) OR 877=(SELECT 877 FROM PG_SLEEP(15))--

Ответ нейросети
18 июня 2026 14:15

What you posted is a time-based blind SQL injection payload intended for PostgreSQL.

Key idea

  • It tries to cause the database to sleep (delay) using pg_sleep(15). If the injection is successful, the server will pause for 15 seconds.
  • The rest of the expression, 877=(SELECT 877 FROM PG_SLEEP(15)), is a boolean check. If the subquery runs (and sleeps), it returns 877, so the comparison becomes true (877 = 877). The -- ends the rest of the SQL statement to avoid syntax errors in the vulnerable query.
  • In short, it’s a test to see if user input is being directly embedded into SQL (concatenated) rather than parameterized. A visible delay indicates the input is being executed as part of the SQL.

Why this matters

  • It’s a classic example of a time-based blind SQL injection technique. Attacks like this don’t necessarily return data but can reveal vulnerability by timing differences.
  • PostgreSQL pg_sleep is commonly used in such proofs-of-concept because it reliably introduces a delay.

Defensive measures (exam-relevant, practical defenses)

  • Use parameterized queries / prepared statements everywhere. Do not concatenate user input into SQL strings.
    • Example (conceptual): cursor.execute("SELECT * FROM users WHERE username = %s AND password_hash = %s", (username, password_hash))
  • Validate and sanitize input, but rely on parameterization first. Whitelist allowed values where possible.
  • Least privilege for DB accounts: ensure the application-only user has minimal rights (no unnecessary superuser or DDL rights).
  • Disable or restrict dangerous functions in the application DB role if possible (e.g., limit use of pg_sleep to non-production environments or remove unsafe dynamic SQL paths).
  • Use an ORM or database access layer that handles escaping and binding correctly.
  • Implement proper error handling to avoid leaking stack traces or SQL content in error messages.
  • Monitoring and defense-in-depth:
    • Enable detailed DB and app logs; watch for unusual delays or “sleep” patterns.
    • Use a WAF or query-based rules to catch obvious injection patterns.
    • Run safe vulnerability tests in a closed lab or staging environment (never on production without authorization).

How you might explain this in an exam

  • It’s a time-based blind SQL injection payload targeting PostgreSQL.
  • It tries to force a delay via pg_sleep(15) and uses a boolean condition to confirm the delay without returning data.
  • The presence of a delay indicates the input is being evaluated as SQL, signaling an injection vulnerability.
  • The remedy is to use parameterized queries, input validation, least-privilege DB accounts, and thorough logging/monitoring.

If you want, I can show Safe, defensive code examples in Python or another language to illustrate how to fix this kind of vulnerability in a typical web app.