Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 533705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:32:10+00:00 2026-05-13T09:32:10+00:00

The problem We need to defend against a ‘WAITFOR DELAY’ sql injection attack in

  • 0

The problem

We need to defend against a ‘WAITFOR DELAY’ sql injection attack in our java application.

Background

[This is long. Skip to ‘Solution?’ section below if you’re in a rush ]

Our application mostly uses prepared statements and callable statements (stored procedures) in accessing the database.

In a few places we dynamically build-and-execute queries for selection. In this paradigm we use a criteria object to build the query depending on the user-input criteria. For example, if the user specified values for first_name and last_name, the result querying always looks something like this:

SELECT first_name,last_name FROM MEMBER WHERE first_name ='joe' AND last_name='frazier'

(In this example the user would have specified “joe” and “frazier” as his/her input values. If the user had more or less critieria we would have longer or shorter queries. We have found that this approach is easier than using prepared statements and quicker/more performant than stored procedures).

The attack

A vulnerability audit reported an sql injection failure. The attacker injected the value ‘frazier WAITFOR DELAY ’00:00:20’ for the ‘last_name’ parameter, resulting in this sql:

   SELECT first_name,last_name FROM MEMBER WHERE first_name ='joe' AND last_name='frazier' WAITFOR DELAY '00:00:20'

The result: the query executes successfully, but takes 20 seconds to execute. An attacker could tie up all your database connections in the db pool and effectively shut down your site.

Some observations about this ‘WAITFOR DELAY’ attack

  • I had thought that because we used Statement executeQuery(String) we would be safe from sql injection. executeQuery(String) will not execute DML or DDL (deletes or drops). And executeQuery(String) chokes on semi-colons, thus the ‘Bobby Tables’ paradigm will fail (i.e. user enters ‘frazier; DROP TABLE member’ for a parameter. See. http://xkcd.com/327/)

  • The ‘WAITFOR’ attack differs in one important respect: WAITFOR modifies the existing ‘SELECT’ command, and is not a separate command.

  • The attack only works on the ‘last parameter’ in the resulting query. i.e. ‘WAITFOR’ must occur at the very end of the sql statement

Solution, Cheap Hack, or Both?

The most obvious solution entails simply tacking “AND 1=1” onto the where clause.

The resulting sql fails immediately and foils the attacker:

   SELECT first_name,last_name FROM MEMBER WHERE first_name ='joe' AND last_name='frazier' WAITFOR DELAY '00:00:20' AND 1=1

The Questions

  • Is this a viable solution for the WAITFOR attack?
  • Does it defend against other similar vulnerabilities?
  • I think the best option would entail using prepared statements. More work, but less vulnerable.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:32:10+00:00Added an answer on May 13, 2026 at 9:32 am

    The correct way to handle SQL injection is to use parameterized queries. Everything else is just pissing in the wind. It might work one time, even twice, but eventually you’ll get hit by that warm feeling that says “you screwed up, badly!”

    Whatever you do, except parameterized queries, is going to be sub-optimal, and it will be up to you to ensure your solution doesn’t have other holes that you need to patch.

    Parameterized queries, on the other hand, works out of the box, and prevents all of these attacks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 273k
  • Answers 273k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the this keyword when referring to the current item… May 13, 2026 at 2:07 pm
  • Editorial Team
    Editorial Team added an answer I don't think that anything changed regarding the helpers in… May 13, 2026 at 2:07 pm
  • Editorial Team
    Editorial Team added an answer The final fingerprint will depend on what keystore you're using… May 13, 2026 at 2:07 pm

Related Questions

I have a project for school where we need to use flex and bison.
we have a number of c# projects that all depend on a common DLL
I have quite an interesting task at work - I need to find out
We have a c# app that uses a number of libraries (that we wrote
Consider that, for a Windows video game, I need to determine if the key

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.