After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 168147 - Save to database doesn't quote inserts
Save to database doesn't quote inserts
Status: RESOLVED FIXED
Product: planner
Classification: Other
Component: General
0.12
Other Linux
: Normal normal
: 0.14
Assigned To: planner-maint
planner-maint
: 318471 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-02-22 13:02 UTC by Iain Rae
Modified: 2008-12-24 15:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch that escapes and quotes all strings in SQL statements (18.47 KB, patch)
2008-04-30 21:45 UTC, Maurice van der Pot
none Details | Review

Description Iain Rae 2005-02-22 13:02:15 UTC
Distribution/Version: FC3

1.Create a new project
2. Create a new task.
3. Edit tha task and in the notes section put
this'll mess it up
4 close the task and attempt to save to database, planner will fail (no error
messages on the desktop) with the following error on the command line

[iainr@eagle bugzilla2planner]$ planner

** (planner:10738): WARNING **: INSERT command failed (task) ERROR:  syntax
error at or near "ll" at character 204
.

** (planner:10738): WARNING **: Couldn't write tasks.


and from the postgres log file we get:

LOG:  statement: UPDATE project SET cal_id=40 WHERE proj_id=62
LOG:  statement: UPDATE project SET default_group_id=NULL WHERE proj_id=62
LOG:  statement: INSERT INTO task(proj_id, parent_id, name, note, start, finish,
work, duration, percent_complete, is_milestone, is_fixed_work, constraint_type,
constraint_time, priority) VALUES(62, NULL, 'thing', 'this'll mess it up',
'2005-02-22 00:00:00+0', '2005-02-22 17:00:00+0', 28800, 28800, 0, false, true,
'ASAP', NULL, 0)
ERROR:  syntax error at or near "ll" at character 204
LOG:  statement: COMMIT

The code inserting the row is treating the apostrophe in the text as a '
character in the SQL, it needs to be quoted somehow.
Comment 1 Jani Tiainen 2005-03-16 20:13:35 UTC
Seems that there is fundamental bug in code. There should be use of bind
variables, instead of injecting values to insert-clause (by using sprintf or
similiar), it will fix this issue.

This is also a security issue called "SQL injection". 
Comment 2 fmoraes 2005-04-15 03:09:50 UTC
Reading some blogs, it seems the GdaParameterList is not used and being planned
for removal from libgda, so that's not an option.
Comment 3 Richard Hult 2005-10-13 20:09:28 UTC
*** Bug 318471 has been marked as a duplicate of this bug. ***
Comment 4 Martin-Éric Racine 2007-07-18 16:24:19 UTC
Given how this is indicated ans an SQL Injection security issue, it would be desirable to fix this ASAP.
Comment 5 Stefan Ritter 2007-11-19 11:00:07 UTC
hi,

i am using 0.14.2 and this bug isn't fixed yet.
would it be fixed in the future?

regards. stefan
Comment 6 David Paleino 2008-04-27 13:14:11 UTC
Hi,
I'm adopting the Debian package for planner, and I'd like to know whether this bug is going to be fixed any soon.

Thanks,
David
Comment 7 Martin-Éric Racine 2008-04-27 13:19:23 UTC
It might be a good idea to sync with the 0.14.3-2 package that is currently in Debian/unstable, before you actually adopt the package.
Comment 8 David Paleino 2008-04-27 13:22:54 UTC
Hi Martin,
I'm already using Debian sid/experimental, thus planner is at 0.14.3-2. I was just reviewing the BTS page of planner, and I posted that comment just to hear^Wread something from upstream about this bug.
Comment 9 Maurice van der Pot 2008-04-28 17:35:28 UTC
I'll look into this, but don't let that stop you from submitting a patch =)
Comment 10 Maurice van der Pot 2008-04-30 21:45:03 UTC
Created attachment 110193 [details] [review]
Patch that escapes and quotes all strings in SQL statements

I would appreciate it if someone can review this patch in detail.
I tried to make sure I got all possible places where SQL could be injected.
Comment 11 Maurice van der Pot 2008-12-24 15:20:44 UTC
I solved it slightly differently in the current development version. Support for libgda versions older than 3.0 has been dropped in the process. Bind variables are still not fully supported in 3.0, so that'll have to wait until we support 4.0.