See: http://drupal.org/node/167284
%s should never be used without quotes around it. There are some bad uses in project*, but Chad and I looked at the code and none look like actual vulnerabilities.
grep turns up these 2 in project_issue:
issue.inc:444:
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type = 'project_project' AND n.status = 1". ($nids ? " AND n.nid NOT IN (%s)" : "") ." ORDER BY n.title"), implode(',', $nids));
mail.inc:320:
$result = db_query('SELECT p.*, u.name, u.mail FROM {project_subscriptions} p INNER JOIN {users} u ON p.uid = u.uid WHERE u.status = 1 AND p.nid = %d AND (p.level = 2 OR (p.level = 1 AND (%s)))', $node->pid, implode(' OR ', $uids));
Comments
Comment #1
hunmonk commentedsince this is a future defensive programming change, i'm not going to hold up our pending release for it. up'ing the priority to make sure it gets taken care of soon, though.
Comment #2
pwolanin commentedhere's a start
Comment #3
pwolanin commentedor this is simpler and just as safe.
Comment #4
hunmonk commentedi'm not a fan of this approach at all. we need to use "uid = %d", implode those, and put the uid values into an array along w/ $node->pid, which can then be passed into the query for proper filtering.
Comment #5
pwolanin commented@hunmonk - ok, so I'll use the patch in #2 as the starting point for any further testing/changes.
Comment #6
dwwYeah, in spite of it being a little more complex, i think i prefer #2 as well. Why is it CNW? Only because there's no equivalent change for issue.inc, only mail.inc? Anything wrong with #2 for the mail.inc case? I don't see it based on a quick review.
Although... it's not clear why you're bothering to use indexes for the $uid_conditions and $uids arrays. Doesn't look like the code depends on them at all. It'd take less space and would be more readable to write, for example:
Any reason you didn't go that route?
Comment #7
dww(presumably because the existing code needlessly uses an index there...) ;)
Comment #8
hunmonk commentedthe implementation felt a bit heavy to me. cleaned it up a little based on dww's work in the initial %s fix commit.
untested.
Comment #9
hunmonk commentedy el patcho...
Comment #10
dwwLooks ok to me. FYI: hunmonk and I discussed why we use the index: it prevents duplicate SQL clauses when a given user participated in the same issue more than once. So, it's good we're keeping that.
However, we're still missing a patch for issue.inc here...
Comment #11
pwolanin commented@dww - I used the indices simply to mimic the original code - I didn't look that closely, but I assumed the original code was that way since the same nid may be referenced multiple times in the loop.
Comment #12
hunmonk commentedwith issue.inc rolled in...
Comment #13
dwwLooks great, and light testing on a local server went fine. I only tested the email stuff via devel.module's logging of drupal_mail(), but I'm confident enough in the visual inspection of the code that this should just go in. Thanks!
Comment #14
hunmonk commentedcommitted to 4.7.x-1.x, 4.7.x-2.x, HEAD.
Comment #15
(not verified) commented