Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add page describing database-layer SQL injection #97

Open
zspitz opened this issue Sep 16, 2018 · 0 comments
Open

Add page describing database-layer SQL injection #97

zspitz opened this issue Sep 16, 2018 · 0 comments

Comments

@zspitz
Copy link
Contributor

zspitz commented Sep 16, 2018

The language idioms for avoiding SQL injection which are described here are for use in the application layer -- a programming language / runtime connects to a database server and issues commands, and those commands must not be constructed by concatenating commands and raw user input.

However, if the database system supports it, concatenating input and commands into a new command and executing the new command can also be done on the database side (e.g. within a stored procedure), and is also vulnerable:

CREATE PROCEDURE dbo.GetStudent @FirstName NVARCHAR(255)
AS
BEGIN
    EXECUTE ('SELECT * FROM Students WHERE FirstName = \'' + @FirstName + '\'')
END

because of the following call:

EXECUTE @FirstName = 'Robert\'; DROP TABLE Students; --'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant