From: Christopher Allan Webber <cwebber@dustycloud.org>
To: Jakub Jankiewicz <jcubic@jcubic.pl>
Cc: guile-user@gnu.org
Subject: Re: Prevent SQL Injection in DBI
Date: Mon, 27 Mar 2017 13:24:47 -0500 [thread overview]
Message-ID: <8760iud1cg.fsf@dustycloud.org> (raw)
In-Reply-To: <20170326185427.32f0f832@jcubic>
Jakub Jankiewicz writes:
> Hi all,
>
> I want to use guile-dbi with unsafe user input. I have code like this:
>
> (dbi-query db-obj (string-append "SELECT * FROM users WHERE username = '"
> username
> "'"))
>
> How can I escape username given from user to prevent sql injection?
>
> I could validate username to only contain letters using [a-zA-Z] regex but
> what about other languages that have non Latin letters and names like O'Conor?
> This will also don't work for password that may have special characters.
guile-squee is pretty immature but I do think it does this one bit
correctly... parameters to the procedure shouldn't be substituted in the
string, they should be provided as additional arguments, like
(exec-query db-obj "SELECT * FROM users WHERE username=$1"
'("alice"))
I seem to remember trying to find out if this was possible to do in
dbi-query, and not succeeding at finding such a route? (guile-dbi,
unlike guile-squee, has some maturity though...)
next prev parent reply other threads:[~2017-03-27 18:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-26 16:54 Prevent SQL Injection in DBI Jakub Jankiewicz
2017-03-27 18:24 ` Christopher Allan Webber [this message]
2017-07-10 22:13 ` Linas Vepstas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8760iud1cg.fsf@dustycloud.org \
--to=cwebber@dustycloud.org \
--cc=guile-user@gnu.org \
--cc=jcubic@jcubic.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).